types

package
v0.0.2-0...-4ce78c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
var (
	// PrometheusStandardAnnotations contains the standard Prometheus AD annotations
	PrometheusStandardAnnotations = []string{
		PrometheusScrapeAnnotation,
		PrometheusPathAnnotation,
		PrometheusPortAnnotation,
	}
)

Functions

func BuildURL

func BuildURL(annotations map[string]string) string

BuildURL returns the 'prometheus_url' based on the default values and the prometheus path and port annotations

Types

type ADConfig

type ADConfig struct {
	KubeAnnotations    *InclExcl      `mapstructure:"kubernetesAnnotations,omitempty" yaml:"kubernetesAnnotations,omitempty" json:"kubernetesAnnotations,omitempty"`
	KubeContainerNames []string       `` /* 133-byte string literal not displayed */
	ContainersRe       *regexp.Regexp `mapstructure:",omitempty" yaml:",omitempty"`
}

ADConfig contains the autodiscovery configuration data for a PrometheusCheck

func (*ADConfig) GetExcludeAnnotations

func (ad *ADConfig) GetExcludeAnnotations() map[string]string

GetExcludeAnnotations returns the AD exclude annotations

func (*ADConfig) GetIncludeAnnotations

func (ad *ADConfig) GetIncludeAnnotations() map[string]string

GetIncludeAnnotations returns the AD include annotations

func (*ADConfig) MatchContainer

func (ad *ADConfig) MatchContainer(name string) bool

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:"labelsToMatch" yaml:"labelsToMatch,omitempty" json:"labelsToMatch"`
	LabelsToGet   []string `mapstructure:"labelsToGet" yaml:"labelsToGet,omitempty" json:"labelsToGet"`
}

LabelJoinsConfig contains the label join configuration fields

type OpenmetricsInstance

type OpenmetricsInstance struct {
	URL                           string                      `mapstructure:"prometheusUrl" yaml:"prometheusUrl,omitempty" json:"prometheusUrl,omitempty"`
	Namespace                     string                      `mapstructure:"namespace" yaml:"namespace,omitempty" json:"namespace"`
	Metrics                       []string                    `mapstructure:"metrics" yaml:"metrics,omitempty" json:"metrics,omitempty"`
	Prefix                        string                      `mapstructure:"prometheusMetricsPrefix" yaml:"prometheusMetricsPrefix,omitempty" json:"prometheusMetricsPrefix,omitempty"`
	HealthCheck                   bool                        `mapstructure:"healthServiceCheck" yaml:"healthServiceCheck,omitempty" json:"healthServiceCheck,omitempty"`
	LabelToHostname               bool                        `mapstructure:"labelToHostname" yaml:"labelToHostname,omitempty" json:"labelToHostname,omitempty"`
	LabelJoins                    map[string]LabelJoinsConfig `mapstructure:"labelJoins" yaml:"labelJoins,omitempty" json:"labelJoins,omitempty"`
	LabelsMapper                  map[string]string           `mapstructure:"labelsMapper" yaml:"labelsMapper,omitempty" json:"labelsMapper,omitempty"`
	TypeOverride                  map[string]string           `mapstructure:"typeOverrides" yaml:"typeOverrides,omitempty" json:"typeOverrides,omitempty"`
	HistogramBuckets              bool                        `mapstructure:"sendHistogramsBuckets" yaml:"sendHistogramsBuckets,omitempty" json:"sendHistogramsBuckets,omitempty"`
	DistributionBuckets           bool                        `mapstructure:"sendDistributionBuckets" yaml:"sendDistributionBuckets,omitempty" json:"sendDistributionBuckets,omitempty"`
	MonotonicCounter              bool                        `mapstructure:"sendMonotonicCounter" yaml:"sendMonotonicCounter,omitempty" json:"sendMonotonicCounter,omitempty"`
	DistributionCountsAsMonotonic bool                        `` /* 150-byte string literal not displayed */
	DistributionSumsAsMonotonic   bool                        `` /* 144-byte string literal not displayed */
	ExcludeLabels                 []string                    `mapstructure:"excludeLabels" yaml:"excludeLabels,omitempty" json:"excludeLabels,omitempty"`
	BearerTokenAuth               bool                        `mapstructure:"bearerTokenAuth" yaml:"bearerTokenAuth,omitempty" json:"bearerTokenAuth,omitempty"`
	BearerTokenPath               string                      `mapstructure:"bearerTokenPath" yaml:"bearerTokenPath,omitempty" json:"bearerTokenPath,omitempty"`
	IgnoreMetrics                 []string                    `mapstructure:"ignoreMetrics" yaml:"ignoreMetrics,omitempty" json:"ignoreMetrics,omitempty"`
	Proxy                         map[string]string           `mapstructure:"proxy" yaml:"proxy,omitempty" json:"proxy,omitempty"`
	SkipProxy                     bool                        `mapstructure:"skipProxy" yaml:"skipProxy,omitempty" json:"skipProxy,omitempty"`
	Username                      string                      `mapstructure:"username" yaml:"username,omitempty" json:"username,omitempty"`
	Password                      string                      `mapstructure:"password" yaml:"password,omitempty" json:"password,omitempty"`
	TLSVerify                     bool                        `mapstructure:"tlsVerify" yaml:"tlsVerify,omitempty" json:"tlsVerify,omitempty"`
	TLSHostHeader                 bool                        `mapstructure:"tlsUseHostHeader" yaml:"tlsUseHostHeader,omitempty" json:"tlsUseHostHeader,omitempty"`
	TLSIgnoreWarn                 bool                        `mapstructure:"tlsIgnoreWarning" yaml:"tlsIgnoreWarning,omitempty" json:"tlsIgnoreWarning,omitempty"`
	TLSCert                       string                      `mapstructure:"tlsCert" yaml:"tlsCert,omitempty" json:"tlsCert,omitempty"`
	TLSPrivateKey                 string                      `mapstructure:"tlsPrivateKey" yaml:"tlsPrivateKey,omitempty" json:"tlsPrivateKey,omitempty"`
	TLSCACert                     string                      `mapstructure:"tlsCaCert" yaml:"tlsCaCert,omitempty" json:"tlsCaCert,omitempty"`
	Headers                       map[string]string           `mapstructure:"headers" yaml:"headers,omitempty" json:"headers,omitempty"`
	ExtraHeaders                  map[string]string           `mapstructure:"extraHeaders" yaml:"extraHeaders,omitempty" json:"extraHeaders,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:"minCollectionInterval" yaml:"minCollectionInterval,omitempty" json:"minCollectionInterval,omitempty"`
	EmptyDefaultHost              bool                        `mapstructure:"emptyDefaultHostname" yaml:"emptyDefaultHostname,omitempty" json:"emptyDefaultHostname,omitempty"`
}

OpenmetricsInstance contains the openmetrics check instance fields

type PrometheusAnnotations

type PrometheusAnnotations map[string]string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL