Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ProviderName is the name of the k8s cloud provider. ProviderName = "k8s" // PodsByIPIndexName is the name of the index function storing pods by IP. PodsByIPIndexName = "PodByIP" // AnnotationPrefix is the annotation prefix that is turned into tags by default. AnnotationPrefix = "gostatsd.atlassian.com/" // TagNameRegexSubexp is the name of the regex subexpression that is used to parse tag names from label/annotation // names. TagNameRegexSubexp = "tag" // ParamAPIQPS is the maximum amount of queries per second we allow to the Kubernetes API server. This is // so we don't overwhelm the server with requests under load. ParamAPIQPS = "kube-api-qps" // ParamAPIQPSBurst is the amount of queries per second we can burst above ParamAPIQPS. ParamAPIQPSBurst = "kube-api-burst" // ParamAnnotationTagRegex is a regex to check annotations against. Any pod annotations matching // this pattern will be included as tags on metrics emitted by that pod. The tag name for these annotations will // be the capture group named "tag". "" means ignore all annotations. ParamAnnotationTagRegex = "annotation-tag-regex" // ParamLabelTagRegex is a list of regexes to check labels against. Any pod labels matching this // pattern will be included as tags on metrics emitted by that pod. The tag name for these labels will // be the capture group named "tag". "" means ignore all labels. ParamLabelTagRegex = "label-tag-regex" // KubeconfigContextis the name of the context to use inside a provided ParamKubeconfigPath. If ParamKubeconfigPath // is unset this has no effect. ParamKubeconfigContext = "kubeconfig-context" // ParamKubeconfigPath is the path to the kubeconfig file to use for auth, or "" if using in-cluster auth. ParamKubeconfigPath = "kubeconfig-path" // ParamNodeName is the Kubernetes node name of the node this is running on. This is only used if ParamWatchCluster // is set to false. ParamNodeName = "node-name" // ParamResyncPeriod is the resync period for the pod cache as a Duration. ParamResyncPeriod = "resync-period" // ParamUserAgent is the user agent used when talking to the k8s API. ParamUserAgent = "user-agent" // ParamWatchCluster is true if we should watch pods in the entire cluster, false if we should watch pods on our // own node. ParamWatchCluster = "watch-cluster" // DefaultAPIQPS is the default maximum amount of queries per second we allow to the Kubernetes API server. DefaultAPIQPS = 5 // DefaultAPIQPSBurst is the default amount of queries per second we can burst above the maximum QPS. DefaultAPIQPSBurst = 10 // DefaultKubeconfigContext is the default context to use inside the kubeconfig file. "" means use the current // context without switching. DefaultKubeconfigContext = "" // DefaultKubeconfigPath is the default path to the kubeconfig file. "" means use in-cluster auth. DefaultKubeconfigPath = "" // DefaultLabelTagRegex is the default ParamLabelTagRegex. Every label is ignored by default. DefaultLabelTagRegex = "" // DefaultNodeName is the default node name to watch pods on when ParamWatchCluster is false. Defaults to unset // as this will fail fast and alert users to set this appropriately. DefaultNodeName = "" // DefaultResyncPeriod is the default resync period for the pod cache. DefaultResyncPeriod = 5 * time.Minute // DefaultUserAgent is the default user agent used when talking to the k8s API. DefaultUserAgent = "gostatsd" // DefaultWatchCluster is the default watch mode for pods. By default we watch the entire cluster. DefaultWatchCluster = true )
Variables ¶
View Source
var ( // DefaultAnnotationTagRegex is the default ParamAnnotationTagRegex. Everything beginning with a standard // gostatsd string is included by default. The default sets the tag name as the part after the "/", for example // gostatsd.atlassian.com/tag1 would return "tag1" as the tag name after matching. DefaultAnnotationTagRegex = fmt.Sprintf("^%s%s$", regexp.QuoteMeta(AnnotationPrefix), DefaultTagCaptureRegex) // DefaultTagCaptureRegex is a regex subexpression to capture from now until the end of the regex as the tag name. DefaultTagCaptureRegex = fmt.Sprintf("(?P<%s>.*)", TagNameRegexSubexp) )
Functions ¶
func NewProviderFromViper ¶
func NewProviderFromViper(v *viper.Viper, logger logrus.FieldLogger, version string) (gostatsd.CachedInstances, error)
NewProviderFromViper returns a new k8s provider.
Types ¶
type PodInformerOptions ¶
PodInformerOptions represent options for a pod informer.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider represents a k8s provider.
func NewProvider ¶
func NewProvider(logger logrus.FieldLogger, clientset kubernetes.Interface, podInfOpts PodInformerOptions, annotationRegex, labelRegex *regexp.Regexp) (*Provider, error)
NewProvider returns a new k8s provider. annotationRegex and/or labelRegex can be nil to disable annotation/label matching.
func (*Provider) EstimatedTags ¶
func (*Provider) InfoSource ¶
func (p *Provider) InfoSource() <-chan gostatsd.InstanceInfo
Click to show internal directories.
Click to hide internal directories.