InfluxDB 2.x is a purpose-built time-series database that excels at storing high-cardinality metrics with millisecond precision, while Telegraf is its companion agent that collects metrics from hundreds of input plugins and writes them directly to InfluxDB. Together they form the “TIG stack” backbone when paired with Grafana for visualisation. On RHEL 9, both packages are available through the official InfluxData repository, making installation straightforward. This tutorial covers adding the repository, configuring InfluxDB, running the initial setup wizard, configuring Telegraf to collect system metrics, and querying data with Flux in the InfluxDB UI.
Prerequisites
- RHEL 9 server with at least 2 GB RAM and root or sudo access
- Port 8086 open in firewalld for the InfluxDB HTTP API and web UI
- Internet access to download packages from the InfluxData repository
- Grafana installed if you want to visualise data beyond the built-in InfluxDB dashboards
Step 1 — Add the InfluxData Repository and Install InfluxDB 2
InfluxData provides an official RPM repository for RHEL-based systems. Add the repository, install influxdb2, and start the service.
cat > /etc/yum.repos.d/influxdata.repo << 'EOF'
[influxdata]
name=InfluxData Repository
baseurl=https://repos.influxdata.com/rhel/9/x86_64/stable/
enabled=1
gpgcheck=1
gpgkey=https://repos.influxdata.com/influxdata-archive_compat.key
EOF
dnf install -y influxdb2
systemctl enable --now influxdb
systemctl status influxdb
# Open firewall port for the web UI and API
firewall-cmd --permanent --add-port=8086/tcp
firewall-cmd --reload
Step 2 — Run the Initial Setup
InfluxDB 2 requires a one-time setup step to create the initial admin user, organisation, and default bucket. This can be done via the web UI at http://<server-ip>:8086 or from the command line using the influx setup command.
# CLI-based setup (non-interactive)
influx setup
--username admin
--password 'YourSecurePassword'
--org myorg
--bucket telegraf
--retention 30d
--force
# The setup command outputs an operator API token — save this value immediately.
# It is shown only once and is needed for Telegraf and Grafana configuration.
# Verify the setup
influx org list
influx bucket list
# Create an additional all-access token for Telegraf writes
influx auth create
--org myorg
--description "telegraf-writer"
--write-buckets
--read-buckets
Step 3 — Install and Configure Telegraf
Telegraf is available from the same InfluxData repository. After installation, edit the main configuration file to configure the InfluxDB v2 output plugin and enable the system metrics input plugins.
dnf install -y telegraf
# Edit the Telegraf configuration
vi /etc/telegraf/telegraf.conf
# Locate and configure the [[outputs.influxdb_v2]] section:
[[outputs.influxdb_v2]]
urls = ["http://127.0.0.1:8086"]
token = "YOUR_TELEGRAF_TOKEN_HERE"
organization = "myorg"
bucket = "telegraf"
# Ensure these input plugins are enabled (uncomment if needed):
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.mem]]
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.net]]
[[inputs.system]]
[[inputs.processes]]
Step 4 — Start Telegraf and Verify Data Ingestion
Start the Telegraf service and confirm it is writing metrics to InfluxDB successfully.
systemctl enable --now telegraf
systemctl status telegraf
# Check Telegraf logs for write errors
journalctl -u telegraf -n 50 --no-pager
# Verify data is arriving in InfluxDB via CLI
influx query --org myorg
'from(bucket:"telegraf") |> range(start: -5m) |> filter(fn: (r) => r._measurement == "cpu") |> limit(n:5)'
# Check using the influx CLI shorthand
influx query -o myorg 'from(bucket:"telegraf") |> range(start:-1m) |> first()'
Step 5 — Query Data in InfluxDB UI with Flux
Open the InfluxDB web UI at http://<server-ip>:8086, navigate to Data Explorer, and use Flux queries to explore and visualise your metrics. Flux is InfluxDB 2’s functional query language and is more expressive than InfluxQL.
# Average CPU usage over the last hour
from(bucket: "telegraf")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "cpu" and r.cpu == "cpu-total" and r._field == "usage_active")
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
|> yield(name: "cpu_usage")
# Memory available in MB
from(bucket: "telegraf")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "mem" and r._field == "available")
|> map(fn: (r) => ({r with _value: float(v: r._value) / 1048576.0}))
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
# Disk I/O reads per second
from(bucket: "telegraf")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "diskio" and r._field == "read_bytes")
|> derivative(unit: 1s, nonNegative: true)
To connect InfluxDB to Grafana, add a new data source of type InfluxDB, set the query language to Flux, URL to http://localhost:8086, and enter your organisation name and Telegraf token under the InfluxDB Details section.
Conclusion
InfluxDB 2 and Telegraf are now running on your RHEL 9 server, collecting CPU, memory, disk, and network metrics every 10 seconds and storing them in a 30-day retention bucket. The built-in InfluxDB Data Explorer provides a graphical query builder for Flux without requiring a separate Grafana instance, although connecting to Grafana unlocks more powerful dashboarding and unified alerting capabilities. For production deployments, consider enabling InfluxDB’s built-in TLS, rotating API tokens regularly, and tuning Telegraf’s collection interval and batch size to match your storage capacity.
Next steps: How to Set Up Grafana Alerting and Notification Channels on RHEL 9, How to Configure Prometheus Node Exporter on RHEL 9, and How to Install Graylog for Centralised Log Management on RHEL 9.