How to Install and Configure Telegraf and InfluxDB on CentOS Stream 9: Building a Time-Series Database with Grafana

Hey everyone. Recently, my team cleaned up our entire monitoring infrastructure. We still have a few servers running CentOS 7 that need to be migrated to AlmaLinux, while at the same time we’re spinning up several new nodes on CentOS Stream 9.

With servers running a mix of OS versions, I needed a lightweight and consistent solution for collecting metrics. The Time-Series Database also needed to store data efficiently so Grafana could render charts quickly.

Before diving into the terminal, I’ll share how our team weighed the options and why we chose the Telegraf + InfluxDB combo, then walk through the actual installation steps.

Comparing Modern System Monitoring Approaches

To collect metrics from Linux servers, DevOps engineers usually gravitate toward three main models:

  • Pull-based (Prometheus + Node Exporter + Grafana): Prometheus actively pulls (scrapes) metrics from nodes over an HTTP port (9100 by default).
  • Push-based (Telegraf + InfluxDB + Grafana – TIG Stack): The Telegraf agent on each machine collects metrics and pushes them to InfluxDB. Grafana simply reads from there to visualize the data.
  • Traditional All-in-one (Zabbix or Nagios): Uses dedicated agents paired with an RDBMS (MySQL/PostgreSQL) to collect, store, and alert within a single interface.

Pros and Cons of Each Solution

1. Prometheus + Node Exporter

Prometheus is a great fit if you’re running Kubernetes or an environment with dynamic Service Discovery. However, the pull mechanism becomes a hassle when servers sit behind NAT, across different VPCs, or behind strict inbound port rules. For long-term storage spanning several months or more, you also need to add Thanos or Cortex, which makes the architecture noticeably heavier.

2. Telegraf + InfluxDB + Grafana (TIG Stack)

What I like most about this stack is that Telegraf is written in Go and runs super light. A single agent uses only about 25–40 MB of RAM and comes with over 300 input plugins out of the box. Thanks to the push model, servers across different subnets only need outbound access to a single InfluxDB port. On the flip side, you do need to manage API Tokens carefully and configure a Retention Policy on InfluxDB 2.x so your disk doesn’t silently fill up.

3. Zabbix / Traditional RDBMS-Based Systems

Zabbix ships with very detailed alerting right out of the box. However, once you scale past a few dozen nodes at a 10-second sampling interval, writing time-series data into MySQL or PostgreSQL easily causes I/O bottlenecks. Loading a 30-day historical chart at that point becomes noticeably sluggish.

Choosing the Right Stack for Our DevOps Team

For a hybrid infrastructure combining new CentOS Stream 9 nodes and recently upgraded legacy servers, our team went with the TIG Stack (Telegraf + InfluxDB 2.x + Grafana). Installation via the package manager is fast. More importantly, we don’t have to open inbound ports on every child server for Prometheus to scrape. InfluxDB also compresses time-series data remarkably well, averaging just 1–2 bytes per data point.

Step-by-Step Deployment of Telegraf, InfluxDB, and Grafana on CentOS Stream 9

I ran all the commands below directly on CentOS Stream 9 using sudo privileges.

Step 1: Add the Official InfluxData Repository

CentOS Stream 9 uses an RHEL 9-compatible package system. Let’s add the official InfluxData repository to get the latest versions:

cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo
[influxdata]
name = InfluxData Repository - Stable
baseurl = https://repos.influxdata.com/stable/\$basearch/main
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
EOF

Step 2: Install and Initialize InfluxDB 2.x

Install influxdb2 along with influxdb2-cli, then enable and start the service:

sudo dnf install -y influxdb2 influxdb2-cli
sudo systemctl enable --now influxdb

Next, open port 8086 in firewalld so remote Telegraf nodes and Grafana can connect:

sudo firewall-cmd --add-port=8086/tcp --permanent
sudo firewall-cmd --reload

Run the initial setup command to create the admin account, Organization, Bucket, and data retention period (720h, equivalent to 30 days):

influx setup \
  --username admin \
  --password 'YourStrongPassword123!' \
  --org devops-team \
  --bucket server-metrics \
  --retention 720h \
  --force

The influx setup command automatically saves your authentication profile to ~/.influxdbv2/configs. You can inspect the newly generated API Token right away with:

influx auth list

Quick tip: The default token created by setup has full permissions (Operator). In production, you should create a dedicated token with write-only permissions to the server-metrics bucket for Telegraf.

Step 3: Install and Configure Telegraf

Since we already added the repo in Step 1, we can install Telegraf directly with dnf:

sudo dnf install -y telegraf

The default configuration file is thousands of lines long and hard to read. I usually back up the original file and write a cleaner /etc/telegraf/telegraf.conf:

sudo cp /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.bak

Paste the following into /etc/telegraf/telegraf.conf (remember to replace YOUR_INFLUXDB_TOKEN with your actual token):

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  flush_interval = "10s"

[[outputs.influxdb_v2]]
  urls = ["http://127.0.0.1:8086"]
  token = "YOUR_INFLUXDB_TOKEN"
  organization = "devops-team"
  bucket = "server-metrics"

[[inputs.cpu]]
  percpu = true
  totalcpu = true
  fieldexclude = ["time_*"]

[[inputs.mem]]

[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.net]]

[[inputs.system]]

Run a quick check with --test to validate the syntax and confirm Telegraf can read metrics before starting the service:

sudo telegraf --config /etc/telegraf/telegraf.conf --test

If the output prints CPU, RAM, and Disk metrics normally, you’re good to go. Now enable the service to run in the background:

sudo systemctl enable --now telegraf

Step 4: Install Grafana and Connect Your Dashboard

Add the Grafana repository and install the OSS edition:

cat <<EOF | sudo tee /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF

sudo dnf install -y grafana
sudo systemctl enable --now grafana-server

Open port 3000 in firewalld to access the web UI:

sudo firewall-cmd --add-port=3000/tcp --permanent
sudo firewall-cmd --reload

That wraps up the installation. Open your browser and go to http://<Server-IP>:3000 (log in with admin / admin and change your password), then complete these two steps:

  1. Configure the Data Source: Navigate to Connections → Data sources → Add data source → InfluxDB. Select Flux as the Query Language, enter http://127.0.0.1:8086 as the URL, and fill in your Organization (devops-team), Token, and Default Bucket (server-metrics). Click Save & test to confirm a green connection status.
  2. Build a Dashboard: Go to Dashboards → Import to use a community template that supports InfluxDB v2 Flux. If you want to build a custom CPU Usage panel, you can use this sample Flux query:
from(bucket: "server-metrics")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "cpu")
  |> filter(fn: (r) => r["_field"] == "usage_user" or r["_field"] == "usage_system")
  |> filter(fn: (r) => r["cpu"] == "cpu-total")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

Practical Tips for Production

  • Encrypt connections: When multiple servers push metrics over an internal network or the internet to a central InfluxDB instance, enable TLS on port 8086 or place it behind Nginx/HAProxy to avoid exposing tokens in plain text.
  • Keep storage in check: Always set an explicit retention policy for each bucket. At a 10-second interval across roughly 20 servers, keeping 30–90 days of metrics usually only consumes a few gigabytes of disk space.
  • Expand to application monitoring: To monitor additional services, simply enable plugins like [[inputs.nginx]], [[inputs.postgresql]], or [[inputs.docker]] in telegraf.conf and restart the service.
Share: