go.d sd config add "disabled" (#17171)
Ilya Mashchenko committed
Mar 15, 2024 at 13:05 UTC
03a0dde56b0a09c6fcecb5b99a334eca1d3534a6
5 files changed
+25
src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/config.go
+1
@@ -16,6 +16,7 @@ type Config struct {
16
Source string `yaml:"-"`
17
ConfigDefaults confgroup.Registry `yaml:"-"`
18
19
+ Disabled bool `yaml:"disabled"`
20
Name string `yaml:"name"`
21
Discover []DiscoveryConfig `yaml:"discover"`
22
Classify []ClassifyRuleConfig `yaml:"classify"`
src/go/collectors/go.d.plugin/agent/discovery/sd/sd.go
+5
@@ -112,6 +112,11 @@ func (d *ServiceDiscovery) addPipeline(ctx context.Context, conf confFile, in ch
112
return
113
}
114
115
+ if cfg.Disabled {
116
+ d.Infof("pipeline config is disabled '%s' (%s)", cfg.Name, cfg.Source)
117
+ return
118
+ }
119
+
120
cfg.Source = fmt.Sprintf("file=%s", conf.source)
121
cfg.ConfigDefaults = d.configDefaults
122
src/go/collectors/go.d.plugin/agent/discovery/sd/sd_test.go
+15
@@ -20,6 +20,12 @@ func TestServiceDiscovery_Run(t *testing.T) {
20
{name: "name", started: true, stopped: false},
21
},
22
},
23
+ "add disabled pipeline": {
24
+ configs: []confFile{
25
+ prepareDisabledConfigFile("source", "name"),
26
+ },
27
+ wantPipelines: nil,
28
+ },
29
"remove pipeline": {
30
configs: []confFile{
31
prepareConfigFile("source", "name"),
@@ -89,3 +95,12 @@ func prepareEmptyConfigFile(source string) confFile {
95
source: source,
96
}
97
}
98
+
99
+func prepareDisabledConfigFile(source, name string) confFile {
100
+ bs, _ := yaml.Marshal(pipeline.Config{Name: name, Disabled: true})
101
+
102
+ return confFile{
103
+ source: source,
104
+ content: bs,
105
+ }
106
+}
src/go/collectors/go.d.plugin/config/go.d/sd/docker.conf
+2
@@ -1,3 +1,5 @@
1
+disabled: no
2
+
3
name: 'docker'
4
5
discover:
src/go/collectors/go.d.plugin/config/go.d/sd/net_listeners.conf
+2
@@ -1,3 +1,5 @@
1
+disabled: no
2
+
3
name: 'network listeners'
4
5
discover: