How to Install Grafana TIG stack Ubuntu
Note: Tested and Validated Procedure on 12th October 2023
A Grafana TIG stack is a technology stack that stands for Telegraf, InfluxDB, and Grafana. It is commonly used for monitoring and visualizing time-series data in real-time.
Need help setting up Grafana SSL (HTTPS) – click here
Telegraf is an open-source data collection agent that collects and sends metrics and events to InfluxDB. InfluxDB is a time-series database that stores and manages the data collected by Telegraf. Grafana is a data visualization and monitoring platform that connects to InfluxDB to provide real-time visualizations and dashboards for the collected data.
Together, these three components create a powerful real-time platform for monitoring and visualizing time-series data. The TIG stack is particularly popular in DevOps and IT operations teams as it allows for monitoring various infrastructure components and application performance metrics.
In this demo, I will install the Grafana server on Ubuntu. Specifically, this will be a TIG stack, you will learn how to Set Up Grafana Monitoring Dashboards with Telegraf and InfluxDB Backend.
The power of a TIG Stack: Monitor Your Data Sources with Ease
The grafana tig stack is one of the most popular and powerful open-source tools available for monitoring a wide panel of data sources. This stack includes Telegraf, InfluxDB, and Grafana and can help streamline your data collection, aggregation, and reporting processes.
What is Telegraf?
Telegraf is a server agent used for collecting and aggregating data and reporting metrics. It is a highly scalable application that allows users to easily access metrics from the system. With Telegraf, you can monitor, store, and analyze data from any source in any format.
What is InfluxDB?
InfluxDB is an open-source database that stores data and exposes it to the Grafana dashboard. It can automate sensors and devices in real-time and provide insights into the performance of your systems and applications. With InfluxDB, you can quickly and easily access and monitor your data sources, ensuring that you have the data you need to make informed decisions.
What is Grafana?
Grafana is an open-source data visualization tool that supports various time series data stores, including Prometheus, Elasticsearch, and InfluxDB. It helps create beautiful, interactive dashboards for easy data exploration and troubleshooting. With Grafana, you can quickly and easily visualize your data sources in real-time.
You can easily monitor your data sources by leveraging the powerful grafana tig stack. With Telegraf, Grafana, and InfluxDB, you can quickly and easily collect, aggregate, and analyze data from any source. With the TIG stack, you can be confident that your data is secure, accurate, and up-to-date.
How to Install a TIG Stack
Ensure that you have a Linux Ubuntu 22.04 server available.
Step 1 – Update Ubuntu Base System
Type the following to update the base repos
apt update -y
You may want to take the time to update your operating system at this point (optional)
apt upgrade -y
Now prep the server to install all the required software
apt install gnupg2 software-properties-common -y
Step 2 – Install Grafana
This stage will install all the required packages for Grafana. If you hit an error here, its likely the gpg key has been rotated by Grafana. Check out this site for more information.
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Now update your repo’s
apt update -y
You will notice that apt is now looking at the grafana repo
apt install grafana -y systemctl start grafana-server systemctl enable grafana-server
You can check the status of the Grafana service using
systemctl status grafana-server
Step 3 – Install InfluxDB
Now add the influxDB repository to the Ubuntu server. This repo is not available by default and must be added manually.
Use this one-liner to install everything you need.
You can check the latest versions of InfluxDB on the official website.
wget -q https://repos.influxdata.com/influxdata-archive_compat.key echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list apt-get update && sudo apt-get install influxdb2 apt-get install influxdb -y
Now start and enable InfluxDB
systemctl enable --now influxdb systemctl start influxdb
You can check the status of the InfluxDB service using
systemctl status influxdb
Step 4 – Configure InfluxDB
Login into the Influx shell by typing
Now create a database for Telegraf
create database telegrafdb; create user telegraf with password 'my-super-strong-password'; grant all on telegrafdb to telegraf;
You can check everything is configured by typing
Now exit from InfluxDB shell
Step 5 – Install Telegraf
This one-liner will install the SHA256-verified version of Telegraf
wget -q https://repos.influxdata.com/influxdata-archive_compat.key echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list sudo apt-get update && sudo apt-get install telegraf
Create a default telegraf config
telegraf config -input-filter cpu:mem:swap:system:processes:disk -output-filter influxdb > /etc/telegraf/telegraf.conf
Add your influxDB database configuration by using nano, vim, or vi.
Make sure your find the correct section in the telegraf.conf file
[[outputs.influxdb]] urls = ["http://127.0.0.1:8086"] database = "telegrafdb" username = "telegraf" password = "my-super-strong-password"
Now start and enable the Telegraf service
systemctl enable --now telegraf systemctl start telegraf
You can check the status of the Telegraf service using
systemctl status telegraf
Step 6 – Setup Grafana Data Source
Next, you will need to access the Grafana dashboard and add a data source to display the InfluxDB and Telegraf metrics.
You can access the Grafana Dashboard using the URL http://your-server-ip:3000/. You should see the Grafana login page:
Provide default username as admin and password as admin then click on the login button. You should see the password reset screen:
Note: Since Grafana version 7.2.2, many users have reported the default admin and password does not work. If this is the case, type the following on your server command prompt:
grafana-cli admin reset-admin-password mynewpassword
Add your new password and click the Submit button to change the default password. You should see the Grafana dashboard on the following page:
To add the data source, click on Add your first data source. You should see the following screen:
Search for InfluxDB and click on the Select button. You should see the following page:
Set the name of the InfluxDB, select InfluxQL in Query Language, define the URL of the InfluxDB data source, provide InfluxDB database details, and click on the Save & Test button. Once the test is successful, you should see the following page:
Step 7 – Setup Grafana Dashboard
At this point, we have added InfluxDB as a data source to the Grafana server. Next, you will need to import the Grafana dashboard.
On the Grafana Dashboard, click on the ‘+’ menu on the left panel and click the ‘Import‘ button. You should see the following page:
Type Grafana ID 5955 and click on the Load button to load the dashboard as shown below.
Select InfluxDB and click on the Import button. You should see the Grafana Dashboard showing the system metrics collected by the Telegraf agent: