Part 3 of Our Network Monitoring Series
In our first post, we set up a subnet scanner that identified SNMP-enabled servers. Then, in Part 2, we configured InfluxDB to store our collected metrics. Now, with data continuously streaming into InfluxDB, it’s time to turn numbers into insights with Grafana dashboards.
Grafana is a powerful visualization tool that works seamlessly with InfluxDB, helping us monitor the network’s health, identify trends, and detect issues in real time. In this post, we’ll walk you through connecting Grafana to InfluxDB, creating dashboards, and setting up visualizations for key metrics.
Step 1: Installing and Configuring Grafana
Grafana provides pre-built packages for most Linux distributions. Follow these steps to install and set it up.
Install Grafana:
For Ubuntu/Debian
Copied!sudo apt-get install -y grafana
For CentOS/RHEL
Copied!sudo yum install -y grafana
Start Grafana:
Copied!sudo systemctl start grafana-server sudo systemctl enable grafana-server
Access Grafana:
Log in with the default credentials (admin
/ admin
). You’ll be prompted to change the password.
Open your browser and go to http://localhost:3000
.
Step 2: Connecting Grafana to InfluxDB
Once inside Grafana, follow these steps to connect it to InfluxDB.
- Add a New Data Source:
- In Grafana, navigate to Configuration > Data Sources and click Add Data Source.
- Select InfluxDB and configure the following:
- URL:
http://localhost:8086
- Database:
network_metrics
- Auth: Set Basic Auth to on and use your InfluxDB token or login credentials.
- Organization and Bucket: Enter the organization and bucket you set up in InfluxDB (e.g.,
network_metrics
).
- URL:
- Test the Connection to ensure Grafana can communicate with InfluxDB.
Step 3: Creating a Dashboard
With InfluxDB connected, you’re ready to create your first dashboard in Grafana.
Add a Dashboard:
- Go to Create > Dashboard and click Add New Panel.
Define a Query:
- In the query editor, select Flux or InfluxQL as the query language (based on your InfluxDB setup).
- Example Query for CPU Load:fluxCode kopiëren
Copied!from(bucket: "network_metrics") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "cpu_load") |> filter(fn: (r) => r._field == "value")
Add Visualizations:
- Line Graph: Use this to display trends over time for metrics like CPU and memory.
- Gauge: A gauge can provide a real-time snapshot of network input/output.
- Table: Use tables to list metrics from multiple servers.
Customize Your Panels:
- Set up custom labels (e.g., CPU usage, memory usage).
- Configure thresholds (e.g., warning at 80%, critical at 90%).
Save and Organize the Dashboard:
- Save your dashboard, giving it a descriptive name such as “Network Monitoring Dashboard.”
- Organize panels to display real-time data from your servers in a single view.
Step 4: Setting Up Alerts
To get notified about network issues before they become critical, set up alerts in Grafana.
Define Alert Conditions:
- Go to any panel and open Edit > Alert.
- Define conditions like CPU load > 80% or Network traffic > X Mbps.
Configure Notifications:
- Go to Alerting > Notification Channels and add channels such as email, Slack, or webhook.
- Select a severity level for each alert, so you know what requires immediate attention.
Summary
In this post, we visualized our SNMP data, making it easy to monitor network health, spot trends, and react to potential issues. With Grafana, we’re now equipped to view and act on critical network insights, ensuring our infrastructure’s performance and stability.