You can see the latest config file with all available plugins here: telegraf.conf
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 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)
Environment variables can be set via the ‘export’ command in Linux (ie, “export password=mypassword”). Using enviroment variables for sensitive information is considered a best practice.
The location of the configuration file can be set via the --config
command line flag. Telegraf will also pick up all files matching the pattern *.conf
if the -config-directory
command line flag is used.
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 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.
Telegraf has a few options you can configure under the [agent]
section of the config.
The following config parameters are available for all inputs:
There are no generic configuration options available for all outputs.
The following config parameters are available for all aggregators:
The following config parameters are available for all processors:
Filters can be configured per input, output, processor, or aggregator, see below for examples.
namepass
. If a match is found the point is discarded. This is tested on points after they have passed the namepass
test.fieldpass
. Fields with a field key matching one of the patterns will be discarded from the point. Not available for outputs.tagpass
. If a match is found the point is discarded. This is tested on points after they have passed the tagpass
test.tagpass
, which will pass an entire point based on its tag, taginclude
removes all non matching tags from the point. This filter can be used on both 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
. Tags with a tag key matching one of the patterns will be discarded from the point.NOTE Due to the way TOML is parsed, tagpass
and tagdrop
parameters must be defined at the end of the plugin definition, otherwise subsequent plugin config options will be interpreted as part of the tagpass/tagdrop tables.
This is a full working config that will output CPU data to an InfluxDB instance at 192.168.59.103:8086, tagging measurements with dc=“denver-1”. It will output measurements at a 10s interval and will collect per-cpu data, dropping any fields which begin with time_
.
[global_tags] dc = "denver-1" [agent] interval = "10s" # OUTPUTS [[outputs.influxdb]] url = "http://192.168.59.103:8086" # required. database = "telegraf" # required. precision = "s" # INPUTS [[inputs.cpu]] percpu = true totalcpu = false # filter all fields beginning with 'time_' fielddrop = ["time_*"]
NOTE tagpass
and tagdrop
parameters must be defined at the end of the plugin definition, otherwise subsequent plugin config options will be interpreted as part of the tagpass/tagdrop map.
[[inputs.cpu]] percpu = true totalcpu = false fielddrop = ["cpu_time"] # Don't collect CPU data for cpu6 & cpu7 [inputs.cpu.tagdrop] cpu = [ "cpu6", "cpu7" ] [[inputs.disk]] [inputs.disk.tagpass] # tagpass conditions are OR, not AND. # If the (filesystem is ext4 or xfs) OR (the path is /opt or /home) # then the metric passes fstype = [ "ext4", "xfs" ] # Globs can also be used on the tag values path = [ "/opt", "/home*" ]
# Drop all metrics for guest & steal CPU usage [[inputs.cpu]] percpu = false totalcpu = true fielddrop = ["usage_guest", "usage_steal"] # Only store inode related metrics for disks [[inputs.disk]] fieldpass = ["inodes*"]
# Drop all metrics about containers for kubelet [[inputs.prometheus]] urls = ["http://kube-node-1:4194/metrics"] namedrop = ["container_*"] # Only store rest client related metrics for kubelet [[inputs.prometheus]] urls = ["http://kube-node-1:4194/metrics"] namepass = ["rest_client_*"]
# Only include the "cpu" tag in the measurements for the cpu plugin. [[inputs.cpu]] percpu = true totalcpu = true taginclude = ["cpu"] # Exclude the "fstype" tag from the measurements for the disk plugin. [[inputs.disk]] tagexclude = ["fstype"]
This plugin will emit measurements with the name cpu_total
[[inputs.cpu]] name_suffix = "_total" percpu = false totalcpu = true
This will emit measurements with the name foobar
[[inputs.cpu]] name_override = "foobar" percpu = false totalcpu = true
This plugin will emit measurements with two additional tags: tag1=foo
and tag2=bar
NOTE: Order matters, the [inputs.cpu.tags]
table must be at the end of the plugin definition.
[[inputs.cpu]] percpu = false totalcpu = true [inputs.cpu.tags] tag1 = "foo" tag2 = "bar"
Additional inputs (or outputs) of the same type can be specified, just define more instances in the config file. It is highly recommended that you utilize name_override
, name_prefix
, or name_suffix
config options to avoid measurement collisions:
[[inputs.cpu]] percpu = false totalcpu = true [[inputs.cpu]] percpu = true totalcpu = false name_override = "percpu_usage" fielddrop = ["cpu_time*"]
[[outputs.influxdb]] urls = [ "http://localhost:8086" ] database = "telegraf" precision = "s" # Drop all measurements that start with "aerospike" namedrop = ["aerospike*"] [[outputs.influxdb]] urls = [ "http://localhost:8086" ] database = "telegraf-aerospike-data" precision = "s" # Only accept aerospike data: namepass = ["aerospike*"] [[outputs.influxdb]] urls = [ "http://localhost:8086" ] database = "telegraf-cpu0-data" precision = "s" # Only store measurements where the tag "cpu" matches the value "cpu0" [outputs.influxdb.tagpass] cpu = ["cpu0"]
This will collect and emit the min/max of the system load1 metric every 30s, dropping the originals.
[[inputs.system]] fieldpass = ["load1"] # collects system load1 metric. [[aggregators.minmax]] period = "30s" # send & clear the aggregate every 30s. drop_original = true # drop the original metrics. [[outputs.file]] files = ["stdout"]
This will collect and emit the min/max of the swap metrics every 30s, dropping the originals. The aggregator will not be applied to the system load metrics due to the namepass
parameter.
[[inputs.swap]] [[inputs.system]] fieldpass = ["load1"] # collects system load1 metric. [[aggregators.minmax]] period = "30s" # send & clear the aggregate every 30s. drop_original = true # drop the original metrics. namepass = ["swap"] # only "pass" swap metrics through the aggregator. [[outputs.file]] files = ["stdout"]
© 2015 InfluxData, Inc.
Licensed under the MIT license.
https://docs.influxdata.com/telegraf/v1.3/administration/configuration/