Table of Contents
Time series data is everywhere, from IoT sensors and server metrics to financial transactions and user behavior. The TIG Stack brings together Telegraf for collection, InfluxDB 3 Core for storage and queries, and Grafana for visualization. This walkthrough collects CPU metrics on your machine and turns them into a Grafana time series.
You’ll learn how to start InfluxDB 3 Core, create a database and token, write metrics with Telegraf, verify the data with the InfluxDB CLI, and visualize it in Grafana.
Requirements
Install the current versions of:
- InfluxDB 3 Core
- Telegraf 1.38 or later to use the native
influxdb_v3output plugin - Grafana 12.2 or later for the current InfluxDB SQL data source workflow
The commands below assume that all three run on the same machine. If you use Grafana Cloud, it needs a private data source or another reachable connection to your InfluxDB server; Grafana Cloud cannot reach localhost on your computer.
Start InfluxDB 3 Core
Start the server with a local file object store. Binding to 127.0.0.1 keeps this initial setup on your machine while you create the first token:
influxdb3 serve --node-id local01 --object-store file --data-dir ~/.influxdb3 --http-bind 127.0.0.1:8181
Leave that terminal running. In a second terminal, create the first admin token (the operator token):
influxdb3 create token --admin
Copy the raw token when it appears; it is displayed only once. Set it as an environment variable in the terminal where you’ll run the remaining commands. Replace the placeholder with your actual token:
export INFLUXDB3_AUTH_TOKEN='YOUR_AUTH_TOKEN'
The CLI reads INFLUXDB3_AUTH_TOKEN automatically. For this local example, use the operator token to create a cpu database:
influxdb3 create database cpu
The current setup uses a token for CLI and HTTP requests after the first token is created. See the Core setup guide for token handling and server options.
Collect CPU metrics with Telegraf
Telegraf uses input plugins to gather metrics and output plugins to send them to a destination. The CPU input produces a cpu measurement. With Telegraf 1.38 or later, the native influxdb_v3 output writes to InfluxDB 3 Core’s v3 API. Save this configuration as telegraf.conf:
[agent]
interval = "10s"
flush_interval = "10s"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = true
[[outputs.influxdb_v3]]
urls = ["http://127.0.0.1:8181"]
token = "${INFLUXDB3_AUTH_TOKEN}"
database = "cpu"
Run Telegraf from the same terminal where you set the token:
telegraf --config ./telegraf.conf --debug
Look for a successful write message from outputs.influxdb_v3. If you run Telegraf as a service, make the token available to that service through its environment or a secret store. Older Telegraf configurations can still use the influxdb_v2 compatibility output, but the current Telegraf guide recommends influxdb_v3 for new InfluxDB 3 Core setups.
Verify the data with the InfluxDB CLI
After Telegraf has collected a few samples, query the cpu database:
influxdb3 query --database cpu 'SELECT time, cpu, usage_user FROM cpu ORDER BY time DESC LIMIT 10'
You should see recent timestamps and CPU usage values. Telegraf’s totalcpu = true setting also writes rows tagged cpu-total, which you can use for a single overall CPU series. See the query CLI reference for more options.
Visualize the data in Grafana
For Grafana 12.2 or later, follow the InfluxDB 3 Core Grafana guide to enable the newInfluxDSConfigPageDesign feature flag when running Grafana locally. Open Grafana, then go to Connections > Data sources > Add new data source and select InfluxDB.
Configure the data source:
- URL:
http://127.0.0.1:8181for the local server in this tutorial - Product:
InfluxDB Enterprise 3.x(the current Grafana menu has no separate Core option) - Query language:
SQL - Database:
cpu - Token: the raw admin token you created earlier
Because this local example uses HTTP without TLS, enable Advanced Database Settings > Insecure Connection. Select Save & test. Grafana uses Flight SQL over HTTP/2 for SQL queries, so a proxy between Grafana and InfluxDB must support HTTP/2.
In Explore, select your InfluxDB data source and query the overall CPU series. In the SQL editor, you can use:
SELECT time, usage_user
FROM cpu
WHERE $__timeFilter(time) AND cpu = 'cpu-total'
ORDER BY time
Select Time series as the result format and run the query. The $__timeFilter(time) macro uses Grafana’s active time range, so choose a range that includes the data Telegraf has written. You can then add the query to a dashboard. For the query editor and available macros, see the Grafana InfluxDB query editor documentation.
Final thoughts
You now have a TIG Stack pipeline: Telegraf collects CPU metrics, InfluxDB 3 Core stores and queries them, and Grafana displays them. To expand the setup, add more Telegraf input plugins or explore the InfluxDB 3 Core documentation. For product help and feedback, see the InfluxDB 3 Core support options.