Skip to content
Snippets Groups Projects
CONFIGURATION.md 8.65 KiB

Telegraf Configuration

Generating a Configuration File

A default Telegraf config file can be generated using the -sample-config flag:

telegraf -sample-config > telegraf.conf

To generate a file with specific inputs and outputs, you can use the -input-filter and -output-filter flags:

telegraf -sample-config -input-filter cpu:mem:net:swap -output-filter influxdb:kafka

You can see the latest config file with all available plugins here: telegraf.conf

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)

[global_tags] Configuration

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.
  • debug: Run telegraf in debug mode.
  • quiet: Run telegraf in quiet mode.
  • hostname: Override default hostname, if empty use os.Hostname().

Measurement Filtering

Filters can be configured per input or output, see below for examples.

  • namepass: An array of strings that is used to filter metrics generated by the current input. Each string in the array is tested as a glob match against measurement names and if it matches, the field is emitted.
  • namedrop: The inverse of pass, if a measurement name matches, it is not emitted.
  • fieldpass: An array of strings that is used to filter metrics generated by the current input. Each string in the array is tested as a glob match against field names and if it matches, the field is emitted. fieldpass is not available for outputs.
  • fielddrop: The inverse of pass, if a field name matches, it is not emitted. fielddrop is not available for outputs.
  • tagpass: tag names and arrays of strings that are used to filter measurements by the current input. Each string in the array is tested as a glob match against the tag name, and if it matches the measurement is emitted.
  • tagdrop: The inverse of tagpass. If a tag matches, the measurement is not emitted. This is tested on measurements that have passed the tagpass test.
  • tagexclude: tagexclude can be used to exclude a tag from measurement(s). As opposed to tagdrop, which will drop an entire measurement based on it's tags, tagexclude simply strips the given tag keys from the measurement. This can be used on inputs & outputs, but it is recommended to be used on inputs, as it is more efficient to filter out tags at the ingestion point.
  • taginclude: taginclude is the inverse of tagexclude. It will only include the tag keys in the final measurement.

Input Configuration

Some configuration options are configurable per input:

  • name_override: Override the base name of the measurement. (Default is the name of the input).
  • name_prefix: Specifies a prefix to attach to the measurement name.
  • name_suffix: Specifies a suffix to attach to the measurement name.
  • tags: A map of tags to apply to a specific input's measurements.
  • interval: How often to gather this metric. Normal plugins use a single global interval, but if one particular input should be run less or more often, you can configure that here.