-
Notifications
You must be signed in to change notification settings - Fork 487
/
metrics.go
36 lines (33 loc) · 1.05 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package common
import (
"github.com/grafana/agent/pkg/integrations/v2/autoscrape"
"github.com/prometheus/prometheus/model/labels"
)
// MetricsConfig is a set of common options shared by metrics integrations. It
// should be utilised by an integration's config by inlining the common
// options:
//
// type IntegrationConfig struct {
// Common common.MetricsConfig `yaml:",inline"`
// }
type MetricsConfig struct {
Autoscrape autoscrape.Config `yaml:"autoscrape,omitempty"`
InstanceKey *string `yaml:"instance,omitempty"`
ExtraLabels labels.Labels `yaml:"extra_labels,omitempty"`
}
// ApplyDefaults applies defaults to mc.
func (mc *MetricsConfig) ApplyDefaults(g autoscrape.Global) {
if mc.Autoscrape.Enable == nil {
val := g.Enable
mc.Autoscrape.Enable = &val
}
if mc.Autoscrape.MetricsInstance == "" {
mc.Autoscrape.MetricsInstance = g.MetricsInstance
}
if mc.Autoscrape.ScrapeInterval == 0 {
mc.Autoscrape.ScrapeInterval = g.ScrapeInterval
}
if mc.Autoscrape.ScrapeTimeout == 0 {
mc.Autoscrape.ScrapeTimeout = g.ScrapeTimeout
}
}