Documentation ¶
Index ¶
Constants ¶
const ( // PrometheusScrapeAnnotation standard Prometheus scrape annotation key PrometheusScrapeAnnotation = "prometheus.io/scrape" // PrometheusPathAnnotation standard Prometheus path annotation key PrometheusPathAnnotation = "prometheus.io/path" // PrometheusPortAnnotation standard Prometheus port annotation key PrometheusPortAnnotation = "prometheus.io/port" )
Variables ¶
var DefaultPrometheusCheck = &PrometheusCheck{ Instances: []*OpenmetricsInstance{ { Metrics: openmetricsDefaultMetrics, Namespace: openmetricsDefaultNS, }, }, AD: &ADConfig{ KubeAnnotations: &InclExcl{ Excl: map[string]string{PrometheusScrapeAnnotation: "false"}, Incl: map[string]string{PrometheusScrapeAnnotation: "true"}, }, KubeContainerNames: []string{}, }, }
DefaultPrometheusCheck has the default openmetrics check values To be used when the checks configuration is empty
var ( // PrometheusStandardAnnotations contains the standard Prometheus AD annotations PrometheusStandardAnnotations = []string{ PrometheusScrapeAnnotation, PrometheusPathAnnotation, PrometheusPortAnnotation, } )
Functions ¶
Types ¶
type ADConfig ¶
type ADConfig struct { KubeAnnotations *InclExcl `` /* 127-byte string literal not displayed */ KubeContainerNames []string `` /* 139-byte string literal not displayed */ ContainersRe *regexp.Regexp `mapstructure:",omitempty" yaml:",omitempty"` }
ADConfig contains the autodiscovery configuration data for a PrometheusCheck
func (*ADConfig) GetExcludeAnnotations ¶
GetExcludeAnnotations returns the AD exclude annotations
func (*ADConfig) GetIncludeAnnotations ¶
GetIncludeAnnotations returns the AD include annotations
func (*ADConfig) MatchContainer ¶
MatchContainer returns whether a container name matches the 'kubernetes_container_names' configuration
type InclExcl ¶
type InclExcl struct { Incl map[string]string `mapstructure:"include" yaml:"include,omitempty" json:"include,omitempty"` Excl map[string]string `mapstructure:"exclude" yaml:"exclude,omitempty" json:"exclude,omitempty"` }
InclExcl contains the include/exclude data structure
type LabelJoinsConfig ¶
type LabelJoinsConfig struct { LabelsToMatch []string `mapstructure:"labels_to_match" yaml:"labels_to_match,omitempty" json:"labels_to_match"` LabelsToGet []string `mapstructure:"labels_to_get" yaml:"labels_to_get,omitempty" json:"labels_to_get"` }
LabelJoinsConfig contains the label join configuration fields
type OpenmetricsInstance ¶
type OpenmetricsInstance struct { URL string `mapstructure:"prometheus_url" yaml:"prometheus_url,omitempty" json:"prometheus_url,omitempty"` Namespace string `mapstructure:"namespace" yaml:"namespace,omitempty" json:"namespace"` Metrics []string `mapstructure:"metrics" yaml:"metrics,omitempty" json:"metrics,omitempty"` Prefix string `` /* 126-byte string literal not displayed */ HealthCheck *bool `mapstructure:"health_service_check" yaml:"health_service_check,omitempty" json:"health_service_check,omitempty"` LabelToHostname bool `mapstructure:"label_to_hostname" yaml:"label_to_hostname,omitempty" json:"label_to_hostname,omitempty"` LabelJoins map[string]LabelJoinsConfig `mapstructure:"label_joins" yaml:"label_joins,omitempty" json:"label_joins,omitempty"` LabelsMapper map[string]string `mapstructure:"labels_mapper" yaml:"labels_mapper,omitempty" json:"labels_mapper,omitempty"` TypeOverride map[string]string `mapstructure:"type_overrides" yaml:"type_overrides,omitempty" json:"type_overrides,omitempty"` HistogramBuckets *bool `mapstructure:"send_histograms_buckets" yaml:"send_histograms_buckets,omitempty" json:"send_histograms_buckets,omitempty"` DistributionBuckets bool `` /* 126-byte string literal not displayed */ MonotonicCounter *bool `mapstructure:"send_monotonic_counter" yaml:"send_monotonic_counter,omitempty" json:"send_monotonic_counter,omitempty"` MonotonicWithGauge bool `` /* 126-byte string literal not displayed */ DistributionCountsAsMonotonic bool `` /* 162-byte string literal not displayed */ DistributionSumsAsMonotonic bool `` /* 156-byte string literal not displayed */ ExcludeLabels []string `mapstructure:"exclude_labels" yaml:"exclude_labels,omitempty" json:"exclude_labels,omitempty"` BearerTokenAuth bool `mapstructure:"bearer_token_auth" yaml:"bearer_token_auth,omitempty" json:"bearer_token_auth,omitempty"` BearerTokenPath string `mapstructure:"bearer_token_path" yaml:"bearer_token_path,omitempty" json:"bearer_token_path,omitempty"` IgnoreMetrics []string `mapstructure:"ignore_metrics" yaml:"ignore_metrics,omitempty" json:"ignore_metrics,omitempty"` IgnoreMetricsByLabels map[string]interface{} `mapstructure:"ignore_metrics_by_labels" yaml:"ignore_metrics_by_labels,omitempty" json:"ignore_metrics_by_labels,omitempty"` IgnoreTags []string `mapstructure:"ignore_tags" yaml:"ignore_tags,omitempty" json:"ignore_tags,omitempty"` Proxy map[string]string `mapstructure:"proxy" yaml:"proxy,omitempty" json:"proxy,omitempty"` SkipProxy bool `mapstructure:"skip_proxy" yaml:"skip_proxy,omitempty" json:"skip_proxy,omitempty"` Username string `mapstructure:"username" yaml:"username,omitempty" json:"username,omitempty"` Password string `mapstructure:"password" yaml:"password,omitempty" json:"password,omitempty"` TLSVerify bool `mapstructure:"tls_verify" yaml:"tls_verify,omitempty" json:"tls_verify,omitempty"` TLSHostHeader bool `mapstructure:"tls_use_host_header" yaml:"tls_use_host_header,omitempty" json:"tls_use_host_header,omitempty"` TLSIgnoreWarn bool `mapstructure:"tls_ignore_warning" yaml:"tls_ignore_warning,omitempty" json:"tls_ignore_warning,omitempty"` TLSCert string `mapstructure:"tls_cert" yaml:"tls_cert,omitempty" json:"tls_cert,omitempty"` TLSPrivateKey string `mapstructure:"tls_private_key" yaml:"tls_private_key,omitempty" json:"tls_private_key,omitempty"` TLSCACert string `mapstructure:"tls_ca_cert" yaml:"tls_ca_cert,omitempty" json:"tls_ca_cert,omitempty"` Headers map[string]string `mapstructure:"headers" yaml:"headers,omitempty" json:"headers,omitempty"` ExtraHeaders map[string]string `mapstructure:"extra_headers" yaml:"extra_headers,omitempty" json:"extra_headers,omitempty"` Timeout int `mapstructure:"timeout" yaml:"timeout,omitempty" json:"timeout,omitempty"` Tags []string `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"` Service string `mapstructure:"service" yaml:"service,omitempty" json:"service,omitempty"` MinCollectInterval int `mapstructure:"min_collection_interval" yaml:"min_collection_interval,omitempty" json:"min_collection_interval,omitempty"` EmptyDefaultHost bool `mapstructure:"empty_default_hostname" yaml:"empty_default_hostname,omitempty" json:"empty_default_hostname,omitempty"` MaxReturnedMetrics int `mapstructure:"max_returned_metrics" yaml:"max_returned_metrics,omitempty" json:"max_returned_metrics,omitempty"` }
OpenmetricsInstance contains the openmetrics check instance fields
type PrometheusAnnotations ¶
PrometheusAnnotations abstracts a map of prometheus annotations
func (PrometheusAnnotations) AnnotationsDiffer ¶
func (a PrometheusAnnotations) AnnotationsDiffer(first, second map[string]string) bool
AnnotationsDiffer returns whether the Prometheus AD include annotations have changed
func (PrometheusAnnotations) IsMatchingAnnotations ¶
func (a PrometheusAnnotations) IsMatchingAnnotations(svcAnnotations map[string]string) bool
IsMatchingAnnotations returns whether annotations matches the AD include rules for Prometheus
type PrometheusCheck ¶
type PrometheusCheck struct { Instances []*OpenmetricsInstance `mapstructure:"configurations" yaml:"configurations,omitempty" json:"configurations"` AD *ADConfig `mapstructure:"autodiscovery" yaml:"autodiscovery,omitempty" json:"autodiscovery"` }
PrometheusCheck represents the openmetrics check instances and the corresponding autodiscovery rules
func (*PrometheusCheck) Init ¶
func (pc *PrometheusCheck) Init() error
Init prepares the PrometheusCheck structure and defaults its values init must be called only once
func (*PrometheusCheck) IsExcluded ¶
func (pc *PrometheusCheck) IsExcluded(annotations map[string]string, namespacedName string) bool
IsExcluded returns whether is the annotations match an AD exclusion rule