Documentation
¶
Index ¶
Constants ¶
const ( // LabelCallStatus represents the status of the exec plugin call, indicating whether it was successful or failed. // These are the possible values, as of the current client-go version: // no_error, plugin_execution_error, plugin_not_found_error, client_internal_error LabelCallStatus = "call_status" // LabelCode represents either the HTTP status code returned by the request or the exit code of the command run. LabelCode = "code" // LabelHost represents the hostname of the server to which the request was made. LabelHost = "host" // LabelMethod represents the HTTP method used for the request (e.g., GET, POST). LabelMethod = "method" // LabelResult represents an attempt to get a transport from the transport cache. // These are the possible values, as of the current client-go version: hit, miss, unreachable // `unreachable` indicates that the cache was not usable for a given REST config because, for example, TLS files // couldn't be loaded, or a proxy is being used. LabelResult = "result" // LabelVerb represents the Kubernetes API verb used in the request (e.g., list, get, create). LabelVerb = "verb" )
The label names are meant to match this: https://github.com/kubernetes/component-base/blob/264c1fd30132a3b36b7588e50ac54eb0ff75f26a/metrics/prometheus/restclient/metrics.go Even in cases where the label name doesn't align well with Argo CD's other labels, we use the Kubernetes labels to make it easier to copy/paste dashboards/alerts/etc. designed for Kubernetes.
Variables ¶
This section is empty.
Functions ¶
func RegisterWithPrometheus ¶
func RegisterWithPrometheus(registry prometheus.Registerer)
RegisterWithPrometheus registers the kubectl metrics with the given prometheus registry.
Types ¶
type KubectlMetrics ¶
type KubectlMetrics struct {
// contains filtered or unexported fields
}
func NewKubectlMetrics ¶
func NewKubectlMetrics() *KubectlMetrics
NewKubectlMetrics returns a new KubectlMetrics instance with the given initiator, which should be the name of the Argo CD component that is producing the metrics.
After initializing the KubectlMetrics instance, you must call RegisterWithClientGo to register the metrics with the client-go metrics library.
You must also call RegisterWithPrometheus to register the metrics with the metrics server's prometheus registry.
So these three lines should be enough to set up kubectl metrics in your metrics server:
kubectlMetricsServer := metricsutil.NewKubectlMetrics("your-component-name") kubectlMetricsServer.RegisterWithClientGo() metricsutil.RegisterWithPrometheus(registry)
Once those functions have been called, everything else should happen automatically. client-go will send observations to the handlers in this struct, and your metrics server will collect and expose the metrics.
func (*KubectlMetrics) RegisterWithClientGo ¶
func (k *KubectlMetrics) RegisterWithClientGo()
RegisterWithClientGo sets the metrics handlers for the go-client library. We do not use the metrics library's `RegisterWithClientGo` method, because it is protected by a sync.Once. controller-runtime registers a single handler, which blocks our registration of our own handlers. So we must rudely set them all directly.
Since the metrics are global, this function should only be called once for a given Argo CD component.