This guide is intentionally minimal. The source of truth is existing collectors in
src/go/plugin/go.d/collector/.
- New collectors should use
collectorapi.CollectorV2. CollectorV1is legacy compatibility for existing collectors; do not use it for new work.
- Minimal V2 example:
src/go/plugin/go.d/collector/ping/collector.go. - V2 with function methods:
src/go/plugin/go.d/collector/mysql/collector.go.
For a new collector foo, create src/go/plugin/go.d/collector/foo/ with:
collector.go:collectorapi.Register("foo", collectorapi.Creator{...})CreateV2,Config, optionalJobConfigSchema, optional function wiring- collector struct embedding
collectorapi.Base Configuration(),Init(),Check(),Collect(),Cleanup()MetricStore()andChartTemplateYAML()
charts.yaml: chart template consumed by the V2 chart engine.config_schema.json: JSON schema for collector job config.- Any helper files you need (
collect.go,init.go,types.go,testdata/, tests).
- Import the collector in
src/go/plugin/go.d/collector/init.go. - Add default config file:
src/go/plugin/go.d/config/go.d/foo.conf. - Add toggle in
src/go/plugin/go.d/config/go.d.confundermodules:(legacy key name kept for compatibility). - Add/update the entry in
src/go/plugin/go.d/README.md(available collectors).
Init(context.Context) errorCheck(context.Context) errorCollect(context.Context) errorCleanup(context.Context)MetricStore() metrix.CollectorStoreChartTemplateYAML() string
Collector output is produced via metrix + chart templates, not by returning raw metric maps.
From src/go:
go test ./plugin/go.d/collector/foo/...go test ./plugin/go.d/collector/...go test ./cmd/godplugin
If you run the binary manually, CLI uses legacy flag naming: -m/--modules.