How to Set Up a Monitoring Dashboard with Grafana, InfluxDB, and Telegraf on a Red Hat-based Linux Server
How to Set Up a Monitoring Dashboard with Grafana, InfluxDB, and Telegraf on a Red Hat-based Linux Server
Monitoring your systems effectively is key to maintaining performance and resolving issues promptly. This guide walks you through setting up Grafana, InfluxDB, and Telegraf on a Red Hat-based Linux server. These tools form a robust monitoring stack, perfect for real-time insights.
1️⃣ Install InfluxDB
Step 1: Add InfluxDB Repository
# influxdata-archive_compat.key GPG fingerprint:
# 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E
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 InfluxDB
sudo yum install -y influxdb
Step 3: Start and Enable InfluxDB
sudo systemctl start influxdb
sudo systemctl enable influxdb
Step 4: Verify InfluxDB Installation
Access the InfluxDB UI at http://<your_server_ip>:8086
and create an organization, a bucket (e.g., telegraf
), and an API token for authentication.
2️⃣ Install Telegraf
Step 1: Add Telegraf Repository
# influxdata-archive_compat.key GPG fingerprint:
# 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E
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 Telegraf
sudo yum install -y telegraf
Step 3: Configure Telegraf to Send Metrics to InfluxDB
Edit the Telegraf configuration file:
sudo vi /etc/telegraf/telegraf.conf
Add the following under [[outputs.influxdb]]
:
You get token when you login to influxdb
[[outputs.influxdb]]
urls = ["http://localhost:8086"]
token = "your_influxdb_api_token"
organization = "your_org_name"
bucket = "telegraf"
Step 4: Start and Enable Telegraf
sudo systemctl start telegraf
sudo systemctl enable telegraf
3️⃣ Install Grafana
Step 1: Add Grafana Repository
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-11.4.0-1.x86_64.rpm
Step 2: Install Grafana
sudo yum install -y grafana
Step 3: Start and Enable Grafana
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Step 4: Access Grafana
Open Grafana in your browser at http://<your_server_ip>:3000
. The default credentials are:
Username:
admin
Password:
admin
4️⃣ Configure Grafana to Use InfluxDB as a Data Source
In the Grafana UI, navigate to Configuration > Data Sources.
Click Add Data Source and select InfluxDB.
Fill in the following details:
Token: Use the API token created in InfluxDB.
Organization: Your InfluxDB organization name.
Bucket:
telegraf
Click Save & Test to confirm the connection.
5️⃣ Create Dashboards in Grafana
Go to Dashboards > New Dashboard.
Add panels for metrics like CPU, memory, and disk usage by querying InfluxDB.
Example Query for CPU:from(bucket: "telegraf") |> range(start: -1h) |> filter(fn: (r) => r["_measurement"] == "cpu") |> filter(fn: (r) => r["_field"] == "usage_user") |> filter(fn: (r) => r["cpu"] == "cpu-total")
Customize panels to suit your needs and save the dashboard.
6️⃣ Verify the Monitoring Setup
Generate system activity to test log collection and visualization.
Ensure that metrics are flowing into InfluxDB and are displayed on Grafana.
7. Troubleshooting Tips
If you encounter issues during the setup or while monitoring, consider the following troubleshooting steps:
InfluxDB Not Running:
Check the status of InfluxDB with:sudo systemctl status influxdb
If it’s not running, restart it:
sudo systemctl start influxdb
Telegraf Not Sending Metrics:
- Verify Telegraf's status:
sudo systemctl status telegraf
- Check the Telegraf logs for errors:
journalctl -u telegraf -f
Ensure the InfluxDB URL, token, and bucket in the Telegraf config are correct.
- Grafana Not Displaying Data:
Confirm the data source configuration in Grafana is correct.
Check if the queries you are using in Grafana panels are returning data.
Examine Grafana logs for any errors:
sudo journalctl -u grafana-server -f
Authorization Issues:
If you receive unauthorized errors, ensure that:The API token in Telegraf is valid and has the necessary permissions.
The organization and bucket names are spelled correctly in the configuration.
Conclusion
By combining Telegraf, InfluxDB, and Grafana, you now have a comprehensive monitoring solution on your Red Hat-based Linux server. This setup provides real-time insights into system performance, making it easier to maintain and troubleshoot infrastructure.
Feel free to share your feedback or ask any questions. Happy monitoring! 🎉
#Grafana #InfluxDB #Telegraf #Linux #DevOps #Monitoring