Visualise Bandwidth utilization in Grafana using SNMP, Telegraf, InfluxDB

Featured Image
Hasan-Uz-Zaman Ashik

Written by Hasan-Uz-Zaman

NMS

December 17, 2021

Grafana, InfluxDB, and Telegraf are popular open-source tools used for time-series data analysis and visualization.

Grafana: Grafana is a popular platform for creating and visualizing time-series data. It provides a web interface for creating and customizing dashboard panels that display time-series data in real-time. Grafana supports multiple data sources, including InfluxDB, and provides a wide range of visualization options, including line charts, bar charts, heat maps, and more.

InfluxDB: InfluxDB is a high-performance time-series database that is optimized for storing and querying time-stamped data. It supports data storage for metrics and events, and provides a SQL-like query language for accessing data. InfluxDB is highly scalable and can handle large amounts of data, making it suitable for use in monitoring and analytics applications.

Telegraf: Telegraf is an agent for collecting and reporting metrics. It can gather data from a wide range of sources, including system metrics, network devices, and cloud services, and send the data to a variety of outputs, including InfluxDB. Telegraf provides a rich set of plugins for collecting data, making it easy to integrate with a wide range of systems and services.

Together, these tools form a powerful stack for time-series data analysis and visualization. Grafana provides a visual interface for analyzing and exploring data, while InfluxDB provides a high-performance database for storing and querying time-series data. Telegraf collects and reports metrics, providing a bridge between data sources and the InfluxDB database.

Because the number of devices in our digitalized world is continually expanding, real-time monitoring and management of those devices is becoming increasingly important. To collect real time data, we need an agent or data collector in server that will collect data stream using TCP, UDP, gRPC etc. In this post, we’ll utilize telegraf to gather bandwidth data from a Cisco IOS XE (Cisco A901-12C-FT-D Version 15.6(2r)SP4 ) router, store them in InfluxDB, and then view in Grafana after some calculations in the mbps format.

All of the tools’ installation instructions are available online.

Step 1: Install telegraf in Ubuntu 16.04 server:

The configuration file is located in this directory: /etc/telegraf

Step 2: Install InfluxDB:

Create database in influxdb: In CMD type

  1. influx
  2. create database:>create database mydb_snmp

> show databases

  1. Use new created database:

>use mydb_snmp

>exit

For the time being, we haven’t set up any usernames or passwords. Blank (ā€œā€) is the default credential.

Install Grafana:

LOG directory:Ā  /var/log/grafana

Plugin directory: /var/lib/grafana/plugins

Fix some directory permission related issue by allowing Grafana user:

Plugin link: https://grafana.com/blog/2020/08/26/popular-community-plugins-that-can-improve-your-grafana-dashboards/

Letā€™s install a plugin in cli: Clock plugin

sudo grafana-cli plugins install grafana-clock-panel

Start Grafana server and enable it to start on boot time with the following command:

Next, check the status of Grafana server using the following command:

sudo systemctl status grafana-server

Let’s allow a port in the firewall:

sudo ufw allow 3000/tcp

Graphana dashboard: http://your_server_ip:3000/login

Documentation on how to set up Grafana to connect to influxdb: https://docs.influxdata.com/influxdb/v1.8/tools/grafana/

Adding user: https://grafana.com/tutorials/create-users-and-teams/?utm_source=grafana_gettingstarted

Plugins: https://grafana.com/grafana/plugins/?type=panel

Finally, we must connect grafana to our InfluxDB database.

Lets begin from our router configuration

Configure router SNMP Community String for server.

We’re declaring a read-only community string here, which we’ll utilize in the telegraf agent so that telegraf can communicate with the device.

Snmp host can be configured in the router as an option. When certain events occur in the router, trap notifications can be sent to the server telegraf agent.

Our server ip must be reachable from the router loopback ip in this case.

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/snmp/command/nm-snmp-cr-book/nm-snmp-cr-s5.html#wp3482803949

 

Configure telegraf:

Inside conf file:

First, we’ll create an agent that will gather data from the router every 250 milliseconds. Then, with the database name mydb_snmp, we define our output database InfluxDB. Following that, we define our router agent that will provide matrix or time series data. SNMP trap setups are not being configured right now. When we configure traps, the device can deliver trap notifications to telegraf.

This is the influx query that will produce bandwidth graf of port Gi 0/2.

 

Bandwidth from routerĀ 

Visualizing data with Grafana has great benefit for several reasons:

Understanding patterns and trends: Grafana provides a visual representation of time-series data, making it easier to identify patterns and trends that might not be immediately apparent from raw data. This can help to uncover insights and inform decision-making.

Improved Communication: Graphical representations of data are often more effective than raw data when it comes to communicating insights and results to stakeholders. Grafana dashboards provide a clear, easy-to-understand visual representation of data that can be shared with others to facilitate communication and collaboration.

Real-time monitoring: Grafana provides real-time data visualization, allowing you to monitor systems and services in real-time. This is particularly useful for identifying and addressing issues before they escalate into larger problems.

Customization and customization: Grafana provides a wide range of customization options, including the ability to create custom dashboard panels, choose from a variety of visualization types, and create alerts based on certain conditions. This allows you to create dashboards that are tailored to your specific needs and use cases.

Integration with other tools: Grafana integrates with a wide range of data sources, including InfluxDB, and supports a variety of plugins for integrating with other tools and services. This makes it possible to create a unified view of data from multiple sources and systems, improving the overall accuracy and comprehensiveness of your data analysis.

Overall, visualizing data with Grafana can help to improve the accuracy and effectiveness of data analysis, support real-time monitoring and decision-making, and enhance communication and collaboration.

You May Also Like…

Hasan-Uz-Zaman

Hasan-Uz-Zaman

Sr. Network Engineer

Zaman is passionate about Network Automation, Cloud Automation, DevOps, SDN, and Web Application development. He has developed network monitoring tools, automation scripts, and web applications, focusing on integrating advanced technologies to optimize and secure operations.

Let's start talking!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *