This page covers configuration for Telegraf deployments.
| File | Purpose |
|---|---|
/etc/telegraf/telegraf.conf |
Main configuration file |
/etc/telegraf/telegraf.d/ |
Additional configuration files |
Telegraf uses TOML format for configuration:
# Global tags
[global_tags]
hostname = "myserver"
environment = "production"
datacenter = "us-east-1"
# Agent settings
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
debug = false
quiet = false
logfile = "/var/log/telegraf/telegraf.log"
# CPU
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
# Memory
[[inputs.mem]]
# Disk
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
# Network
[[inputs.net]]
# Disk I/O
[[inputs.diskio]]
# System load
[[inputs.system]]
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
gather_services = false
container_names = []
container_name_include = []
container_name_exclude = []
timeout = "5s"
perdevice = true
total = false
[[inputs.prometheus]]
urls = ["http://localhost:9090/metrics"]
bearer_token = ""
insecure_skip_verify = false
[[outputs.influxdb_v2]]
urls = ["http://influxdb:8086"]
token = "${INFLUXDB_TOKEN}"
organization = "${INFLUXDB_ORG}"
bucket = "${INFLUXDB_BUCKET}"
[[outputs.influxdb]]
urls = ["http://influxdb:8086"]
database = "telegraf"
username = "${INFLUXDB_USER}"
password = "${INFLUXDB_PASSWORD}"
[[outputs.prometheus_client]]
listen = ":9273"
metric_version = 2
[[outputs.graphite]]
servers = ["graphite.example.com:2003"]
prefix = "telegraf"
template = "host.tags.measurement.field"
[[processors.rename]]
[[processors.rename.replace]]
measurement = "cpu"
dest = "processor"
[[processors.filter]]
namepass = ["cpu", "mem", "disk"]
namedrop = ["internal*"]
[[processors.add_tag]]
key = "environment"
value = "production"
order = 1
[[aggregators.minmax]]
period = "1m"
drop_original = true
grace = "10s"
[[aggregators.basicstats]]
period = "1m"
drop_original = true
stats = ["count", "min", "max", "mean"]
Use Telegraf’s secret store:
[secretstores]
[[secretstores.os]]
id = "my-secret-store"
service = "telegraf"
Then reference in outputs:
[[outputs.influxdb_v2]]
token = "@{my-secret-store:influxdb_token}"
# Test configuration
telegraf --config /etc/telegraf/telegraf.conf --test
# Config test only
telegraf --config /etc/telegraf/telegraf.conf --config-test
# Generate sample config
telegraf config > sample.conf
# Restart Telegraf
sudo systemctl restart telegraf
# Reload (if supported)
sudo systemctl reload telegraf
# Check status
sudo systemctl status telegraf
# Check logs
sudo journalctl -u telegraf -f
# Test output
telegraf --config /etc/telegraf/telegraf.conf --test
# Check metrics endpoint
curl http://localhost:9273/metrics
Telegraf supports environment variable substitution:
[[outputs.influxdb_v2]]
urls = ["${INFLUXDB_URL}"]
token = "${INFLUXDB_TOKEN}"
organization = "${INFLUXDB_ORG}"
bucket = "${INFLUXDB_BUCKET}"