Telegraf Configuration
You can see the latest config file with all available plugins here: telegraf.conf
Generating a Configuration File
A default Telegraf config file can be auto-generated by telegraf:
telegraf config > telegraf.conf
To generate a file with specific inputs and outputs, you can use the --input-filter and --output-filter flags:
telegraf --input-filter cpu:mem:net:swap --output-filter influxdb:kafka config
Environment Variables
Environment variables can be used anywhere in the config file, simply prepend them with . For strings the variable must be within quotes (ie, "STR_VAR"), for numbers and booleans they should be plain (ie, $INT_VAR, $BOOL_VAR)
When using the .deb
or .rpm
packages, you can define environment variables
in the /etc/default/telegraf
file.
Configuration file locations
The location of the configuration file can be set via the --config
command
line flag.
When the --config-directory
command line flag is used files ending with
.conf
in the specified directory will also be included in the Telegraf
configuration.
On most systems, the default locations are /etc/telegraf/telegraf.conf
for
the main configuration file and /etc/telegraf/telegraf.d
for the directory of
configuration files.
Global Tags
Global tags can be specified in the [global_tags]
section of the config file
in key="value" format. All metrics being gathered on this host will be tagged
with the tags specified here.
Agent Configuration
Telegraf has a few options you can configure under the [agent]
section of the
config.
-
interval: Default data collection interval for all inputs
-
round_interval: Rounds collection interval to 'interval' ie, if interval="10s" then always collect on :00, :10, :20, etc.
-
metric_batch_size: Telegraf will send metrics to output in batch of at most metric_batch_size metrics.
-
metric_buffer_limit: Telegraf will cache metric_buffer_limit metrics for each output, and will flush this buffer on a successful write. This should be a multiple of metric_batch_size and could not be less than 2 times metric_batch_size.
-
collection_jitter: Collection jitter is used to jitter the collection by a random amount. Each plugin will sleep for a random time within jitter before collecting. This can be used to avoid many plugins querying things like sysfs at the same time, which can have a measurable effect on the system.
-
flush_interval: Default data flushing interval for all outputs. You should not set this below interval. Maximum flush_interval will be flush_interval + flush_jitter
-
flush_jitter: Jitter the flush interval by a random amount. This is primarily to avoid large write spikes for users running a large number of telegraf instances. ie, a jitter of 5s and flush_interval 10s means flushes will happen every 10-15s.
-
precision: By default or when set to "0s", precision will be set to the same timestamp order as the collection interval, with the maximum being 1s. Precision will NOT be used for service inputs. It is up to each individual service input to set the timestamp at the appropriate precision. Valid time units are "ns", "us" (or "µs"), "ms", "s".
-
logfile: Specify the log file name. The empty string means to log to stderr.
-
debug: Run telegraf in debug mode.
-
quiet: Run telegraf in quiet mode (error messages only).
-
hostname: Override default hostname, if empty use os.Hostname().
-
omit_hostname: If true, do no set the "host" tag in the telegraf agent.