@cryptotaxi247 / netdata-1 / commits / 4dbed7d6b

go.d dyncfg add userconfig action (#17684)

Ilya Mashchenko committed May 17, 2024 at 18:44 UTC 4dbed7d6b590174ac9433b7a621649fb9fb21544
104 files changed +567 -308
src/go/collectors/go.d.plugin/agent/jobmgr/dyncfg.go
+103 -9
@@ -7,6 +7,7 @@ import (
7 "encoding/json"
8 "fmt"
9 "log/slog"
10 + "reflect"
11 "strconv"
12 "strings"
13 "time"
@@ -59,10 +60,10 @@ func dyncfgJobID(cfg confgroup.Config) string {
60 }
61
62 func dyncfgModCmds() string {
62 - return "add schema enable disable test"
63 + return "add schema enable disable test userconfig"
64 }
65 func dyncfgJobCmds(cfg confgroup.Config) string {
65 - cmds := "schema get enable disable update restart test"
66 + cmds := "schema get enable disable update restart test userconfig"
67 if isDyncfg(cfg) {
68 cmds += " remove"
69 }
@@ -107,8 +108,14 @@ func (m *Manager) dyncfgConfig(fn functions.Function) {
108 default:
109 }
110
111 + //m.Infof("QQ FN: '%s'", fn)
112 +
113 action := strings.ToLower(fn.Args[1])
114 +
115 switch action {
116 + case "userconfig":
117 + m.dyncfgConfigUserconfig(fn)
118 + return
119 case "test":
120 m.dyncfgConfigTest(fn)
121 return
@@ -127,8 +134,6 @@ func (m *Manager) dyncfgConfig(fn functions.Function) {
134 func (m *Manager) dyncfgConfigExec(fn functions.Function) {
135 action := strings.ToLower(fn.Args[1])
136
130 - //m.Infof("QQ FN(%s): '%s'", action, fn)
131 -
137 switch action {
138 case "test":
139 m.dyncfgConfigTest(fn)
@@ -154,6 +159,43 @@ func (m *Manager) dyncfgConfigExec(fn functions.Function) {
159 }
160 }
161
162 +func (m *Manager) dyncfgConfigUserconfig(fn functions.Function) {
163 + id := fn.Args[0]
164 + jn := "test"
165 + if len(fn.Args) > 2 {
166 + jn = fn.Args[2]
167 + }
168 +
169 + mn, ok := extractModuleName(id)
170 + if !ok {
171 + m.Warningf("dyncfg: userconfig: could not extract module and job from id (%s)", id)
172 + m.dyncfgRespf(fn, 400,
173 + "Invalid ID format. Could not extract module and job name from ID. Provided ID: %s.", id)
174 + return
175 + }
176 +
177 + creator, ok := m.Modules.Lookup(mn)
178 + if !ok {
179 + m.Warningf("dyncfg: userconfig: module %s not found", mn)
180 + m.dyncfgRespf(fn, 404, "The specified module '%s' is not registered.", mn)
181 + return
182 + }
183 +
184 + if creator.Config == nil || creator.Config() == nil {
185 + m.Warningf("dyncfg: userconfig: module %s: configuration not found", mn)
186 + m.dyncfgRespf(fn, 500, "Module %s does not provide configuration.", mn)
187 + return
188 + }
189 +
190 + bs, err := userConfigFromPayload(creator.Config(), jn, fn)
191 + if err != nil {
192 + m.Warningf("dyncfg: userconfig: module %s: failed to create config from payload: %v", mn, err)
193 + m.dyncfgRespf(fn, 400, "Invalid configuration format. Failed to create configuration from payload: %v.", err)
194 + }
195 +
196 + m.dyncfgRespPayloadYAML(fn, string(bs))
197 +}
198 +
199 func (m *Manager) dyncfgConfigTest(fn functions.Function) {
200 id := fn.Args[0]
201 mn, ok := extractModuleName(id)
@@ -164,6 +206,11 @@ func (m *Manager) dyncfgConfigTest(fn functions.Function) {
206 return
207 }
208
209 + jn := "test"
210 + if len(fn.Args) > 2 {
211 + jn = fn.Args[2]
212 + }
213 +
214 creator, ok := m.Modules.Lookup(mn)
215 if !ok {
216 m.Warningf("dyncfg: test: module %s not found", mn)
@@ -187,7 +234,7 @@ func (m *Manager) dyncfgConfigTest(fn functions.Function) {
234 }
235
236 cfg.SetModule(mn)
190 - cfg.SetName("test")
237 + cfg.SetName(jn)
238
239 job := creator.Create()
240
@@ -238,7 +285,7 @@ func (m *Manager) dyncfgConfigSchema(fn functions.Function) {
285 return
286 }
287
241 - m.dyncfgRespPayload(fn, mod.JobConfigSchema)
288 + m.dyncfgRespPayloadJSON(fn, mod.JobConfigSchema)
289 }
290
291 func (m *Manager) dyncfgConfigGet(fn functions.Function) {
@@ -287,7 +334,7 @@ func (m *Manager) dyncfgConfigGet(fn functions.Function) {
334 return
335 }
336
290 - m.dyncfgRespPayload(fn, string(bs))
337 + m.dyncfgRespPayloadJSON(fn, string(bs))
338 }
339
340 func (m *Manager) dyncfgConfigRestart(fn functions.Function) {
@@ -665,9 +712,17 @@ func (m *Manager) dyncfgSetConfigMeta(cfg confgroup.Config, module, name string)
712 }
713 }
714
668 -func (m *Manager) dyncfgRespPayload(fn functions.Function, payload string) {
715 +func (m *Manager) dyncfgRespPayloadJSON(fn functions.Function, payload string) {
716 + m.dyncfgRespPayload(fn, payload, "application/json")
717 +}
718 +
719 +func (m *Manager) dyncfgRespPayloadYAML(fn functions.Function, payload string) {
720 + m.dyncfgRespPayload(fn, payload, " application/yaml")
721 +}
722 +
723 +func (m *Manager) dyncfgRespPayload(fn functions.Function, payload string, contentType string) {
724 ts := strconv.FormatInt(time.Now().Unix(), 10)
670 - m.api.FUNCRESULT(fn.UID, "application/json", payload, "200", ts)
725 + m.api.FUNCRESULT(fn.UID, contentType, payload, "200", ts)
726 }
727
728 func (m *Manager) dyncfgRespf(fn functions.Function, code int, msgf string, a ...any) {
@@ -685,6 +740,45 @@ func (m *Manager) dyncfgRespf(fn functions.Function, code int, msgf string, a ..
740 m.api.FUNCRESULT(fn.UID, "application/json", string(bs), strconv.Itoa(code), ts)
741 }
742
743 +func userConfigFromPayload(cfg any, jobName string, fn functions.Function) ([]byte, error) {
744 + if v := reflect.ValueOf(cfg); v.Kind() != reflect.Ptr || v.IsNil() {
745 + return nil, fmt.Errorf("invalid config: expected a pointer to a struct, got a %s", v.Type())
746 + }
747 +
748 + if fn.ContentType == "application/json" {
749 + if err := json.Unmarshal(fn.Payload, cfg); err != nil {
750 + return nil, err
751 + }
752 + } else {
753 + if err := yaml.Unmarshal(fn.Payload, cfg); err != nil {
754 + return nil, err
755 + }
756 + }
757 +
758 + bs, err := yaml.Marshal(cfg)
759 + if err != nil {
760 + return nil, err
761 + }
762 +
763 + var yms yaml.MapSlice
764 + if err := yaml.Unmarshal(bs, &yms); err != nil {
765 + return nil, err
766 + }
767 +
768 + yms = append([]yaml.MapItem{{Key: "name", Value: jobName}}, yms...)
769 +
770 + v := map[string]any{
771 + "jobs": []any{yms},
772 + }
773 +
774 + bs, err = yaml.Marshal(v)
775 + if err != nil {
776 + return nil, err
777 + }
778 +
779 + return bs, nil
780 +}
781 +
782 func configFromPayload(fn functions.Function) (confgroup.Config, error) {
783 var cfg confgroup.Config
784
src/go/collectors/go.d.plugin/agent/jobmgr/manager_test.go
+106 -42
@@ -34,7 +34,7 @@ func TestManager_Run(t *testing.T) {
34 wantExposed: nil,
35 wantRunning: nil,
36 wantDyncfg: `
37 -CONFIG go.d:collector:success:name create accepted job /collectors/jobs stock 'type=stock,module=success,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
37 +CONFIG go.d:collector:success:name create accepted job /collectors/jobs stock 'type=stock,module=success,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
38
39 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
40 {"status":200,"message":""}
@@ -66,7 +66,7 @@ CONFIG go.d:collector:success:name delete
66 wantExposed: nil,
67 wantRunning: nil,
68 wantDyncfg: `
69 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
69 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
70
71 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
72 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -96,7 +96,7 @@ CONFIG go.d:collector:fail:name delete
96 wantExposed: nil,
97 wantRunning: nil,
98 wantDyncfg: `
99 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
99 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
100
101 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
102 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -126,7 +126,7 @@ CONFIG go.d:collector:fail:name delete
126 wantExposed: nil,
127 wantRunning: nil,
128 wantDyncfg: `
129 -CONFIG go.d:collector:success:name create accepted job /collectors/jobs user 'type=user,module=success,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
129 +CONFIG go.d:collector:success:name create accepted job /collectors/jobs user 'type=user,module=success,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
130
131 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
132 {"status":200,"message":""}
@@ -158,7 +158,7 @@ CONFIG go.d:collector:success:name delete
158 wantExposed: nil,
159 wantRunning: nil,
160 wantDyncfg: `
161 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
161 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
162
163 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
164 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -190,7 +190,7 @@ CONFIG go.d:collector:fail:name delete
190 wantExposed: nil,
191 wantRunning: nil,
192 wantDyncfg: `
193 -CONFIG go.d:collector:success:name create accepted job /collectors/jobs discovered 'type=discovered,module=success,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
193 +CONFIG go.d:collector:success:name create accepted job /collectors/jobs discovered 'type=discovered,module=success,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
194
195 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
196 {"status":200,"message":""}
@@ -222,7 +222,7 @@ CONFIG go.d:collector:success:name delete
222 wantExposed: nil,
223 wantRunning: nil,
224 wantDyncfg: `
225 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
225 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
226
227 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
228 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -277,7 +277,7 @@ CONFIG go.d:collector:fail:name delete
277 },
278 wantRunning: nil,
279 wantDyncfg: `
280 -CONFIG go.d:collector:fail:stock create accepted job /collectors/jobs stock 'type=stock,module=fail,job=stock' 'schema get enable disable update restart test' 0x0000 0x0000
280 +CONFIG go.d:collector:fail:stock create accepted job /collectors/jobs stock 'type=stock,module=fail,job=stock' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
281
282 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
283 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -285,7 +285,7 @@ FUNCTION_RESULT_END
285
286 CONFIG go.d:collector:fail:stock delete
287
288 -CONFIG go.d:collector:fail:discovered create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=discovered' 'schema get enable disable update restart test' 0x0000 0x0000
288 +CONFIG go.d:collector:fail:discovered create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=discovered' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
289
290 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
291 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -293,7 +293,7 @@ FUNCTION_RESULT_END
293
294 CONFIG go.d:collector:fail:discovered status failed
295
296 -CONFIG go.d:collector:fail:user create accepted job /collectors/jobs user 'type=user,module=fail,job=user' 'schema get enable disable update restart test' 0x0000 0x0000
296 +CONFIG go.d:collector:fail:user create accepted job /collectors/jobs user 'type=user,module=fail,job=user' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
297
298 FUNCTION_RESULT_BEGIN 3-enable 200 application/json
299 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -345,7 +345,7 @@ CONFIG go.d:collector:fail:user status failed
345 },
346 wantRunning: nil,
347 wantDyncfg: `
348 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
348 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
349
350 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
351 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -353,7 +353,7 @@ FUNCTION_RESULT_END
353
354 CONFIG go.d:collector:fail:name delete
355
356 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
356 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
357
358 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
359 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -361,7 +361,7 @@ FUNCTION_RESULT_END
361
362 CONFIG go.d:collector:fail:name status failed
363
364 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
364 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
365
366 FUNCTION_RESULT_BEGIN 3-enable 200 application/json
367 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -407,7 +407,7 @@ CONFIG go.d:collector:fail:name status failed
407 wantExposed: nil,
408 wantRunning: nil,
409 wantDyncfg: `
410 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
410 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs stock 'type=stock,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
411
412 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
413 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -415,7 +415,7 @@ FUNCTION_RESULT_END
415
416 CONFIG go.d:collector:fail:name delete
417
418 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
418 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs discovered 'type=discovered,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
419
420 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
421 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -423,7 +423,7 @@ FUNCTION_RESULT_END
423
424 CONFIG go.d:collector:fail:name status failed
425
426 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
426 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
427
428 FUNCTION_RESULT_BEGIN 3-enable 200 application/json
429 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -468,7 +468,7 @@ CONFIG go.d:collector:fail:name delete
468 },
469 wantRunning: nil,
470 wantDyncfg: `
471 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
471 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
472
473 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
474 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -505,7 +505,7 @@ CONFIG go.d:collector:fail:name status failed
505 wantExposed: nil,
506 wantRunning: nil,
507 wantDyncfg: `
508 -CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test' 0x0000 0x0000
508 +CONFIG go.d:collector:fail:name create accepted job /collectors/jobs user 'type=user,module=fail,job=name' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
509
510 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
511 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -589,7 +589,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
589 {"status":202,"message":""}
590 FUNCTION_RESULT_END
591
592 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
592 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
593
594 FUNCTION_RESULT_BEGIN 2-get 200 application/json
595 {"option_str":"1","option_int":1}
@@ -608,6 +608,70 @@ FUNCTION_RESULT_END
608 }
609 }
610
611 +func TestManager_Run_Dyncfg_Userconfig(t *testing.T) {
612 + tests := map[string]struct {
613 + createSim func() *runSim
614 + }{
615 + "[userconfig] existing": {
616 + createSim: func() *runSim {
617 + cfg := prepareDyncfgCfg("success", "test")
618 +
619 + return &runSim{
620 + do: func(mgr *Manager, _ chan []*confgroup.Group) {
621 + mgr.dyncfgConfig(functions.Function{
622 + UID: "1-userconfig",
623 + Args: []string{dyncfgJobID(cfg), "userconfig"},
624 + })
625 + },
626 + wantDiscovered: nil,
627 + wantSeen: nil,
628 + wantExposed: nil,
629 + wantRunning: nil,
630 + wantDyncfg: `
631 +FUNCTION_RESULT_BEGIN 1-userconfig 200 application/yaml
632 +jobs:
633 +- name: test
634 + option_one: one
635 + option_two: 2
636 +
637 +FUNCTION_RESULT_END
638 +`,
639 + }
640 + },
641 + },
642 + "[userconfig] non-existing": {
643 + createSim: func() *runSim {
644 + cfg := prepareDyncfgCfg("success!", "test")
645 +
646 + return &runSim{
647 + do: func(mgr *Manager, _ chan []*confgroup.Group) {
648 + mgr.dyncfgConfig(functions.Function{
649 + UID: "1-userconfig",
650 + Args: []string{dyncfgJobID(cfg), "userconfig"},
651 + })
652 + },
653 + wantDiscovered: nil,
654 + wantSeen: nil,
655 + wantExposed: nil,
656 + wantRunning: nil,
657 + wantDyncfg: `
658 +FUNCTION_RESULT_BEGIN 1-userconfig 404 application/json
659 +{"status":404,"message":"The specified module 'success!' is not registered."}
660 +FUNCTION_RESULT_END
661 +`,
662 + }
663 + },
664 + },
665 + }
666 +
667 + for name, test := range tests {
668 + t.Run(name, func(t *testing.T) {
669 + sim := test.createSim()
670 + sim.run(t)
671 + })
672 + }
673 +}
674 +
675 func TestManager_Run_Dyncfg_Add(t *testing.T) {
676 tests := map[string]struct {
677 createSim func() *runSim
@@ -638,7 +702,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
702 {"status":202,"message":""}
703 FUNCTION_RESULT_END
704
641 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
705 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
706 `,
707 }
708 },
@@ -669,7 +733,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
733 {"status":202,"message":""}
734 FUNCTION_RESULT_END
735
672 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
736 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
737 `,
738 }
739 },
@@ -705,13 +769,13 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
769 {"status":202,"message":""}
770 FUNCTION_RESULT_END
771
708 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
772 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
773
774 FUNCTION_RESULT_BEGIN 2-add 202 application/json
775 {"status":202,"message":""}
776 FUNCTION_RESULT_END
777
714 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
778 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
779 `,
780 }
781 },
@@ -784,7 +848,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
848 {"status":202,"message":""}
849 FUNCTION_RESULT_END
850
787 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
851 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
852
853 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
854 {"status":200,"message":""}
@@ -829,7 +893,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
893 {"status":202,"message":""}
894 FUNCTION_RESULT_END
895
832 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
896 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
897
898 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
899 {"status":200,"message":""}
@@ -876,7 +940,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
940 {"status":202,"message":""}
941 FUNCTION_RESULT_END
942
879 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
943 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
944
945 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
946 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -921,7 +985,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
985 {"status":202,"message":""}
986 FUNCTION_RESULT_END
987
924 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
988 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
989
990 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
991 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -1006,7 +1070,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1070 {"status":202,"message":""}
1071 FUNCTION_RESULT_END
1072
1009 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1073 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1074
1075 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1076 {"status":200,"message":""}
@@ -1051,7 +1115,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1115 {"status":202,"message":""}
1116 FUNCTION_RESULT_END
1117
1054 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1118 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1119
1120 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1121 {"status":200,"message":""}
@@ -1098,7 +1162,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1162 {"status":202,"message":""}
1163 FUNCTION_RESULT_END
1164
1101 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1165 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1166
1167 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1168 {"status":200,"message":""}
@@ -1143,7 +1207,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1207 {"status":202,"message":""}
1208 FUNCTION_RESULT_END
1209
1146 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1210 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1211
1212 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1213 {"status":200,"message":""}
@@ -1228,7 +1292,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1292 {"status":202,"message":""}
1293 FUNCTION_RESULT_END
1294
1231 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1295 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1296
1297 FUNCTION_RESULT_BEGIN 2-restart 405 application/json
1298 {"status":405,"message":"Restarting data collection job is not allowed in 'accepted' state."}
@@ -1273,7 +1337,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1337 {"status":202,"message":""}
1338 FUNCTION_RESULT_END
1339
1276 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1340 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1341
1342 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1343 {"status":200,"message":""}
@@ -1324,7 +1388,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1388 {"status":202,"message":""}
1389 FUNCTION_RESULT_END
1390
1327 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1391 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1392
1393 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1394 {"status":200,"message":""}
@@ -1379,7 +1443,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1443 {"status":202,"message":""}
1444 FUNCTION_RESULT_END
1445
1382 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1446 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1447
1448 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1449 {"status":200,"message":""}
@@ -1496,7 +1560,7 @@ FUNCTION_RESULT_END
1560 },
1561 wantRunning: []string{stockCfg.FullName(), userCfg.FullName(), discCfg.FullName()},
1562 wantDyncfg: `
1499 -CONFIG go.d:collector:success:stock create accepted job /collectors/jobs stock 'type=stock,module=success,job=stock' 'schema get enable disable update restart test' 0x0000 0x0000
1563 +CONFIG go.d:collector:success:stock create accepted job /collectors/jobs stock 'type=stock,module=success,job=stock' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
1564
1565 FUNCTION_RESULT_BEGIN 1-enable 200 application/json
1566 {"status":200,"message":""}
@@ -1504,7 +1568,7 @@ FUNCTION_RESULT_END
1568
1569 CONFIG go.d:collector:success:stock status running
1570
1507 -CONFIG go.d:collector:success:user create accepted job /collectors/jobs user 'type=user,module=success,job=user' 'schema get enable disable update restart test' 0x0000 0x0000
1571 +CONFIG go.d:collector:success:user create accepted job /collectors/jobs user 'type=user,module=success,job=user' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
1572
1573 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1574 {"status":200,"message":""}
@@ -1512,7 +1576,7 @@ FUNCTION_RESULT_END
1576
1577 CONFIG go.d:collector:success:user status running
1578
1515 -CONFIG go.d:collector:success:discovered create accepted job /collectors/jobs discovered 'type=discovered,module=success,job=discovered' 'schema get enable disable update restart test' 0x0000 0x0000
1579 +CONFIG go.d:collector:success:discovered create accepted job /collectors/jobs discovered 'type=discovered,module=success,job=discovered' 'schema get enable disable update restart test userconfig' 0x0000 0x0000
1580
1581 FUNCTION_RESULT_BEGIN 3-enable 200 application/json
1582 {"status":200,"message":""}
@@ -1561,7 +1625,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1625 {"status":202,"message":""}
1626 FUNCTION_RESULT_END
1627
1564 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1628 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1629
1630 FUNCTION_RESULT_BEGIN 2-remove 200 application/json
1631 {"status":200,"message":""}
@@ -1602,7 +1666,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1666 {"status":202,"message":""}
1667 FUNCTION_RESULT_END
1668
1605 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1669 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1670
1671 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1672 {"status":200,"message":""}
@@ -1698,7 +1762,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1762 {"status":202,"message":""}
1763 FUNCTION_RESULT_END
1764
1701 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1765 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1766
1767 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1768 {"status":200,"message":""}
@@ -1755,7 +1819,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1819 {"status":202,"message":""}
1820 FUNCTION_RESULT_END
1821
1758 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test remove' 0x0000 0x0000
1822 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1823
1824 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1825 {"status":200,"message":""}
src/go/collectors/go.d.plugin/agent/jobmgr/sim_test.go
+7
@@ -121,6 +121,10 @@ func (s *runSim) run(t *testing.T) {
121
122 func prepareMockRegistry() module.Registry {
123 reg := module.Registry{}
124 + type config struct {
125 + OptionOne string `yaml:"option_one" json:"option_one"`
126 + OptionTwo int64 `yaml:"option_two" json:"option_two"`
127 + }
128
129 reg.Register("success", module.Creator{
130 JobConfigSchema: module.MockConfigSchema,
@@ -132,6 +136,9 @@ func prepareMockRegistry() module.Registry {
136 CollectFunc: func() map[string]int64 { return map[string]int64{"id1": 1} },
137 }
138 },
139 + Config: func() any {
140 + return &config{OptionOne: "one", OptionTwo: 2}
141 + },
142 })
143 reg.Register("fail", module.Creator{
144 Create: func() module.Module {
src/go/collectors/go.d.plugin/agent/module/registry.go
+1
@@ -24,6 +24,7 @@ type (
24 Defaults
25 Create func() Module
26 JobConfigSchema string
27 + Config func() any
28 }
29 // Registry is a collection of Creators.
30 Registry map[string]Creator
src/go/collectors/go.d.plugin/modules/activemq/activemq.go
+5 -4
@@ -19,6 +19,7 @@ func init() {
19 module.Register("activemq", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -44,13 +45,13 @@ func New() *ActiveMQ {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 - Webadmin string `yaml:"webadmin" json:"webadmin"`
50 + Webadmin string `yaml:"webadmin,omitempty" json:"webadmin"`
51 MaxQueues int `yaml:"max_queues" json:"max_queues"`
52 MaxTopics int `yaml:"max_topics" json:"max_topics"`
52 - QueuesFilter string `yaml:"queues_filter" json:"queues_filter"`
53 - TopicsFilter string `yaml:"topics_filter" json:"topics_filter"`
53 + QueuesFilter string `yaml:"queues_filter,omitempty" json:"queues_filter"`
54 + TopicsFilter string `yaml:"topics_filter,omitempty" json:"topics_filter"`
55 }
56
57 type ActiveMQ struct {
src/go/collectors/go.d.plugin/modules/adaptecraid/adaptec.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -36,8 +37,8 @@ func New() *AdaptecRaid {
37 }
38
39 type Config struct {
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 }
43
44 type (
src/go/collectors/go.d.plugin/modules/apache/apache.go
+2 -1
@@ -20,6 +20,7 @@ func init() {
20 module.Register("apache", module.Creator{
21 Create: func() module.Module { return New() },
22 JobConfigSchema: configSchema,
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -41,8 +42,8 @@ func New() *Apache {
42 }
43
44 type Config struct {
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 web.HTTP `yaml:",inline" json:""`
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 }
48
49 type Apache struct {
src/go/collectors/go.d.plugin/modules/bind/bind.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 module.Register("bind", module.Creator{
22 JobConfigSchema: configSchema,
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -41,9 +42,9 @@ func New() *Bind {
42 }
43
44 type Config struct {
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 web.HTTP `yaml:",inline" json:""`
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 - PermitView string `yaml:"permit_view" json:"permit_view"`
47 + PermitView string `yaml:"permit_view,omitempty" json:"permit_view"`
48 }
49
50 type (
src/go/collectors/go.d.plugin/modules/cassandra/cassandra.go
+2 -1
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 5,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -44,8 +45,8 @@ func New() *Cassandra {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
50 }
51
52 type Cassandra struct {
src/go/collectors/go.d.plugin/modules/chrony/chrony.go
+3 -2
@@ -19,6 +19,7 @@ func init() {
19 module.Register("chrony", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -34,9 +35,9 @@ func New() *Chrony {
35 }
36
37 type Config struct {
37 - UpdateEvery int `yaml:"update_every" json:"update_every"`
38 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
39 Address string `yaml:"address" json:"address"`
39 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
40 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
41 }
42
43 type (
src/go/collectors/go.d.plugin/modules/cockroachdb/cockroachdb.go
+2 -1
@@ -26,6 +26,7 @@ func init() {
26 UpdateEvery: dbSamplingInterval,
27 },
28 Create: func() module.Module { return New() },
29 + Config: func() any { return &Config{} },
30 })
31 }
32
@@ -46,8 +47,8 @@ func New() *CockroachDB {
47 }
48
49 type Config struct {
50 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
51 web.HTTP `yaml:",inline" json:""`
50 - UpdateEvery int `yaml:"update_every" json:"update_every"`
52 }
53
54 type CockroachDB struct {
src/go/collectors/go.d.plugin/modules/consul/consul.go
+3 -2
@@ -26,6 +26,7 @@ func init() {
26 UpdateEvery: 1,
27 },
28 Create: func() module.Module { return New() },
29 + Config: func() any { return &Config{} },
30 })
31 }
32
@@ -49,9 +50,9 @@ func New() *Consul {
50 }
51
52 type Config struct {
53 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
54 web.HTTP `yaml:",inline" json:""`
53 - UpdateEvery int `yaml:"update_every" json:"update_every"`
54 - ACLToken string `yaml:"acl_token" json:"acl_token"`
55 + ACLToken string `yaml:"acl_token,omitempty" json:"acl_token"`
56 }
57
58 type Consul struct {
src/go/collectors/go.d.plugin/modules/coredns/coredns.go
+4 -3
@@ -22,6 +22,7 @@ func init() {
22 module.Register("coredns", module.Creator{
23 JobConfigSchema: configSchema,
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -44,10 +45,10 @@ func New() *CoreDNS {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 - PerServerStats matcher.SimpleExpr `yaml:"per_server_stats" json:"per_server_stats"`
50 - PerZoneStats matcher.SimpleExpr `yaml:"per_zone_stats" json:"per_zone_stats"`
50 + PerServerStats matcher.SimpleExpr `yaml:"per_server_stats,omitempty" json:"per_server_stats"`
51 + PerZoneStats matcher.SimpleExpr `yaml:"per_zone_stats,omitempty" json:"per_zone_stats"`
52 }
53
54 type CoreDNS struct {
src/go/collectors/go.d.plugin/modules/couchbase/couchbase.go
+2 -1
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 5,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -42,8 +43,8 @@ func New() *Couchbase {
43 }
44
45 type Config struct {
46 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
47 web.HTTP `yaml:",inline" json:""`
46 - UpdateEvery int `yaml:"update_every" json:"update_every"`
48 }
49
50 type Couchbase struct {
src/go/collectors/go.d.plugin/modules/couchdb/couchdb.go
+4 -3
@@ -23,6 +23,7 @@ func init() {
23 UpdateEvery: 10,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -43,10 +44,10 @@ func New() *CouchDB {
44 }
45
46 type Config struct {
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 web.HTTP `yaml:",inline" json:""`
47 - UpdateEvery int `yaml:"update_every" json:"update_every"`
48 - Node string `yaml:"node" json:"node"`
49 - Databases string `yaml:"databases" json:"databases"`
49 + Node string `yaml:"node,omitempty" json:"node"`
50 + Databases string `yaml:"databases,omitempty" json:"databases"`
51 }
52
53 type CouchDB struct {
src/go/collectors/go.d.plugin/modules/dnsdist/dnsdist.go
+2 -1
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 1,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -41,8 +42,8 @@ func New() *DNSdist {
42 }
43
44 type Config struct {
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 web.HTTP `yaml:",inline" json:""`
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 }
48
49 type DNSdist struct {
src/go/collectors/go.d.plugin/modules/dnsmasq/dnsmasq.go
+4 -3
@@ -20,6 +20,7 @@ func init() {
20 module.Register("dnsmasq", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -41,10 +42,10 @@ func New() *Dnsmasq {
42 }
43
44 type Config struct {
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
45 - Protocol string `yaml:"protocol" json:"protocol"`
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 Address string `yaml:"address" json:"address"`
47 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
47 + Protocol string `yaml:"protocol,omitempty" json:"protocol"`
48 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
49 }
50
51 type (
src/go/collectors/go.d.plugin/modules/dnsmasq_dhcp/dhcp.go
+4 -3
@@ -19,6 +19,7 @@ func init() {
19 module.Register("dnsmasq_dhcp", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -38,10 +39,10 @@ func New() *DnsmasqDHCP {
39 }
40
41 type Config struct {
41 - UpdateEvery int `yaml:"update_every" json:"update_every"`
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 LeasesPath string `yaml:"leases_path" json:"leases_path"`
43 - ConfPath string `yaml:"conf_path" json:"conf_path"`
44 - ConfDir string `yaml:"conf_dir" json:"conf_dir"`
44 + ConfPath string `yaml:"conf_path,omitempty" json:"conf_path"`
45 + ConfDir string `yaml:"conf_dir,omitempty" json:"conf_dir"`
46 }
47
48 type DnsmasqDHCP struct {
src/go/collectors/go.d.plugin/modules/dnsquery/dnsquery.go
+7 -6
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 5,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -43,14 +44,14 @@ func New() *DNSQuery {
44 }
45
46 type Config struct {
46 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
49 Domains []string `yaml:"domains" json:"domains"`
50 Servers []string `yaml:"servers" json:"servers"`
50 - Network string `yaml:"network" json:"network"`
51 - RecordType string `yaml:"record_type" json:"record_type"`
52 - RecordTypes []string `yaml:"record_types" json:"record_types"`
53 - Port int `yaml:"port" json:"port"`
51 + Network string `yaml:"network,omitempty" json:"network"`
52 + RecordType string `yaml:"record_type,omitempty" json:"record_type"`
53 + RecordTypes []string `yaml:"record_types,omitempty" json:"record_types"`
54 + Port int `yaml:"port,omitempty" json:"port"`
55 }
56
57 type (
src/go/collectors/go.d.plugin/modules/docker/docker.go
+3 -2
@@ -25,6 +25,7 @@ func init() {
25 module.Register("docker", module.Creator{
26 JobConfigSchema: configSchema,
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -45,9 +46,9 @@ func New() *Docker {
46 }
47
48 type Config struct {
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
50 Address string `yaml:"address" json:"address"`
50 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
51 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
52 CollectContainerSize bool `yaml:"collect_container_size" json:"collect_container_size"`
53 }
54
src/go/collectors/go.d.plugin/modules/docker_engine/docker_engine.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("docker_engine", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -38,8 +39,8 @@ func New() *DockerEngine {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type DockerEngine struct {
src/go/collectors/go.d.plugin/modules/dockerhub/dockerhub.go
+2 -1
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 5,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -40,8 +41,8 @@ func New() *DockerHub {
41 }
42
43 type Config struct {
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 web.HTTP `yaml:",inline" json:""`
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 Repositories []string `yaml:"repositories" json:"repositories"`
47 }
48
src/go/collectors/go.d.plugin/modules/elasticsearch/elasticsearch.go
+2 -1
@@ -23,6 +23,7 @@ func init() {
23 UpdateEvery: 5,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -54,8 +55,8 @@ func New() *Elasticsearch {
55 }
56
57 type Config struct {
58 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
59 web.HTTP `yaml:",inline" json:""`
58 - UpdateEvery int `yaml:"update_every" json:"update_every"`
60 ClusterMode bool `yaml:"cluster_mode" json:"cluster_mode"`
61 DoNodeStats bool `yaml:"collect_node_stats" json:"collect_node_stats"`
62 DoClusterHealth bool `yaml:"collect_cluster_health" json:"collect_cluster_health"`
src/go/collectors/go.d.plugin/modules/envoy/envoy.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("envoy", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -47,8 +48,8 @@ func New() *Envoy {
48 }
49
50 type Config struct {
51 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
52 web.HTTP `yaml:",inline" json:""`
51 - UpdateEvery int `yaml:"update_every" json:"update_every"`
53 }
54
55 type Envoy struct {
src/go/collectors/go.d.plugin/modules/example/example.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 Disabled: true,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -44,12 +45,12 @@ func New() *Example {
45
46 type (
47 Config struct {
47 - UpdateEvery int `yaml:"update_every" json:"update_every"`
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 Charts ConfigCharts `yaml:"charts" json:"charts"`
50 HiddenCharts ConfigCharts `yaml:"hidden_charts" json:"hidden_charts"`
51 }
52 ConfigCharts struct {
52 - Type string `yaml:"type" json:"type"`
53 + Type string `yaml:"type,omitempty" json:"type"`
54 Num int `yaml:"num" json:"num"`
55 Contexts int `yaml:"contexts" json:"contexts"`
56 Dims int `yaml:"dimensions" json:"dimensions"`
src/go/collectors/go.d.plugin/modules/fail2ban/fail2ban.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -36,8 +37,8 @@ func New() *Fail2Ban {
37 }
38
39 type Config struct {
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 }
43
44 type (
src/go/collectors/go.d.plugin/modules/filecheck/filecheck.go
+5 -4
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -39,18 +40,18 @@ func New() *Filecheck {
40
41 type (
42 Config struct {
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
43 - DiscoveryEvery web.Duration `yaml:"discovery_every" json:"discovery_every"`
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 + DiscoveryEvery web.Duration `yaml:"discovery_every,omitempty" json:"discovery_every"`
45 Files filesConfig `yaml:"files" json:"files"`
46 Dirs dirsConfig `yaml:"dirs" json:"dirs"`
47 }
48 filesConfig struct {
49 Include []string `yaml:"include" json:"include"`
49 - Exclude []string `yaml:"exclude" json:"exclude"`
50 + Exclude []string `yaml:"exclude,omitempty" json:"exclude"`
51 }
52 dirsConfig struct {
53 Include []string `yaml:"include" json:"include"`
53 - Exclude []string `yaml:"exclude" json:"exclude"`
54 + Exclude []string `yaml:"exclude,omitempty" json:"exclude"`
55 CollectDirSize bool `yaml:"collect_dir_size" json:"collect_dir_size"`
56 }
57 )
src/go/collectors/go.d.plugin/modules/fluentd/fluentd.go
+3 -2
@@ -19,6 +19,7 @@ func init() {
19 module.Register("fluentd", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -39,9 +40,9 @@ func New() *Fluentd {
40 }
41
42 type Config struct {
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 web.HTTP `yaml:",inline" json:""`
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 - PermitPlugin string `yaml:"permit_plugin_id" json:"permit_plugin_id"`
45 + PermitPlugin string `yaml:"permit_plugin_id,omitempty" json:"permit_plugin_id"`
46 }
47
48 type Fluentd struct {
src/go/collectors/go.d.plugin/modules/freeradius/freeradius.go
+1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("freeradius", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
src/go/collectors/go.d.plugin/modules/geth/geth.go
+1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("geth", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
src/go/collectors/go.d.plugin/modules/haproxy/haproxy.go
+1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("haproxy", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
src/go/collectors/go.d.plugin/modules/hddtemp/hddtemp.go
+1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("hddtemp", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
src/go/collectors/go.d.plugin/modules/hdfs/hdfs.go
+1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("hdfs", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
src/go/collectors/go.d.plugin/modules/hpssa/hpssa.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -38,8 +39,8 @@ func New() *Hpssa {
39 }
40
41 type Config struct {
41 - UpdateEvery int `yaml:"update_every" json:"update_every"`
42 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
44 }
45
46 type (
src/go/collectors/go.d.plugin/modules/httpcheck/httpcheck.go
+5 -4
@@ -23,6 +23,7 @@ func init() {
23 UpdateEvery: 5,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -43,12 +44,12 @@ func New() *HTTPCheck {
44
45 type (
46 Config struct {
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 web.HTTP `yaml:",inline" json:""`
47 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 AcceptedStatuses []int `yaml:"status_accepted" json:"status_accepted"`
49 - ResponseMatch string `yaml:"response_match" json:"response_match"`
50 - CookieFile string `yaml:"cookie_file" json:"cookie_file"`
51 - HeaderMatch []headerMatchConfig `yaml:"header_match" json:"header_match"`
50 + ResponseMatch string `yaml:"response_match,omitempty" json:"response_match"`
51 + CookieFile string `yaml:"cookie_file,omitempty" json:"cookie_file"`
52 + HeaderMatch []headerMatchConfig `yaml:"header_match,omitempty" json:"header_match"`
53 }
54 headerMatchConfig struct {
55 Exclude bool `yaml:"exclude" json:"exclude"`
src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go
+3 -2
@@ -14,8 +14,9 @@ var configSchema string
14
15 func init() {
16 module.Register("intelgpu", module.Creator{
17 - Create: func() module.Module { return New() },
17 JobConfigSchema: configSchema,
18 + Create: func() module.Module { return New() },
19 + Config: func() any { return &Config{} },
20 })
21 }
22
@@ -28,7 +29,7 @@ func New() *IntelGPU {
29 }
30
31 type Config struct {
31 - UpdateEvery int `yaml:"update_every" json:"update_every"`
32 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
33 }
34
35 type (
src/go/collectors/go.d.plugin/modules/isc_dhcpd/isc_dhcpd.go
+2 -1
@@ -20,6 +20,7 @@ func init() {
20 UpdateEvery: 1,
21 },
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -35,7 +36,7 @@ func New() *DHCPd {
36
37 type (
38 Config struct {
38 - UpdateEvery int `yaml:"update_every" json:"update_every"`
39 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
40 LeasesPath string `yaml:"leases_path" json:"leases_path"`
41 // TODO: parse config file to extract configured pool
42 Pools []PoolConfig `yaml:"pools" json:"pools"`
src/go/collectors/go.d.plugin/modules/k8s_kubelet/kubelet.go
+3 -2
@@ -23,6 +23,7 @@ func init() {
23 Priority: 50000,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -47,9 +48,9 @@ func New() *Kubelet {
48 }
49
50 type Config struct {
51 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
52 web.HTTP `yaml:",inline" json:""`
51 - UpdateEvery int `yaml:"update_every" json:"update_every"`
52 - TokenPath string `yaml:"token_path" json:"token_path"`
53 + TokenPath string `yaml:"token_path,omitempty" json:"token_path"`
54 }
55
56 type Kubelet struct {
src/go/collectors/go.d.plugin/modules/k8s_kubeproxy/kubeproxy.go
+2 -1
@@ -23,6 +23,7 @@ func init() {
23 Priority: 50000,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -43,8 +44,8 @@ func New() *KubeProxy {
44 }
45
46 type Config struct {
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 web.HTTP `yaml:",inline" json:""`
47 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 }
50
51 type KubeProxy struct {
src/go/collectors/go.d.plugin/modules/k8s_state/kube_state.go
+2 -1
@@ -25,6 +25,7 @@ func init() {
25 Disabled: true,
26 },
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -40,7 +41,7 @@ func New() *KubeState {
41 }
42
43 type Config struct {
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 }
46
47 type (
src/go/collectors/go.d.plugin/modules/lighttpd/lighttpd.go
+2 -1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("lighttpd", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -35,8 +36,8 @@ func New() *Lighttpd {
36 }
37
38 type Config struct {
39 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
40 web.HTTP `yaml:",inline" json:""`
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
41 }
42
43 type Lighttpd struct {
src/go/collectors/go.d.plugin/modules/litespeed/litespeed.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 UpdateEvery: 10, // The .rtreport files are generated per worker, and updated every 10 seconds.
20 },
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -34,7 +35,7 @@ func New() *Litespeed {
35 }
36
37 type Config struct {
37 - UpdateEvery int `yaml:"update_every" json:"update_every"`
38 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
39 ReportsDir string `yaml:"reports_dir" json:"reports_dir"`
40 }
41
src/go/collectors/go.d.plugin/modules/logind/logind.go
+3 -2
@@ -24,6 +24,7 @@ func init() {
24 Priority: 59999, // copied from the python collector
25 },
26 Create: func() module.Module { return New() },
27 + Config: func() any { return &Config{} },
28 })
29 }
30
@@ -40,8 +41,8 @@ func New() *Logind {
41 }
42
43 type Config struct {
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
46 }
47
48 type Logind struct {
src/go/collectors/go.d.plugin/modules/logstash/logstash.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("logstash", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -40,8 +41,8 @@ func New() *Logstash {
41 }
42
43 type Config struct {
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 web.HTTP `yaml:",inline" json:""`
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 }
47
48 type Logstash struct {
src/go/collectors/go.d.plugin/modules/lvm/lvm.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -35,8 +36,8 @@ func New() *LVM {
36 }
37
38 type Config struct {
38 - UpdateEvery int `yaml:"update_every" json:"update_every"`
39 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
39 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
40 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
41 }
42
43 type (
src/go/collectors/go.d.plugin/modules/megacli/megacli.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -37,8 +38,8 @@ func New() *MegaCli {
38 }
39
40 type Config struct {
40 - UpdateEvery int `yaml:"update_every" json:"update_every"`
41 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
41 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
42 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
43 }
44
45 type (
src/go/collectors/go.d.plugin/modules/mongodb/mongodb.go
+5 -3
@@ -20,6 +20,7 @@ func init() {
20 module.Register("mongodb", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -47,9 +48,10 @@ func New() *Mongo {
48 }
49
50 type Config struct {
50 - URI string `yaml:"uri" json:"uri"`
51 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
52 - Databases matcher.SimpleExpr `yaml:"databases" json:"databases"`
51 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
52 + URI string `yaml:"uri" json:"uri"`
53 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
54 + Databases matcher.SimpleExpr `yaml:"databases,omitempty" json:"databases"`
55 }
56
57 type Mongo struct {
src/go/collectors/go.d.plugin/modules/mongodb/testdata/config.json
+1
@@ -1,4 +1,5 @@
1 {
2 + "update_every": 1,
3 "uri": "ok",
4 "timeout": 123.123,
5 "databases": {
src/go/collectors/go.d.plugin/modules/mongodb/testdata/config.yaml
+1
@@ -1,3 +1,4 @@
1 +update_every: 1
2 uri: "ok"
3 timeout: 123.123
4 databases:
src/go/collectors/go.d.plugin/modules/mysql/mysql.go
+4 -3
@@ -25,6 +25,7 @@ func init() {
25 module.Register("mysql", module.Creator{
26 JobConfigSchema: configSchema,
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -54,10 +55,10 @@ func New() *MySQL {
55 }
56
57 type Config struct {
57 - UpdateEvery int `yaml:"update_every" json:"update_every"`
58 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
59 DSN string `yaml:"dsn" json:"dsn"`
59 - MyCNF string `yaml:"my.cnf" json:"my.cnf"`
60 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
60 + MyCNF string `yaml:"my.cnf,omitempty" json:"my.cnf"`
61 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
62 }
63
64 type MySQL struct {
src/go/collectors/go.d.plugin/modules/nginx/nginx.go
+2 -1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("nginx", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -36,8 +37,8 @@ func New() *Nginx {
37 }
38
39 type Config struct {
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 web.HTTP `yaml:",inline" json:""`
40 - UpdateEvery int `yaml:"update_every" json:"update_every"`
42 }
43
44 type Nginx struct {
src/go/collectors/go.d.plugin/modules/nginxplus/nginxplus.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("nginxplus", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -41,8 +42,8 @@ func New() *NginxPlus {
42 }
43
44 type Config struct {
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 web.HTTP `yaml:",inline" json:""`
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 }
48
49 type NginxPlus struct {
src/go/collectors/go.d.plugin/modules/nginxvts/nginxvts.go
+2 -1
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 1,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -41,8 +42,8 @@ func New() *NginxVTS {
42 }
43
44 type Config struct {
45 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
46 web.HTTP `yaml:",inline" json:""`
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 }
48
49 type NginxVTS struct {
src/go/collectors/go.d.plugin/modules/ntpd/ntpd.go
+3 -2
@@ -20,6 +20,7 @@ func init() {
20 module.Register("ntpd", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -38,9 +39,9 @@ func New() *NTPd {
39 }
40
41 type Config struct {
41 - UpdateEvery int `yaml:"update_every" json:"update_every"`
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 Address string `yaml:"address" json:"address"`
43 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
44 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
45 CollectPeers bool `yaml:"collect_peers" json:"collect_peers"`
46 }
47
src/go/collectors/go.d.plugin/modules/nvidia_smi/nvidia_smi.go
+3 -2
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 10,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -40,8 +41,8 @@ func New() *NvidiaSMI {
41 }
42
43 type Config struct {
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
46 BinaryPath string `yaml:"binary_path" json:"binary_path"`
47 UseCSVFormat bool `yaml:"use_csv_format" json:"use_csv_format"`
48 }
src/go/collectors/go.d.plugin/modules/nvme/nvme.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -38,8 +39,8 @@ func New() *NVMe {
39 }
40
41 type Config struct {
41 - UpdateEvery int `yaml:"update_every" json:"update_every"`
42 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
44 }
45
46 type (
src/go/collectors/go.d.plugin/modules/openvpn/openvpn.go
+4 -3
@@ -20,6 +20,7 @@ func init() {
20 module.Register("openvpn", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -36,10 +37,10 @@ func New() *OpenVPN {
37 }
38
39 type Config struct {
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 Address string `yaml:"address" json:"address"`
41 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
42 - PerUserStats matcher.SimpleExpr `yaml:"per_user_stats" json:"per_user_stats"`
42 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
43 + PerUserStats matcher.SimpleExpr `yaml:"per_user_stats,omitempty" json:"per_user_stats"`
44 }
45
46 type (
src/go/collectors/go.d.plugin/modules/openvpn_status_log/openvpn.go
+3 -2
@@ -17,6 +17,7 @@ func init() {
17 module.Register("openvpn_status_log", module.Creator{
18 JobConfigSchema: configSchema,
19 Create: func() module.Module { return New() },
20 + Config: func() any { return &Config{} },
21 })
22 }
23
@@ -31,9 +32,9 @@ func New() *OpenVPNStatusLog {
32 }
33
34 type Config struct {
34 - UpdateEvery int `yaml:"update_every" json:"update_every"`
35 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
36 LogPath string `yaml:"log_path" json:"log_path"`
36 - PerUserStats matcher.SimpleExpr `yaml:"per_user_stats" json:"per_user_stats"`
37 + PerUserStats matcher.SimpleExpr `yaml:"per_user_stats,omitempty" json:"per_user_stats"`
38 }
39
40 type OpenVPNStatusLog struct {
src/go/collectors/go.d.plugin/modules/pgbouncer/pgbouncer.go
+3 -2
@@ -22,6 +22,7 @@ func init() {
22 module.Register("pgbouncer", module.Creator{
23 JobConfigSchema: configSchema,
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -40,9 +41,9 @@ func New() *PgBouncer {
41 }
42
43 type Config struct {
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 DSN string `yaml:"dsn" json:"dsn"`
45 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
46 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
47 }
48
49 type PgBouncer struct {
src/go/collectors/go.d.plugin/modules/phpdaemon/phpdaemon.go
+2 -1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("phpdaemon", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -38,8 +39,8 @@ func New() *PHPDaemon {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type PHPDaemon struct {
src/go/collectors/go.d.plugin/modules/phpfpm/phpfpm.go
+2 -1
@@ -20,6 +20,7 @@ func init() {
20 module.Register("phpfpm", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -40,8 +41,8 @@ func New() *Phpfpm {
41 }
42
43 type Config struct {
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 web.HTTP `yaml:",inline" json:""`
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 Socket string `yaml:"socket" json:"socket"`
47 Address string `yaml:"address" json:"address"`
48 FcgiPath string `yaml:"fcgi_path" json:"fcgi_path"`
src/go/collectors/go.d.plugin/modules/pihole/pihole.go
+2 -1
@@ -23,6 +23,7 @@ func init() {
23 UpdateEvery: 5,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -47,8 +48,8 @@ func New() *Pihole {
48 }
49
50 type Config struct {
51 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
52 web.HTTP `yaml:",inline" json:""`
51 - UpdateEvery int `yaml:"update_every" json:"update_every"`
53 SetupVarsPath string `yaml:"setup_vars_path" json:"setup_vars_path"`
54 }
55
src/go/collectors/go.d.plugin/modules/pika/pika.go
+4 -3
@@ -23,6 +23,7 @@ func init() {
23 module.Register("pika", module.Creator{
24 JobConfigSchema: configSchema,
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -39,10 +40,10 @@ func New() *Pika {
40 }
41
42 type Config struct {
42 - tlscfg.TLSConfig `yaml:",inline" json:""`
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 Address string `yaml:"address" json:"address"`
45 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
45 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
46 + tlscfg.TLSConfig `yaml:",inline" json:""`
47 }
48
49 type (
src/go/collectors/go.d.plugin/modules/ping/ping.go
+6 -5
@@ -24,6 +24,7 @@ func init() {
24 UpdateEvery: 5,
25 },
26 Create: func() module.Module { return New() },
27 + Config: func() any { return &Config{} },
28 })
29 }
30
@@ -43,13 +44,13 @@ func New() *Ping {
44 }
45
46 type Config struct {
46 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 Hosts []string `yaml:"hosts" json:"hosts"`
48 - Network string `yaml:"network" json:"network"`
49 + Network string `yaml:"network,omitempty" json:"network"`
50 Privileged bool `yaml:"privileged" json:"privileged"`
50 - SendPackets int `yaml:"packets" json:"packets"`
51 - Interval web.Duration `yaml:"interval" json:"interval"`
52 - Interface string `yaml:"interface" json:"interface"`
51 + SendPackets int `yaml:"packets,omitempty" json:"packets"`
52 + Interval web.Duration `yaml:"interval,omitempty" json:"interval"`
53 + Interface string `yaml:"interface,omitempty" json:"interface"`
54 }
55
56 type (
src/go/collectors/go.d.plugin/modules/portcheck/portcheck.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 5,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -34,10 +35,10 @@ func New() *PortCheck {
35 }
36
37 type Config struct {
37 - UpdateEvery int `yaml:"update_every" json:"update_every"`
38 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
39 Host string `yaml:"host" json:"host"`
40 Ports []int `yaml:"ports" json:"ports"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 }
43
44 type PortCheck struct {
src/go/collectors/go.d.plugin/modules/postgres/postgres.go
+6 -5
@@ -25,6 +25,7 @@ func init() {
25 module.Register("postgres", module.Creator{
26 JobConfigSchema: configSchema,
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -57,12 +58,12 @@ func New() *Postgres {
58 }
59
60 type Config struct {
60 - UpdateEvery int `yaml:"update_every" json:"update_every"`
61 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
62 DSN string `yaml:"dsn" json:"dsn"`
62 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
63 - DBSelector string `yaml:"collect_databases_matching" json:"collect_databases_matching"`
64 - XactTimeHistogram []float64 `yaml:"transaction_time_histogram" json:"transaction_time_histogram"`
65 - QueryTimeHistogram []float64 `yaml:"query_time_histogram" json:"query_time_histogram"`
63 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
64 + DBSelector string `yaml:"collect_databases_matching,omitempty" json:"collect_databases_matching"`
65 + XactTimeHistogram []float64 `yaml:"transaction_time_histogram,omitempty" json:"transaction_time_histogram"`
66 + QueryTimeHistogram []float64 `yaml:"query_time_histogram,omitempty" json:"query_time_histogram"`
67 MaxDBTables int64 `yaml:"max_db_tables" json:"max_db_tables"`
68 MaxDBIndexes int64 `yaml:"max_db_indexes" json:"max_db_indexes"`
69 }
src/go/collectors/go.d.plugin/modules/powerdns/authoritativens.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("powerdns", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -38,8 +39,8 @@ func New() *AuthoritativeNS {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type AuthoritativeNS struct {
src/go/collectors/go.d.plugin/modules/powerdns_recursor/recursor.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("powerdns_recursor", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -38,8 +39,8 @@ func New() *Recursor {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type Recursor struct {
src/go/collectors/go.d.plugin/modules/prometheus/prometheus.go
+10 -9
@@ -24,6 +24,7 @@ func init() {
24 UpdateEvery: 10,
25 },
26 Create: func() module.Module { return New() },
27 + Config: func() any { return &Config{} },
28 })
29 }
30
@@ -44,19 +45,19 @@ func New() *Prometheus {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 - Name string `yaml:"name" json:"name"`
50 - Application string `yaml:"app" json:"app"`
51 - BearerTokenFile string `yaml:"bearer_token_file" json:"bearer_token_file"`
52 - Selector selector.Expr `yaml:"selector" json:"selector"`
53 - ExpectedPrefix string `yaml:"expected_prefix" json:"expected_prefix"`
50 + Name string `yaml:"name,omitempty" json:"name"`
51 + Application string `yaml:"app,omitempty" json:"app"`
52 + BearerTokenFile string `yaml:"bearer_token_file,omitempty" json:"bearer_token_file"`
53 + Selector selector.Expr `yaml:"selector,omitempty" json:"selector"`
54 + ExpectedPrefix string `yaml:"expected_prefix,omitempty" json:"expected_prefix"`
55 MaxTS int `yaml:"max_time_series" json:"max_time_series"`
56 MaxTSPerMetric int `yaml:"max_time_series_per_metric" json:"max_time_series_per_metric"`
57 FallbackType struct {
57 - Gauge []string `yaml:"gauge" json:"gauge"`
58 - Counter []string `yaml:"counter" json:"counter"`
59 - } `yaml:"fallback_type" json:"fallback_type"`
58 + Gauge []string `yaml:"gauge,omitempty" json:"gauge"`
59 + Counter []string `yaml:"counter,omitempty" json:"counter"`
60 + } `yaml:"fallback_type,omitempty" json:"fallback_type"`
61 }
62
63 type Prometheus struct {
src/go/collectors/go.d.plugin/modules/proxysql/proxysql.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 module.Register("proxysql", module.Creator{
22 JobConfigSchema: configSchema,
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -42,9 +43,9 @@ func New() *ProxySQL {
43 }
44
45 type Config struct {
45 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
47 DSN string `yaml:"dsn" json:"dsn"`
47 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
48 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
49 }
50
51 type ProxySQL struct {
src/go/collectors/go.d.plugin/modules/pulsar/pulsar.go
+3 -2
@@ -24,6 +24,7 @@ func init() {
24 UpdateEvery: 60,
25 },
26 Create: func() module.Module { return New() },
27 + Config: func() any { return &Config{} },
28 })
29 }
30
@@ -53,9 +54,9 @@ func New() *Pulsar {
54 }
55
56 type Config struct {
57 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
58 web.HTTP `yaml:",inline" json:""`
57 - UpdateEvery int `yaml:"update_every" json:"update_every"`
58 - TopicFilter matcher.SimpleExpr `yaml:"topic_filter" json:"topic_filter"`
59 + TopicFilter matcher.SimpleExpr `yaml:"topic_filter,omitempty" json:"topic_filter"`
60 }
61
62 type Pulsar struct {
src/go/collectors/go.d.plugin/modules/rabbitmq/rabbitmq.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("rabbitmq", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -44,8 +45,8 @@ func New() *RabbitMQ {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
50 CollectQueues bool `yaml:"collect_queues_metrics" json:"collect_queues_metrics"`
51 }
52
src/go/collectors/go.d.plugin/modules/redis/redis.go
+8 -7
@@ -23,8 +23,9 @@ var configSchema string
23
24 func init() {
25 module.Register("redis", module.Creator{
26 - Create: func() module.Module { return New() },
26 JobConfigSchema: configSchema,
27 + Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -45,13 +46,13 @@ func New() *Redis {
46 }
47
48 type Config struct {
48 - tlscfg.TLSConfig `yaml:",inline" json:""`
49 - UpdateEvery int `yaml:"update_every" json:"update_every"`
49 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
50 Address string `yaml:"address" json:"address"`
51 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
52 - Username string `yaml:"username" json:"username"`
53 - Password string `yaml:"password" json:"password"`
54 - PingSamples int `yaml:"ping_samples" json:"ping_samples"`
51 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
52 + Username string `yaml:"username,omitempty" json:"username"`
53 + Password string `yaml:"password,omitempty" json:"password"`
54 + tlscfg.TLSConfig `yaml:",inline" json:""`
55 + PingSamples int `yaml:"ping_samples" json:"ping_samples"`
56 }
57
58 type (
src/go/collectors/go.d.plugin/modules/rspamd/rspamd.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("rspamd", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -39,8 +40,8 @@ func New() *Rspamd {
40 }
41
42 type Config struct {
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 web.HTTP `yaml:",inline" json:""`
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
45 }
46
47 type Rspamd struct {
src/go/collectors/go.d.plugin/modules/scaleio/scaleio.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("scaleio", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -40,8 +41,8 @@ func New() *ScaleIO {
41 }
42
43 type Config struct {
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 web.HTTP `yaml:",inline" json:""`
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 }
47
48 type (
src/go/collectors/go.d.plugin/modules/sensors/sensors.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -36,8 +37,8 @@ func New() *Sensors {
37 }
38
39 type Config struct {
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 BinaryPath string `yaml:"binary_path" json:"binary_path"`
43 }
44
src/go/collectors/go.d.plugin/modules/smartctl/smartctl.go
+7 -6
@@ -24,6 +24,7 @@ func init() {
24 UpdateEvery: 10,
25 },
26 Create: func() module.Module { return New() },
27 + Config: func() any { return &Config{} },
28 })
29 }
30
@@ -43,12 +44,12 @@ func New() *Smartctl {
44 }
45
46 type Config struct {
46 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
48 - ScanEvery web.Duration `yaml:"scan_every" json:"scan_every"`
49 - PollDevicesEvery web.Duration `yaml:"poll_devices_every" json:"poll_devices_every"`
50 - NoCheckPowerMode string `yaml:"no_check_power_mode" json:"no_check_power_mode"`
51 - DeviceSelector string `yaml:"device_selector" json:"device_selector"`
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
49 + ScanEvery web.Duration `yaml:"scan_every,omitempty" json:"scan_every"`
50 + PollDevicesEvery web.Duration `yaml:"poll_devices_every,omitempty" json:"poll_devices_every"`
51 + NoCheckPowerMode string `yaml:"no_check_power_mode,omitempty" json:"no_check_power_mode"`
52 + DeviceSelector string `yaml:"device_selector,omitempty" json:"device_selector"`
53 }
54
55 type (
src/go/collectors/go.d.plugin/modules/snmp/snmp.go
+18 -17
@@ -23,6 +23,7 @@ func init() {
23 UpdateEvery: defaultUpdateEvery,
24 },
25 Create: func() module.Module { return New() },
26 + Config: func() any { return &Config{} },
27 })
28 }
29
@@ -63,27 +64,27 @@ func New() *SNMP {
64
65 type (
66 Config struct {
66 - UpdateEvery int `yaml:"update_every" json:"update_every"`
67 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
68 Hostname string `yaml:"hostname" json:"hostname"`
68 - Community string `yaml:"community" json:"community"`
69 - User User `yaml:"user" json:"user"`
70 - Options Options `yaml:"options" json:"options"`
71 - ChartsInput []ChartConfig `yaml:"charts" json:"charts"`
69 + Community string `yaml:"community,omitempty" json:"community"`
70 + User User `yaml:"user,omitempty" json:"user"`
71 + Options Options `yaml:"options,omitempty" json:"options"`
72 + ChartsInput []ChartConfig `yaml:"charts,omitempty" json:"charts"`
73 }
74 User struct {
74 - Name string `yaml:"name" json:"name"`
75 - SecurityLevel string `yaml:"level" json:"level"`
76 - AuthProto string `yaml:"auth_proto" json:"auth_proto"`
77 - AuthKey string `yaml:"auth_key" json:"auth_key"`
78 - PrivProto string `yaml:"priv_proto" json:"priv_proto"`
79 - PrivKey string `yaml:"priv_key" json:"priv_key"`
75 + Name string `yaml:"name,omitempty" json:"name"`
76 + SecurityLevel string `yaml:"level,omitempty" json:"level"`
77 + AuthProto string `yaml:"auth_proto,omitempty" json:"auth_proto"`
78 + AuthKey string `yaml:"auth_key,omitempty" json:"auth_key"`
79 + PrivProto string `yaml:"priv_proto,omitempty" json:"priv_proto"`
80 + PrivKey string `yaml:"priv_key,omitempty" json:"priv_key"`
81 }
82 Options struct {
82 - Port int `yaml:"port" json:"port"`
83 - Retries int `yaml:"retries" json:"retries"`
84 - Timeout int `yaml:"timeout" json:"timeout"`
85 - Version string `yaml:"version" json:"version"`
86 - MaxOIDs int `yaml:"max_request_size" json:"max_request_size"`
83 + Port int `yaml:"port,omitempty" json:"port"`
84 + Retries int `yaml:"retries,omitempty" json:"retries"`
85 + Timeout int `yaml:"timeout,omitempty" json:"timeout"`
86 + Version string `yaml:"version,omitempty" json:"version"`
87 + MaxOIDs int `yaml:"max_request_size,omitempty" json:"max_request_size"`
88 }
89 ChartConfig struct {
90 ID string `yaml:"id" json:"id"`
@@ -92,7 +93,7 @@ type (
93 Family string `yaml:"family" json:"family"`
94 Type string `yaml:"type" json:"type"`
95 Priority int `yaml:"priority" json:"priority"`
95 - IndexRange []int `yaml:"multiply_range" json:"multiply_range"`
96 + IndexRange []int `yaml:"multiply_range,omitempty" json:"multiply_range"`
97 Dimensions []DimensionConfig `yaml:"dimensions" json:"dimensions"`
98 }
99 DimensionConfig struct {
src/go/collectors/go.d.plugin/modules/squidlog/squidlog.go
+4 -3
@@ -16,6 +16,7 @@ func init() {
16 module.Register("squidlog", module.Creator{
17 JobConfigSchema: configSchema,
18 Create: func() module.Module { return New() },
19 + Config: func() any { return &Config{} },
20 })
21 }
22
@@ -39,10 +40,10 @@ func New() *SquidLog {
40 }
41
42 type Config struct {
42 - logs.ParserConfig `yaml:",inline" json:""`
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 Path string `yaml:"path" json:"path"`
45 - ExcludePath string `yaml:"exclude_path" json:"exclude_path"`
45 + ExcludePath string `yaml:"exclude_path,omitempty" json:"exclude_path"`
46 + logs.ParserConfig `yaml:",inline" json:""`
47 }
48
49 type SquidLog struct {
src/go/collectors/go.d.plugin/modules/storcli/storcli.go
+3 -2
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -37,8 +38,8 @@ func New() *StorCli {
38 }
39
40 type Config struct {
40 - UpdateEvery int `yaml:"update_every" json:"update_every"`
41 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
41 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
42 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
43 }
44
45 type (
src/go/collectors/go.d.plugin/modules/supervisord/supervisord.go
+3 -2
@@ -18,6 +18,7 @@ func init() {
18 module.Register("supervisord", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -36,9 +37,9 @@ func New() *Supervisord {
37 }
38
39 type Config struct {
39 - web.Client `yaml:",inline" json:""`
40 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 URL string `yaml:"url" json:"url"`
42 + web.Client `yaml:",inline" json:""`
43 }
44
45 type (
src/go/collectors/go.d.plugin/modules/systemdunits/systemdunits.go
+7 -6
@@ -27,6 +27,7 @@ func init() {
27 UpdateEvery: 10, // gathering systemd units can be a CPU intensive op
28 },
29 Create: func() module.Module { return New() },
30 + Config: func() any { return &Config{} },
31 })
32 }
33
@@ -47,12 +48,12 @@ func New() *SystemdUnits {
48 }
49
50 type Config struct {
50 - UpdateEvery int `yaml:"update_every" json:"update_every"`
51 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
52 - Include []string `yaml:"include" json:"include"`
53 - CollectUnitFiles bool `yaml:"collect_unit_files" json:"collect_unit_files"`
54 - IncludeUnitFiles []string `yaml:"include_unit_files" json:"include_unit_files"`
55 - CollectUnitFilesEvery web.Duration `yaml:"collect_unit_files_every" json:"collect_unit_files_every"`
51 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
52 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
53 + Include []string `yaml:"include,omitempty" json:"include"`
54 + CollectUnitFiles bool `yaml:"collect_unit_files,omitempty" json:"collect_unit_files"`
55 + IncludeUnitFiles []string `yaml:"include_unit_files,omitempty" json:"include_unit_files"`
56 + CollectUnitFilesEvery web.Duration `yaml:"collect_unit_files_every,omitempty" json:"collect_unit_files_every"`
57 }
58
59 type SystemdUnits struct {
src/go/collectors/go.d.plugin/modules/tengine/tengine.go
+2 -1
@@ -18,6 +18,7 @@ func init() {
18 module.Register("tengine", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -38,8 +39,8 @@ func New() *Tengine {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type Tengine struct {
src/go/collectors/go.d.plugin/modules/traefik/traefik.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("traefik", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -44,8 +45,8 @@ func New() *Traefik {
45 }
46
47 type Config struct {
48 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
49 web.HTTP `yaml:",inline" json:""`
48 - UpdateEvery int `yaml:"update_every" json:"update_every"`
50 }
51
52 type (
src/go/collectors/go.d.plugin/modules/unbound/unbound.go
+6 -5
@@ -20,6 +20,7 @@ func init() {
20 module.Register("unbound", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -43,13 +44,13 @@ func New() *Unbound {
44 }
45
46 type Config struct {
46 - tlscfg.TLSConfig `yaml:",inline" json:""`
47 - UpdateEvery int `yaml:"update_every" json:"update_every"`
47 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
48 Address string `yaml:"address" json:"address"`
49 - ConfPath string `yaml:"conf_path" json:"conf_path"`
50 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
49 + ConfPath string `yaml:"conf_path,omitempty" json:"conf_path"`
50 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
51 Cumulative bool `yaml:"cumulative_stats" json:"cumulative_stats"`
52 - UseTLS bool `yaml:"use_tls" json:"use_tls"`
52 + UseTLS bool `yaml:"use_tls,omitempty" json:"use_tls"`
53 + tlscfg.TLSConfig `yaml:",inline" json:""`
54 }
55
56 type Unbound struct {
src/go/collectors/go.d.plugin/modules/upsd/upsd.go
+5 -4
@@ -18,6 +18,7 @@ func init() {
18 module.Register("upsd", module.Creator{
19 JobConfigSchema: configSchema,
20 Create: func() module.Module { return New() },
21 + Config: func() any { return &Config{} },
22 })
23 }
24
@@ -34,11 +35,11 @@ func New() *Upsd {
35 }
36
37 type Config struct {
37 - UpdateEvery int `yaml:"update_every" json:"update_every"`
38 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
39 Address string `yaml:"address" json:"address"`
39 - Username string `yaml:"username" json:"username"`
40 - Password string `yaml:"password" json:"password"`
41 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
40 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
41 + Username string `yaml:"username,omitempty" json:"username"`
42 + Password string `yaml:"password,omitempty" json:"password"`
43 }
44
45 type (
src/go/collectors/go.d.plugin/modules/vcsa/vcsa.go
+2 -1
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 5, // VCSA health checks freq is 5 second.
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -38,8 +39,8 @@ func New() *VCSA {
39 }
40
41 type Config struct {
42 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
43 web.HTTP `yaml:",inline" json:""`
42 - UpdateEvery int `yaml:"update_every" json:"update_every"`
44 }
45
46 type (
src/go/collectors/go.d.plugin/modules/vernemq/vernemq.go
+2 -1
@@ -19,6 +19,7 @@ func init() {
19 module.Register("vernemq", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -40,8 +41,8 @@ func New() *VerneMQ {
41 }
42
43 type Config struct {
44 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
45 web.HTTP `yaml:",inline" json:""`
44 - UpdateEvery int `yaml:"update_every" json:"update_every"`
46 }
47
48 type (
src/go/collectors/go.d.plugin/modules/vsphere/vsphere.go
+5 -4
@@ -25,6 +25,7 @@ func init() {
25 UpdateEvery: 20,
26 },
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -49,11 +50,11 @@ func New() *VSphere {
50 }
51
52 type Config struct {
53 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
54 web.HTTP `yaml:",inline" json:""`
53 - UpdateEvery int `yaml:"update_every" json:"update_every"`
54 - DiscoveryInterval web.Duration `yaml:"discovery_interval" json:"discovery_interval"`
55 - HostsInclude match.HostIncludes `yaml:"host_include" json:"host_include"`
56 - VMsInclude match.VMIncludes `yaml:"vm_include" json:"vm_include"`
55 + DiscoveryInterval web.Duration `yaml:"discovery_interval,omitempty" json:"discovery_interval"`
56 + HostsInclude match.HostIncludes `yaml:"host_include,omitempty" json:"host_include"`
57 + VMsInclude match.VMIncludes `yaml:"vm_include,omitempty" json:"vm_include"`
58 }
59
60 type (
src/go/collectors/go.d.plugin/modules/weblog/weblog.go
+11 -10
@@ -16,6 +16,7 @@ func init() {
16 module.Register("web_log", module.Creator{
17 JobConfigSchema: configSchema,
18 Create: func() module.Module { return New() },
19 + Config: func() any { return &Config{} },
20 })
21 }
22
@@ -45,15 +46,15 @@ func New() *WebLog {
46
47 type (
48 Config struct {
49 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
50 + Path string `yaml:"path" json:"path"`
51 + ExcludePath string `yaml:"exclude_path,omitempty" json:"exclude_path"`
52 logs.ParserConfig `yaml:",inline" json:""`
49 - UpdateEvery int `yaml:"update_every" json:"update_every"`
50 - Path string `yaml:"path" json:"path"`
51 - ExcludePath string `yaml:"exclude_path" json:"exclude_path"`
52 - URLPatterns []userPattern `yaml:"url_patterns" json:"url_patterns"`
53 - CustomFields []customField `yaml:"custom_fields" json:"custom_fields"`
54 - CustomTimeFields []customTimeField `yaml:"custom_time_fields" json:"custom_time_fields"`
55 - CustomNumericFields []customNumericField `yaml:"custom_numeric_fields" json:"custom_numeric_fields"`
56 - Histogram []float64 `yaml:"histogram" json:"histogram"`
53 + URLPatterns []userPattern `yaml:"url_patterns,omitempty" json:"url_patterns"`
54 + CustomFields []customField `yaml:"custom_fields,omitempty" json:"custom_fields"`
55 + CustomTimeFields []customTimeField `yaml:"custom_time_fields,omitempty" json:"custom_time_fields"`
56 + CustomNumericFields []customNumericField `yaml:"custom_numeric_fields,omitempty" json:"custom_numeric_fields"`
57 + Histogram []float64 `yaml:"histogram,omitempty" json:"histogram"`
58 GroupRespCodes bool `yaml:"group_response_codes" json:"group_response_codes"`
59 }
60 userPattern struct {
@@ -71,8 +72,8 @@ type (
72 customNumericField struct {
73 Name string `yaml:"name" json:"name"`
74 Units string `yaml:"units" json:"units"`
74 - Multiplier int `yaml:"multiplier" json:"multiplier"`
75 - Divisor int `yaml:"divisor" json:"divisor"`
75 + Multiplier int `yaml:"multiplier,omitempty" json:"multiplier"`
76 + Divisor int `yaml:"divisor,omitempty" json:"divisor"`
77 }
78 )
79
src/go/collectors/go.d.plugin/modules/whoisquery/whoisquery.go
+5 -4
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 60,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -35,11 +36,11 @@ func New() *WhoisQuery {
36 }
37
38 type Config struct {
38 - UpdateEvery int `yaml:"update_every" json:"update_every"`
39 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
40 Source string `yaml:"source" json:"source"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
41 - DaysUntilWarn int64 `yaml:"days_until_expiration_warning" json:"days_until_expiration_warning"`
42 - DaysUntilCrit int64 `yaml:"days_until_expiration_critical" json:"days_until_expiration_critical"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 + DaysUntilWarn int64 `yaml:"days_until_expiration_warning,omitempty" json:"days_until_expiration_warning"`
43 + DaysUntilCrit int64 `yaml:"days_until_expiration_critical,omitempty" json:"days_until_expiration_critical"`
44 }
45
46 type WhoisQuery struct {
src/go/collectors/go.d.plugin/modules/windows/windows.go
+3 -2
@@ -22,6 +22,7 @@ func init() {
22 UpdateEvery: 5,
23 },
24 Create: func() module.Module { return New() },
25 + Config: func() any { return &Config{} },
26 })
27 }
28
@@ -68,9 +69,9 @@ func New() *Windows {
69 }
70
71 type Config struct {
72 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
73 web.HTTP `yaml:",inline" json:""`
72 - UpdateEvery int `yaml:"update_every" json:"update_every"`
73 - Vnode string `yaml:"vnode" json:"vnode"`
74 + Vnode string `yaml:"vnode,omitempty" json:"vnode"`
75 }
76
77 type (
src/go/collectors/go.d.plugin/modules/wireguard/wireguard.go
+2 -1
@@ -20,6 +20,7 @@ func init() {
20 module.Register("wireguard", module.Creator{
21 JobConfigSchema: configSchema,
22 Create: func() module.Module { return New() },
23 + Config: func() any { return &Config{} },
24 })
25 }
26
@@ -34,7 +35,7 @@ func New() *WireGuard {
35 }
36
37 type Config struct {
37 - UpdateEvery int `yaml:"update_every" json:"update_every"`
38 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
39 }
40
41 type (
src/go/collectors/go.d.plugin/modules/x509check/x509check.go
+6 -5
@@ -25,6 +25,7 @@ func init() {
25 UpdateEvery: 60,
26 },
27 Create: func() module.Module { return New() },
28 + Config: func() any { return &Config{} },
29 })
30 }
31
@@ -39,13 +40,13 @@ func New() *X509Check {
40 }
41
42 type Config struct {
42 - tlscfg.TLSConfig `yaml:",inline" json:""`
43 - UpdateEvery int `yaml:"update_every" json:"update_every"`
43 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
44 Source string `yaml:"source" json:"source"`
45 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
46 - DaysUntilWarn int64 `yaml:"days_until_expiration_warning" json:"days_until_expiration_warning"`
47 - DaysUntilCritical int64 `yaml:"days_until_expiration_critical" json:"days_until_expiration_critical"`
45 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
46 + DaysUntilWarn int64 `yaml:"days_until_expiration_warning,omitempty" json:"days_until_expiration_warning"`
47 + DaysUntilCritical int64 `yaml:"days_until_expiration_critical,omitempty" json:"days_until_expiration_critical"`
48 CheckRevocation bool `yaml:"check_revocation_status" json:"check_revocation_status"`
49 + tlscfg.TLSConfig `yaml:",inline" json:""`
50 }
51
52 type X509Check struct {
src/go/collectors/go.d.plugin/modules/zfspool/zfspool.go
+4 -3
@@ -21,6 +21,7 @@ func init() {
21 UpdateEvery: 10,
22 },
23 Create: func() module.Module { return New() },
24 + Config: func() any { return &Config{} },
25 })
26 }
27
@@ -36,9 +37,9 @@ func New() *ZFSPool {
37 }
38
39 type Config struct {
39 - UpdateEvery int `yaml:"update_every" json:"update_every"`
40 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
41 - BinaryPath string `yaml:"binary_path" json:"binary_path"`
40 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
41 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
42 + BinaryPath string `yaml:"binary_path,omitempty" json:"binary_path"`
43 }
44
45 type (
src/go/collectors/go.d.plugin/modules/zookeeper/zookeeper.go
+5 -4
@@ -19,6 +19,7 @@ func init() {
19 module.Register("zookeeper", module.Creator{
20 JobConfigSchema: configSchema,
21 Create: func() module.Module { return New() },
22 + Config: func() any { return &Config{} },
23 })
24 }
25
@@ -32,11 +33,11 @@ func New() *Zookeeper {
33 }
34
35 type Config struct {
35 - tlscfg.TLSConfig `yaml:",inline" json:""`
36 - UpdateEvery int `yaml:"update_every" json:"update_every"`
36 + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
37 Address string `yaml:"address" json:"address"`
38 - Timeout web.Duration `yaml:"timeout" json:"timeout"`
39 - UseTLS bool `yaml:"use_tls" json:"use_tls"`
38 + Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"`
39 + tlscfg.TLSConfig `yaml:",inline" json:""`
40 + UseTLS bool `yaml:"use_tls,omitempty" json:"use_tls"`
41 }
42
43 type (
src/go/collectors/go.d.plugin/pkg/logs/csv.go
+3 -3
@@ -14,10 +14,10 @@ import (
14
15 type (
16 CSVConfig struct {
17 - FieldsPerRecord int `yaml:"fields_per_record" json:"fields_per_record"`
18 - Delimiter string `yaml:"delimiter" json:"delimiter"`
17 + FieldsPerRecord int `yaml:"fields_per_record,omitempty" json:"fields_per_record"`
18 + Delimiter string `yaml:"delimiter,omitempty" json:"delimiter"`
19 TrimLeadingSpace bool `yaml:"trim_leading_space" json:"trim_leading_space"`
20 - Format string `yaml:"format" json:"format"`
20 + Format string `yaml:"format,omitempty" json:"format"`
21 CheckField func(string) (string, int, bool) `yaml:"-" json:"-"`
22 }
23
src/go/collectors/go.d.plugin/pkg/logs/parser.go
+5 -5
@@ -40,11 +40,11 @@ const (
40 )
41
42 type ParserConfig struct {
43 - LogType string `yaml:"log_type" json:"log_type"`
44 - CSV CSVConfig `yaml:"csv_config" json:"csv_config"`
45 - LTSV LTSVConfig `yaml:"ltsv_config" json:"ltsv_config"`
46 - RegExp RegExpConfig `yaml:"regexp_config" json:"regexp_config"`
47 - JSON JSONConfig `yaml:"json_config" json:"json_config"`
43 + LogType string `yaml:"log_type,omitempty" json:"log_type"`
44 + CSV CSVConfig `yaml:"csv_config,omitempty" json:"csv_config"`
45 + LTSV LTSVConfig `yaml:"ltsv_config,omitempty" json:"ltsv_config"`
46 + RegExp RegExpConfig `yaml:"regexp_config,omitempty" json:"regexp_config"`
47 + JSON JSONConfig `yaml:"json_config,omitempty" json:"json_config"`
48 }
49
50 func NewParser(config ParserConfig, in io.Reader) (Parser, error) {
src/go/collectors/go.d.plugin/pkg/matcher/expr.go
+2 -2
@@ -15,8 +15,8 @@ type (
15 // SimpleExpr is a simple expression to describe the condition:
16 // (includes[0].Match(v) || includes[1].Match(v) || ...) && !(excludes[0].Match(v) || excludes[1].Match(v) || ...)
17 SimpleExpr struct {
18 - Includes []string `yaml:"includes" json:"includes"`
19 - Excludes []string `yaml:"excludes" json:"excludes"`
18 + Includes []string `yaml:"includes,omitempty" json:"includes"`
19 + Excludes []string `yaml:"excludes,omitempty" json:"excludes"`
20 }
21 )
22
src/go/collectors/go.d.plugin/pkg/prometheus/selector/expr.go
+2 -2
@@ -5,8 +5,8 @@ package selector
5 import "fmt"
6
7 type Expr struct {
8 - Allow []string `yaml:"allow" json:"allow"`
9 - Deny []string `yaml:"deny" json:"deny"`
8 + Allow []string `yaml:"allow,omitempty" json:"allow"`
9 + Deny []string `yaml:"deny,omitempty" json:"deny"`
10 }
11
12 func (e Expr) Empty() bool {
src/go/collectors/go.d.plugin/pkg/tlscfg/config.go
+4 -4
@@ -12,16 +12,16 @@ import (
12 // TLSConfig represents the standard client TLS configuration.
13 type TLSConfig struct {
14 // TLSCA specifies the certificate authority to use when verifying server certificates.
15 - TLSCA string `yaml:"tls_ca" json:"tls_ca"`
15 + TLSCA string `yaml:"tls_ca,omitempty" json:"tls_ca"`
16
17 // TLSCert specifies tls certificate file.
18 - TLSCert string `yaml:"tls_cert" json:"tls_cert"`
18 + TLSCert string `yaml:"tls_cert,omitempty" json:"tls_cert"`
19
20 // TLSKey specifies tls key file.
21 - TLSKey string `yaml:"tls_key" json:"tls_key"`
21 + TLSKey string `yaml:"tls_key,omitempty" json:"tls_key"`
22
23 // InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name.
24 - InsecureSkipVerify bool `yaml:"tls_skip_verify" json:"tls_skip_verify"`
24 + InsecureSkipVerify bool `yaml:"tls_skip_verify,omitempty" json:"tls_skip_verify"`
25 }
26
27 // NewTLSConfig creates a tls.Config, may be nil without an error if TLS is not configured.
src/go/collectors/go.d.plugin/pkg/web/client.go
+4 -4
@@ -21,18 +21,18 @@ var ErrRedirectAttempted = errors.New("redirect")
21 type Client struct {
22 // Timeout specifies a time limit for requests made by this Client.
23 // Default (zero value) is no timeout. Must be set before http.Client creation.
24 - Timeout Duration `yaml:"timeout" json:"timeout"`
24 + Timeout Duration `yaml:"timeout,omitempty" json:"timeout"`
25
26 // NotFollowRedirect specifies the policy for handling redirects.
27 // Default (zero value) is std http package default policy (stop after 10 consecutive requests).
28 - NotFollowRedirect bool `yaml:"not_follow_redirects" json:"not_follow_redirects"`
28 + NotFollowRedirect bool `yaml:"not_follow_redirects,omitempty" json:"not_follow_redirects"`
29
30 // ProxyURL specifies the URL of the proxy to use. An empty string means use the environment variables
31 // HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the lowercase versions thereof) to get the URL.
32 - ProxyURL string `yaml:"proxy_url" json:"proxy_url"`
32 + ProxyURL string `yaml:"proxy_url,omitempty" json:"proxy_url"`
33
34 // TLSConfig specifies the TLS configuration.
35 - tlscfg.TLSConfig `yaml:",inline" json:",inline"`
35 + tlscfg.TLSConfig `yaml:",inline" json:""`
36 }
37
38 // NewHTTPClient returns a new *http.Client given a Client configuration and an error if any.
src/go/collectors/go.d.plugin/pkg/web/request.go
+13 -13
@@ -20,28 +20,28 @@ type Request struct {
20 // URL specifies the URL to access.
21 URL string `yaml:"url" json:"url"`
22
23 - // Body specifies the HTTP request body to be sent by the client.
24 - Body string `yaml:"body" json:"body"`
25 -
26 - // Method specifies the HTTP method (GET, POST, PUT, etc.). An empty string means GET.
27 - Method string `yaml:"method" json:"method"`
28 -
29 - // Headers specifies the HTTP request header fields to be sent by the client.
30 - Headers map[string]string `yaml:"headers" json:"headers"`
31 -
23 // Username specifies the username for basic HTTP authentication.
33 - Username string `yaml:"username" json:"username"`
24 + Username string `yaml:"username,omitempty" json:"username"`
25
26 // Password specifies the password for basic HTTP authentication.
36 - Password string `yaml:"password" json:"password"`
27 + Password string `yaml:"password,omitempty" json:"password"`
28
29 // ProxyUsername specifies the username for basic HTTP authentication.
30 // It is used to authenticate a user agent to a proxy server.
40 - ProxyUsername string `yaml:"proxy_username" json:"proxy_username"`
31 + ProxyUsername string `yaml:"proxy_username,omitempty" json:"proxy_username"`
32
33 // ProxyPassword specifies the password for basic HTTP authentication.
34 // It is used to authenticate a user agent to a proxy server.
44 - ProxyPassword string `yaml:"proxy_password" json:"proxy_password"`
35 + ProxyPassword string `yaml:"proxy_password,omitempty" json:"proxy_password"`
36 +
37 + // Method specifies the HTTP method (GET, POST, PUT, etc.). An empty string means GET.
38 + Method string `yaml:"method,omitempty" json:"method"`
39 +
40 + // Headers specifies the HTTP request header fields to be sent by the client.
41 + Headers map[string]string `yaml:"headers,omitempty" json:"headers"`
42 +
43 + // Body specifies the HTTP request body to be sent by the client.
44 + Body string `yaml:"body,omitempty" json:"body"`
45 }
46
47 // Copy makes a full copy of the Request.
src/go/collectors/go.d.plugin/pkg/web/web.go
+2 -2
@@ -6,6 +6,6 @@ package web
6 // This structure intended to be part of the module configuration.
7 // Supported configuration file formats: YAML.
8 type HTTP struct {
9 - Request `yaml:",inline" json:",inline"`
10 - Client `yaml:",inline" json:",inline"`
9 + Request `yaml:",inline" json:""`
10 + Client `yaml:",inline" json:""`
11 }