Telegraf commands and flags

The telegraf command starts and runs all the processes necessary for Telegraf to function.

Usage

telegraf [commands]
telegraf [flags]

Commands

CommandDescription
configGenerate and migrate Telegraf configurations
pluginsPrint available plugins
secretsManage secrets in secret stores
serviceManage the Telegraf Windows service (Windows only)
versionPrint current version to stdout

Global flags

Load configuration

FlagDescription
--config <file>Configuration file to load. Can be a local path or a URL. Repeat to load multiple files.
--config-directory <directory>Directory containing additional *.conf files. Repeat to load multiple directories.
--config-url-retry-attempts <count>Number of attempts to obtain a remote configuration from a URL during startup. Set to -1 for unlimited attempts. Default is 3.
--config-url-watch-interval <duration>Time duration to check for updates to URL-based configuration files. Disabled by default.
--watch-config <method>Restart Telegraf on local configuration changes. Use filesystem notifications (notify) on Linux, BSD, and macOS, or polling (poll), required on Windows. Disabled by default.
--watch-interval <duration>Time duration to check for updates to local configuration files. Use with --watch-config poll. Disabled by default.
--watch-debounce-interval <duration>Time duration to wait after a configuration change before reloading.

Run modes

FlagDescription
--testGather metrics once, print them, and exit. Test mode runs inputs, processors, and aggregators, but not outputs.
--test-wait <seconds>Number of seconds to wait for service inputs to complete in test or once mode.
--onceGather metrics once, write them to the configured outputs, and exit.

Select plugins

FlagDescription
--input-filter <filter>Filter input plugins to enable. Separator is :.
--output-filter <filter>Filter output plugins to enable. Separator is :.
--processor-filter <filter>Filter processor plugins to enable. Separator is :.
--aggregator-filter <filter>Filter aggregator plugins to enable. Separator is :.
--secretstore-filter <filter>Filter secret store plugins to enable. Separator is :.
--section-filter <filter>Filter configuration sections to output (agent, global_tags, outputs, processors, aggregators, and inputs). Separator is :.
--select <selector>Enable only plugins with labels matching the given key-value selection. Repeat for OR logic; multiple pairs in one option combine with AND.
FlagDescription
--usage <plugin>Print plugin usage (example: telegraf --usage mysql).
--input-listPrint available input plugins.
--output-listPrint available output plugins.
--deprecation-listPrint all deprecated plugins or plugin options.
--print-plugin-config-sourcePrint the source for a given plugin.
--help, -hPrint help and exit.

Secrets and environment

FlagDescription
--password <password>Password to unlock secret stores.
--unprotectedDo not protect secrets in memory.
--strict-env-handlingEnforce strict and secure handling of environment variables. Doesn’t work with non-string settings.
--non-strict-env-handlingAllow unsafe non-strict handling of environment variables to replace non-string settings.
--old-env-behaviorSwitch back to pre-v1.27 environment replacement behavior.

Logging and debugging

FlagDescription
--debugEnable debug logging.
--quietRun in quiet mode.
--pprof-addr <address>pprof address to listen on. Disabled by default.
--pidfile <file>File to write the process ID (PID) to.

Deprecated flags

FlagDescription
--versionPrint Telegraf version. Use telegraf version instead.
--sample-configPrint full sample configuration. Use telegraf config instead.
--plugin-directory <directory>Directory containing *.so files to search recursively for plugins. Found plugins are loaded, tagged, and identified.

Examples

Generate a Telegraf configuration file

telegraf config > telegraf.conf

Generate a configuration with only specific plugins

telegraf config \
  --input-filter cpu \
  --output-filter influxdb_v3

Run a single Telegraf configuration and output metrics to stdout

telegraf --config telegraf.conf --test

Run Telegraf with all plugins defined in configuration file

telegraf --config telegraf.conf

Run Telegraf, but only enable specific plugins

telegraf \
  --config telegraf.conf \
  --input-filter cpu:mem \
  --output-filter influxdb_v3

Run Telegraf with pprof

telegraf \
  --config telegraf.conf \
  --pprof-addr localhost:6060

Was this page helpful?

Thank you for your feedback!