In today’s rapidly evolving digital landscape, monitoring and analyzing system metrics is crucial for businesses to ensure optimal performance and identify potential issues. The TIG (Telegraf, InfluxDB, and Grafana) Stack is an open-source platform that streamlines the collection, storage, visualization, and alerting of system metrics. In this comprehensive guide, we will walk you through the step-by-step process of installing and configuring the TIG Stack on a Rocky Linux 8 based server.
Prerequisites
Before diving into the installation process, let’s ensure that we have all the necessary prerequisites in place:
- A server running Rocky Linux 8.
- A non-sudo user with root privileges.
- SELinux disabled.
- Ensured that everything is updated by running the command:
sudo dnf update
Step 1: Configure Firewall
The first step is to configure the firewall to allow access to the necessary ports for the TIG Stack components. Rocky Linux comes with the Firewalld firewall, which we will be using for this configuration.
To check if the firewall is running, execute the following command:
sudo firewall-cmd --state
If the output shows “running,” the firewall is active.
Next, check the currently allowed services/ports with the following command:
sudo firewall-cmd --permanent --list-services
The output should display a list of services, including “cockpit,” “dhcpv6-client,” and “ssh.”
To allow access to the required ports, run the following commands:
sudo firewall-cmd --permanent --add-port=8086/tcp sudo firewall-cmd --permanent --add-port=3000/tcp
Finally, reload the firewall to apply the changes:
sudo systemctl reload firewalld
Step 2: Install InfluxDB
InfluxDB is a powerful open-source time-series database that serves as the storage backend for the TIG Stack. To install InfluxDB, we need to create a repository file for it.
Create and open the influxdb.repo file for editing:
sudo nano /etc/yum.repos.d/influxdb.repo
Paste the following code into the file:
[influxdb] name = InfluxDB Repository - RHEL $releasever baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdb.key
Save the file and exit the text editor.
Now, we can proceed with the installation. Run the following command:
sudo dnf install influxdb2
Once the installation is complete, start and enable the InfluxDB service:
sudo systemctl enable influxdb sudo systemctl start influxdb
Step 3: Create InfluxDB Database and User Credentials
To store the data collected by Telegraf, we need to set up an InfluxDB database and user credentials. The InfluxDB command-line tool, influx, allows us to interact with the InfluxDB server.
Run the following command to perform the initial configuration for InfluxDB:
influx setup
You will be prompted to enter the primary username, password, organization name, primary bucket name, and retention period. Set these values according to your preferences.
Once the initial setup is complete, you can create a new token for secure access to the database. Click on the “Data” option in the left sidebar and navigate to the “Tokens” section. Generate a new token and save it for later use.
With the InfluxDB setup complete, we can now proceed to install Telegraf.
Step 4: Install Telegraf
Telegraf is an open-source metrics collection agent that collects and sends data and events from various sources, including databases, systems, and IoT sensors. It integrates seamlessly with InfluxDB and other output plugins.
Since Telegraf and InfluxDB share the same repository, we can install Telegraf directly using the following command:
sudo dnf install telegraf
Once the installation is finished, enable and start the Telegraf service:
sudo systemctl enable telegraf sudo systemctl start telegraf
Telegraf utilizes a plugin-driven architecture, allowing you to configure different input, processor, aggregator, and output plugins. The configuration file for Telegraf is located at /etc/telegraf/telegraf.conf.
Open the file for editing:
sudo nano /etc/telegraf/telegraf.conf
In the configuration file, you can specify the output plugins to send data to InfluxDB. Locate the [[outputs.influxdb_v2]] section and uncomment it by removing the # symbol at the beginning of the lines.
Replace the placeholder values with the appropriate details, including the InfluxDB token, organization name, and bucket name.
Save the changes and exit the text editor.
To apply the new configuration, restart the Telegraf service:
sudo systemctl restart telegraf
Step 5: Verify Telegraf Stats in InfluxDB
Before proceeding further, let’s verify if Telegraf stats are correctly collected and stored in InfluxDB.
Open your web browser and access the InfluxDB UI by entering the following URL: http://<serverIP>:8086/.
Navigate to the “Data” section and select your bucket from the list. Click on the values under the _measurement filter to explore the available metrics. You should see a graph displaying the collected data.
By confirming that the data is being passed correctly, we can proceed to install Grafana.
Step 6: Install Grafana
Grafana is an open-source data visualization and monitoring suite that allows you to create beautiful dashboards and analyze metrics from various sources. To install Grafana, we need to add the Grafana repository.
Create and open the grafana.repo file for editing:
sudo nano /etc/yum.repos.d/grafana.repo
Paste the following code into the file:
[grafana] name=grafana baseurl=https://packages.grafana.com/oss/rpm repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packages.grafana.com/gpg.key sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt
Save the file and exit the text editor.
Now, we can proceed with the installation. Run the following command:
sudo dnf install grafana
Once the installation is complete, start and enable the Grafana service:
sudo systemctl start grafana-server sudo systemctl enable grafana-server
Step 7: Set Up Grafana Data Source
Launch your web browser and access the Grafana login page by entering the following URL: http://<serverIP>:3000/.
Log in using the default username and password: admin/admin. You will be prompted to set a new password.
Once logged in, click on the “Add your first data source” button. Select “InfluxDB” as the type of data source.
On the configuration page, enter the following details:
- URL:
http://localhost:8086 - Access:
Server (Default) - Basic Auth Details:
- User:
<your InfluxDB username> - Password:
<your InfluxDB password> - InfluxDB Details:
- Organization:
<your InfluxDB organization> - Token:
<your InfluxDB token> - Default Bucket:
<your InfluxDB bucket>
Click on the “Save & Test” button to verify the connection to the InfluxDB data source.
Step 8: Set Up Grafana Dashboards
The next step is to create Grafana dashboards to visualize the collected metrics. Let’s start by creating a new panel.
Click on the “+” sign and select “Dashboards” to open the Dashboard Create screen.
On the next page, click on the “Add an empty panel” button. This will launch the Query Editor.
In the Query Editor, enter the desired Flux query to retrieve the metrics you want to display. You can customize the query based on your specific requirements.
Once you have defined the query, give the panel a title and specify the axis label, time range, and other settings as needed.
Click on the “Apply” button to save the panel configuration.
Repeat the process to create additional panels for different metrics of interest. Grafana offers a wide range of visualization options, allowing you to create informative and visually appealing dashboards.
Once you have created all the desired panels, click on the “Save Dashboard” button to save the dashboard. Give it a meaningful name and click “Save” again. You can now view and access your dashboard from the Grafana homepage.
Step 9: Configure Alerts and Notifications
To ensure timely detection of critical events or anomalies, it is essential to set up alerts and notifications in Grafana. This allows you to receive alerts when certain conditions are met or thresholds are exceeded.
Before setting up alerts, we need to configure the SMTP service for email notifications. Open the grafana.ini file for SMTP configuration:
sudo nano /etc/grafana/grafana.ini
Locate the [smtp] section and uncomment the relevant lines. Enter the SMTP server details, including the host, username, password, and other required information.
Save the changes and exit the text editor.
Restart the Grafana server to apply the SMTP settings:
sudo systemctl restart grafana-server
Now, let’s set up the email notification channel in Grafana. Click on the alert icon in the Grafana interface and select “Notification channels.” Click on the “Add Channel” button.
Enter the necessary details for the email notification channel, including the recipient email address and the SMTP configuration.
Click on the “Test” button to ensure that the email settings are working correctly. Once verified, click “Save” to create the channel.
To create an alert, navigate to the desired dashboard and click on the panel you want to monitor. From the panel menu, select “Edit” and then click on the “Alert” tab.
Configure the alert settings, including the evaluation interval, conditions, and notification channels. You can define multiple conditions and specify different actions for each condition.
Save the alert rule, and Grafana will start monitoring the specified metrics and trigger notifications according to the defined conditions.
Conclusion
Congratulations! You have successfully installed and configured the TIG Stack (Telegraf, InfluxDB, and Grafana) on your Rocky Linux 8 based server. With this powerful monitoring and visualization platform in place, you can now efficiently collect, store, analyze, and visualize system metrics from various sources.
The TIG Stack provides a comprehensive solution for monitoring and managing system performance, allowing you to make data-driven decisions and ensure the optimal operation of your infrastructure.
If you have any questions or need further assistance, feel free to reach out to the experts at Shape.host. They offer reliable and scalable SSD Linux VPS hosting services to help businesses thrive in the digital landscape.