This article provides a guide demonstrating how to deploy a Telegraf, InfluxDB and Grafana stack on Debian VPS server. Commonly known as TIG, Telegraf, InfluxDB and Grafana collectively make a powerful monitoring stack on your Debian 12 VPS server.
With InfluxDB for data storage, Telegraf for data collection, and Grafana for data visualization, this setup will help you monitor your systems and infrastructure efficiently and securely.
Deploying a Telegraf, InfluxDB and Grafana stack on a Debian 12 VPS involves several steps, from initial server setup to configuring the software. This guide will provide you with a detailed, step-by-step approach to get a Telegraf, InfluxDB and Grafana stack up and running on your Debian system.
Before installing any new software, it’s best practice to update your system packages to the latest versions. This can help avoid conflicts and ensure compatibility.
sudo apt update && sudo apt upgrade -y
InfluxDB is a time-series database, ideal for storing and analyzing large amounts of timestamped data.
To install the latest version of InfluxDB, you need to add the official InfluxData repository.
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian stable main" | sudo tee /etc/apt/sources.list.d/influxdb.list
Now that the repository is added, update your package list and install InfluxDB:
sudo apt update
sudo apt install influxdb
To ensure InfluxDB starts automatically at boot:
sudo systemctl start influxdb
sudo systemctl enable influxdb
You can edit the InfluxDB configuration file to set up things like data retention policies and authentication.
sudo nano /etc/influxdb/influxdb.conf
Make the necessary changes according to your needs and then restart InfluxDB to apply these changes:
sudo systemctl restart influxdb
Install Telegraf to collect and send data and metrics to InfluxDB:
curl -s https://repos.influxdata.com/influxdata-archive_compat.key > 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
sudo nano /etc/telegraf/telegraf.conf
[[outputs.influxdb]]
section and set the URLs to point to your InfluxDB instance, typically urls = ["http://127.0.0.1:8086"]
.database = "telegraf"
(you might need to create this database in InfluxDB).Here is a sample configuration snippet:
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
urls = ["http://localhost:8086"]
database = "telegraf"
timeout = "5s"
username = "telegraf"
password = "metricsmetrics"
sudo systemctl start telegraf
sudo systemctl enable telegraf
Grafana is an open-source platform for monitoring and observability, and it pairs well with InfluxDB for visualizing data.
Add the Grafana APT repository:
sudo apt install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
Update your package list and install Grafana:
sudo apt update
sudo apt install grafana
Enable and start Grafana:
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
http://:3000/
admin
for both username and password.http://localhost:8086
Now that Grafana is set up and connected to InfluxDB, you can create dashboards:
Restrict access to your VPS:
sudo apt install ufw
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 3000/tcp
sudo ufw allow 8086/tcp
sudo ufw reload
Before proceeding, ensure you have a domain name pointing to the IP address of your VPS, as Let’s Encrypt requires a valid domain for certificate issuance.
Certbot is a tool that simplifies the process of obtaining and renewing Let’s Encrypt certificates.
sudo apt install certbot
sudo apt install python3-certbot-nginx
Alternatively, if you prefer using Apache as your reverse proxy, use:
sudo apt install python3-certbot-apache
your_domain.com
with your domain name. sudo certbot --nginx -d your_domain.com
Certbot will modify the Nginx configuration to serve Grafana over HTTPS automatically. Follow the prompts to configure your HTTPS settings, including the redirection of HTTP traffic to HTTPS.
sudo certbot --apache -d your_domain.com
Similar to Nginx, Certbot will handle the modifications required to serve Grafana via HTTPS.
If you are not using a web server like Nginx or Apache as a reverse proxy, you can configure Grafana itself to serve HTTPS:
sudo nano /etc/grafana/grafana.ini
[server]
section in the configuration file, and make the following changes (uncomment lines by removing ;
at the beginning): [server]
protocol = https
http_port = 3000
domain = your_domain.com
cert_file = /etc/letsencrypt/live/your_domain.com/fullchain.pem
cert_key = /etc/letsencrypt/live/your_domain.com/privkey.pem
sudo systemctl restart grafana-server
https://your_domain.com:3000
You should see the Grafana login page served over HTTPS with a secure connection indicated by a padlock icon in the address bar of your browser.
Let’s Encrypt certificates are valid for 90 days. To automate the renewal process:
sudo crontab -e
certbot renew
twice a day: 0 */12 * * * certbot renew --quiet
This cron job will check if the certificate is due for renewal every twelve hours and renew it if necessary.
Your Debian 12 VPS now has InfluxDB and Grafana installed and configured. This setup is ideal for monitoring applications and systems using time-series data. Secure access and regular updates are recommended to maintain the integrity and performance of your monitoring system.
This article provides a guide for how to install Hestia Control Panel on Rad Web Hosting cloud VPS server. What… Read More
This guide will show you how to choose the best dedicated server hosting services for your business or project requirements… Read More
Docker has revolutionized the software development industry by making it possible to package applications into containers. This guide provides 7… Read More
Resellers require access to WHM (Web Host Manager) in order to create and administer cPanel accounts and hosting packages. To… Read More
This article provides a comprehensive guide to mastering LVM management on Ubuntu VPS servers. Introduction Logical Volume Management (LVM) is… Read More
This article provides an overview of the benefits of reseller hosting. Reseller hosting offers numerous benefits. What are the Benefits… Read More