telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Add new command `run` to replace `--config` and ` --config-directory`

Open sspaink opened this issue 3 years ago • 3 comments

Backwards compatibility is required

Related: https://github.com/influxdata/telegraf/issues/11316

Deprecate the flags --config, --config-directory by adding DEPRECATED: to the Usage field for each. Then add a new command run that will accept a configuration file or directory as a value and run Telegraf with the provided configurations. I assume it won't be a problem to have Telegraf check if the provided field is a file or a folder, opposed to needing separate flags for a file and directory. The flags --once, --quiet, --debug, --test, --test-wait will also need to be moved to be flags under the command run opposed to global as they are now. These global flags need to be marked as deprecated as well.

Example of expected help output:

NAME:
   Telegraf run value - Run telegraf with a provided config

USAGE:
   Telegraf run value (accepts multiple inputs)

e.g.

telegraf run telegraf.conf ~ Run with a config named telegraf.conf

telegraf run telegraf.conf,telegraf_dir ~ Run with a config named telegraf.conf and a directory called telegraf_dir containing configs

sspaink avatar Aug 29 '22 20:08 sspaink

If "run" is a subcommand, what does telegraf do when you call it without a subcommand? Running is the main purpose of the program so it feels natural to me to run without a subcommand.

Removing or combining --config and --config-directory could be useful.

reimda avatar Sep 06 '22 20:09 reimda

I was thinking if you just run telegraf then it will print the help information, similar to what git does when you just run git. It is a good point that running Telegraf with a config is its main purpose, but the benefit I like of adding the run command is it cleans up the help information organizing all the flags that are relevant to running Telegraf into one section.

sspaink avatar Sep 06 '22 21:09 sspaink

Action:

  • Research other daemons are doing, should it display help when just running telegraf?
  • Check with other teams.

Option: Include directive in the config to point to other configs and directories instead of allowing to pass multiple.

Goal: Choose an approach that reduce impact to the end user, but consistent with rest of commands.

This might be too distributive and provide no benefit over --config and --config-directory.

sspaink avatar Sep 07 '22 18:09 sspaink

Prometheus: ./prometheus --config.file=prometheus.yml DataDog: <AGENT_BIN_PATH> <SUB_COMMAND> <OPTIONS>

  • it appears you can't change the file location of the datadog agent config. have to use the the default file or directory locations)

OpenTelemetry Collector: uses --config: https://opentelemetry.io/docs/collector/getting-started/#local fluentd: also uses --config https://docs.fluentd.org/deployment/command-line-option#fluentd

sjwang90 avatar Sep 29 '22 18:09 sjwang90

At this point, given no 2.x, we are not going to revamp the CLI and instead maintain the current behavior.

powersj avatar Nov 07 '23 15:11 powersj