How to Install InfluxDB and Telegraf on RHEL 7
InfluxDB is a purpose-built time series database optimised for the high-write workloads that are typical in infrastructure monitoring, IoT data collection, and application performance tracking. Unlike general-purpose databases, InfluxDB stores measurements indexed by timestamp and tag values, enabling sub-millisecond queries across billions of data points. Telegraf is its companion agent — a plugin-driven metrics collector that ships data from CPU, disk, memory, network interfaces, Docker, databases, and hundreds of other sources directly into InfluxDB with zero code. Together they form the “TI” in the TICK stack (Telegraf, InfluxDB, Chronograf, Kapacitor) and integrate cleanly with Grafana for dashboards. This guide covers installing and configuring both on Red Hat Enterprise Linux 7 using the official InfluxData yum repository.
Prerequisites
- RHEL 7 with root or sudo access
- A minimum of 2 GB RAM; 4 GB or more is recommended for production workloads
- At least 10 GB of free disk space on the data partition (time series data grows continuously)
- NTP or Chrony configured to keep system time accurate — InfluxDB relies on accurate timestamps
- Grafana installed separately if you intend to build dashboards (optional for basic setup)
Step 1: Add the InfluxData Yum Repository
InfluxData maintains official RPM packages for RHEL/CentOS 7. Add the repository and import the GPG key:
sudo tee /etc/yum.repos.d/influxdata.repo <<'EOF'
[influxdata]
name = InfluxData Repository - Stable
baseurl = https://repos.influxdata.com/rhel/7/x86_64/stable/
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
EOF
sudo rpm --import https://repos.influxdata.com/influxdata-archive_compat.key
Verify the repository is recognised by yum:
sudo yum repolist | grep influxdata
Step 2: Install InfluxDB and Telegraf
Install both packages in one command. The repository provides InfluxDB 1.x, which is the version best supported on RHEL 7 and has the widest Grafana compatibility:
sudo yum install -y influxdb telegraf
# Confirm versions
influxd version
telegraf --version
Step 3: Configure InfluxDB
The main InfluxDB configuration file is at /etc/influxdb/influxdb.conf. The default configuration is suitable for a single-node deployment, but review the following key sections:
sudo vi /etc/influxdb/influxdb.conf
Key settings to review and adjust:
[meta]
# Directory where cluster metadata is stored
dir = "/var/lib/influxdb/meta"
[data]
# Directory where shard data is stored
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
# Maximum size a shard's WAL can reach before flushing to disk
wal-fsync-delay = "0s"
# Compress TSM files to reduce disk usage
index-version = "tsi1"
[http]
# HTTP API endpoint settings
enabled = true
bind-address = ":8086"
auth-enabled = false # Set to true in production and create admin user
log-enabled = true
write-tracing = false
pprof-enabled = false
https-enabled = false
[retention]
# Automatic retention policy enforcement
enabled = true
check-interval = "30m"
[logging]
format = "auto"
level = "info"
suppress-logo = false
Enable and start InfluxDB:
sudo systemctl daemon-reload
sudo systemctl enable influxdb
sudo systemctl start influxdb
sudo systemctl status influxdb
Verify the HTTP API is responding:
curl -s http://localhost:8086/ping
# Returns HTTP 204 No Content on success
Step 4: Create a Database and Retention Policy
Use the influx CLI to create a dedicated database for Telegraf metrics and set a retention policy. A retention policy tells InfluxDB how long to keep data before automatically purging old shards.
influx
Inside the InfluxDB shell:
-- Create the metrics database
CREATE DATABASE telegraf
-- Create a 30-day retention policy named "30days" as the default
CREATE RETENTION POLICY "30days" ON "telegraf" DURATION 30d REPLICATION 1 DEFAULT
-- Verify
SHOW DATABASES
SHOW RETENTION POLICIES ON telegraf
-- Exit the shell
EXIT
You can also create the database and retention policy in a single non-interactive command:
influx -execute 'CREATE DATABASE telegraf'
influx -execute 'CREATE RETENTION POLICY "30days" ON "telegraf" DURATION 30d REPLICATION 1 DEFAULT'
If you enabled HTTP authentication in influxdb.conf, first create an admin user:
influx -execute "CREATE USER admin WITH PASSWORD 'SecurePassword123' WITH ALL PRIVILEGES"
Step 5: Configure Telegraf
Telegraf’s configuration lives at /etc/telegraf/telegraf.conf. The file is large with many commented sections. The key blocks to configure are the output plugin (where data is written) and the input plugins (what data is collected).
Back up the original and edit the file:
sudo cp /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.orig
sudo vi /etc/telegraf/telegraf.conf
Configure the InfluxDB output plugin (find the existing [[outputs.influxdb]] block and update it):
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "telegraf"
retention_policy = "30days"
write_consistency = "any"
timeout = "5s"
# username = "admin"
# password = "SecurePassword123"
Configure CPU input plugin:
[[inputs.cpu]]
## Whether to report per-cpu stats or only total CPU stats.
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = true
Configure disk input plugin:
[[inputs.disk]]
## By default, telegraf gathers stats for all mountpoints.
## To restrict, set mount points explicitly:
# mount_points = ["/", "/var", "/home"]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
Configure memory input plugin:
[[inputs.mem]]
# No configuration options — collects all memory statistics by default
Configure network interface input plugin:
[[inputs.net]]
## By default, telegraf gathers stats for all network interfaces.
## To restrict, set interface names explicitly:
# interfaces = ["eth0", "eth1"]
ignore_protocol_filters = ["all", "total"]
Add disk I/O statistics:
[[inputs.diskio]]
## By default, telegraf gathers stats for all block devices.
# devices = ["sda", "sdb"]
skip_serial_number = true
Add system load and uptime:
[[inputs.system]]
## no configuration required
Step 6: Enable and Start Telegraf
sudo systemctl daemon-reload
sudo systemctl enable telegraf
sudo systemctl start telegraf
sudo systemctl status telegraf
Watch the Telegraf log to confirm it is successfully writing to InfluxDB:
sudo journalctl -u telegraf -f --no-pager
Look for lines containing Wrote batch of X metrics in Y ms. Errors will appear as could not write to output with an explanation.
Step 7: Verify Data in InfluxDB
Use the InfluxDB CLI to confirm that Telegraf data is flowing into the database:
influx -database telegraf -execute 'SHOW MEASUREMENTS'
You should see measurements like cpu, disk, diskio, mem, net, system. Query a few rows:
# CPU usage for the last 5 minutes
influx -database telegraf -execute
"SELECT mean(usage_user), mean(usage_system) FROM cpu WHERE time > now() - 5m GROUP BY time(1m), cpu"
# Memory available
influx -database telegraf -execute
"SELECT last(available_percent) FROM mem"
# Disk usage
influx -database telegraf -execute
"SELECT last(used_percent), last(path) FROM disk WHERE time > now() - 1m"
Step 8: Open Firewall Ports
If Grafana or other clients are on separate hosts and need access to the InfluxDB HTTP API:
GRAFANA_IP="192.168.1.50"
sudo firewall-cmd --permanent
--add-rich-rule="rule family=ipv4 source address=${GRAFANA_IP}/32 port port=8086 protocol=tcp accept"
sudo firewall-cmd --reload
Step 9: Connect Grafana to InfluxDB
In Grafana, navigate to Configuration → Data Sources → Add data source and select InfluxDB.
- URL:
http://influxdb-server:8086(orhttp://localhost:8086if Grafana is on the same host) - Database:
telegraf - HTTP Method: GET
- Min time interval:
10s(match Telegraf’s collection interval)
Leave User and Password blank if you did not enable InfluxDB authentication. Click Save & Test.
Step 10: Build a Basic Dashboard
Create a new Grafana dashboard and add panels using InfluxQL queries:
CPU Usage Panel (Time series):
SELECT mean("usage_user") + mean("usage_system") AS "CPU Used %"
FROM "cpu"
WHERE ("cpu" = 'cpu-total') AND $timeFilter
GROUP BY time($__interval) fill(none)
Memory Usage Panel (Gauge or Time series):
SELECT last("used_percent") AS "Memory Used %"
FROM "mem"
WHERE $timeFilter
GROUP BY time($__interval) fill(none)
Disk Usage Panel (Bar gauge):
SELECT last("used_percent") AS "Disk Used %"
FROM "disk"
WHERE $timeFilter
GROUP BY "path", time($__interval) fill(none)
Alternatively, import the community Telegraf System dashboard (ID 928 on grafana.com) which provides CPU, memory, disk, and network panels pre-built for Telegraf and InfluxDB.
Conclusion
You now have a fully operational InfluxDB and Telegraf monitoring stack running on RHEL 7. InfluxDB stores time series metrics efficiently with automatic shard management and configurable retention policies that prevent unbounded disk growth. Telegraf collects CPU, memory, disk, and network metrics every 10 seconds and writes them to the telegraf database with zero custom code. Grafana connects to InfluxDB as a data source and renders these metrics as real-time dashboards. From this foundation you can extend Telegraf by enabling additional input plugins for Docker, MySQL, NGINX, Redis, or any of the 200+ available inputs, all with a simple configuration block and a Telegraf service restart.