Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/integrations/v2/common/metrics.go
5370 views
1
package common
2
3
import (
4
"github.com/grafana/agent/pkg/integrations/v2/autoscrape"
5
"github.com/prometheus/prometheus/model/labels"
6
)
7
8
// MetricsConfig is a set of common options shared by metrics integrations. It
9
// should be utilised by an integration's config by inlining the common
10
// options:
11
//
12
// type IntegrationConfig struct {
13
// Common common.MetricsConfig `yaml:",inline"`
14
// }
15
type MetricsConfig struct {
16
Autoscrape autoscrape.Config `yaml:"autoscrape,omitempty"`
17
InstanceKey *string `yaml:"instance,omitempty"`
18
ExtraLabels labels.Labels `yaml:"extra_labels,omitempty"`
19
}
20
21
// ApplyDefaults applies defaults to mc.
22
func (mc *MetricsConfig) ApplyDefaults(g autoscrape.Global) {
23
if mc.Autoscrape.Enable == nil {
24
val := g.Enable
25
mc.Autoscrape.Enable = &val
26
}
27
if mc.Autoscrape.MetricsInstance == "" {
28
mc.Autoscrape.MetricsInstance = g.MetricsInstance
29
}
30
if mc.Autoscrape.ScrapeInterval == 0 {
31
mc.Autoscrape.ScrapeInterval = g.ScrapeInterval
32
}
33
if mc.Autoscrape.ScrapeTimeout == 0 {
34
mc.Autoscrape.ScrapeTimeout = g.ScrapeTimeout
35
}
36
}
37
38