Skip to content

Commit

Permalink
feat(cli): List available parsers and serializers (#15426)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Powers <powersj@fastmail.com>
  • Loading branch information
LarsStegman and powersj authored May 31, 2024
1 parent b516ead commit 719e3cb
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
42 changes: 42 additions & 0 deletions cmd/telegraf/cmd_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
"github.com/influxdata/telegraf/plugins/aggregators"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/influxdata/telegraf/plugins/processors"
"github.com/influxdata/telegraf/plugins/secretstores"
"github.com/influxdata/telegraf/plugins/serializers"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -42,12 +44,16 @@ func getPluginCommands(outputBuffer io.Writer) []*cli.Command {
outputBuffer.Write(pluginNames(processors.Deprecations, "processors"))
outputBuffer.Write(pluginNames(aggregators.Deprecations, "aggregators"))
outputBuffer.Write(pluginNames(secretstores.Deprecations, "secretstores"))
outputBuffer.Write(pluginNames(parsers.Deprecations, "parsers"))
outputBuffer.Write(pluginNames(serializers.Deprecations, "serializers"))
} else {
outputBuffer.Write(pluginNames(inputs.Inputs, "inputs"))
outputBuffer.Write(pluginNames(outputs.Outputs, "outputs"))
outputBuffer.Write(pluginNames(processors.Processors, "processors"))
outputBuffer.Write(pluginNames(aggregators.Aggregators, "aggregators"))
outputBuffer.Write(pluginNames(secretstores.SecretStores, "secretstores"))
outputBuffer.Write(pluginNames(parsers.Parsers, "parsers"))
outputBuffer.Write(pluginNames(serializers.Serializers, "serializers"))
}

return nil
Expand Down Expand Up @@ -143,6 +149,42 @@ func getPluginCommands(outputBuffer io.Writer) []*cli.Command {
return nil
},
},
{
Name: "parsers",
Usage: "Print available parser plugins",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "deprecated",
Usage: "print only deprecated plugins",
},
},
Action: func(cCtx *cli.Context) error {
if cCtx.Bool("deprecated") {
outputBuffer.Write(pluginNames(parsers.Deprecations, "parsers"))
} else {
outputBuffer.Write(pluginNames(parsers.Parsers, "parsers"))
}
return nil
},
},
{
Name: "serializers",
Usage: "Print available serializer plugins",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "deprecated",
Usage: "print only deprecated plugins",
},
},
Action: func(cCtx *cli.Context) error {
if cCtx.Bool("deprecated") {
outputBuffer.Write(pluginNames(serializers.Deprecations, "serializers"))
} else {
outputBuffer.Write(pluginNames(serializers.Serializers, "serializers"))
}
return nil
},
},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions docs/CUSTOMIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ You can build customized versions of Telegraf with a specific plugin set using
the [custom builder](/tools/custom_builder) tool or
[build-tags](https://pkg.go.dev/cmd/go#hdr-Build_constraints).
For build tags, the plugins can be selected either category-wise, i.e.
`inputs`, `outputs`,`processors`, `aggregators` and `parsers` or
individually, e.g. `inputs.modbus` or `outputs.influxdb`.
`inputs`, `outputs`,`processors`, `aggregators`, `parsers`, `secretstores`
and `serializers` or individually, e.g. `inputs.modbus` or `outputs.influxdb`.

Usually the build tags correspond to the plugin names used in the Telegraf
configuration. To be sure, check the files in the corresponding
Expand Down
6 changes: 6 additions & 0 deletions plugins/parsers/deprecations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package parsers

import "github.com/influxdata/telegraf"

// Deprecations lists the deprecated plugins
var Deprecations = map[string]telegraf.DeprecationInfo{}
6 changes: 6 additions & 0 deletions plugins/serializers/deprecations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package serializers

import "github.com/influxdata/telegraf"

// Deprecations lists the deprecated plugins
var Deprecations = map[string]telegraf.DeprecationInfo{}

0 comments on commit 719e3cb

Please sign in to comment.