Downsample metrics before writing
Collect at high resolution, keep the raw data briefly, and store compact statistical summaries long-term. This configuration collects CPU and memory metrics every 10 seconds, writes the raw metrics to one database, and writes 5-minute min, max, and mean summaries to another.
Configuration
[agent]
interval = "10s"
[[inputs.cpu]]
totalcpu = true
[[inputs.mem]]
[[aggregators.basicstats]]
## Summarize each 5-minute window.
period = "5m"
stats = ["min", "max", "mean"]
## Keep the raw metrics flowing to the outputs.
drop_original = false
## Rename the aggregates so outputs can route on the name.
name_suffix = "_5m"
[[outputs.influxdb_v3]]
## Raw metrics: everything except the renamed aggregates.
urls = ["http://localhost:8181"]
token = "AUTH_TOKEN"
database = "RAW_DATABASE_NAME"
namedrop = ["*_5m"]
[[outputs.influxdb_v3]]
## Aggregates only.
urls = ["http://localhost:8181"]
token = "AUTH_TOKEN"
database = "SUMMARY_DATABASE_NAME"
namepass = ["*_5m"]Replace the following:
AUTH_TOKEN: your InfluxDB authorization tokenRAW_DATABASE_NAME: the database for full-resolution metrics, typically with a short retention periodSUMMARY_DATABASE_NAME: the database for long-term summaries
How it works
aggregators.basicstatscollects matching metrics into 5-minute windows and emits<field>_min,<field>_max, and<field>_meanfields at the end of each period.drop_original = false(the default) lets the raw metrics continue to the outputs alongside the aggregates. The result is two streams in one pipeline: rawcpuandmemmetrics every 10 seconds, pluscpu_5mandmem_5maggregates every 5 minutes.name_suffix = "_5m"renames the aggregate metrics, which is what makes them routable: the raw output excludes them withnamedrop = ["*_5m"], and the summary output selects only them withnamepass = ["*_5m"].- Each output batches and delivers independently, so a slow or unavailable destination doesn’t block the other.
To keep only the summaries and discard raw data entirely, set
drop_original = true and remove the raw output.
See
Why processors run twice
for how aggregates flow through the pipeline.
Example output
Raw metrics, every 10 seconds:
cpu,cpu=cpu-total,host=host1 usage_idle=92.4,usage_user=4.2 1709572230000000000
mem,host=host1 used_percent=64.2 1709572230000000000Aggregates, every 5 minutes:
cpu_5m,cpu=cpu-total,host=host1 usage_idle_min=88.1,usage_idle_max=94.6,usage_idle_mean=91.7,usage_user_min=3.1,usage_user_max=6.8,usage_user_mean=4.4 1709572500000000000
mem_5m,host=host1 used_percent_min=63.8,used_percent_max=65.1,used_percent_mean=64.3 1709572500000000000Extend this example
- Swap or add aggregators for different summaries: quantiles, histograms, or final values. See Common aggregator examples.
- Scope the aggregator to specific measurements with
namepasson the aggregator itself. - For more routing patterns, see Route metrics to different outputs.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Telegraf and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.