How to deploy a telegraf, influxdb and grafana stack on debian vps
Follow this guide to learn how to deploy a telegraf, influxdb and grafana stack on debian vps!

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.


  • A Debian 12 VPS Server
  • Root or sudo privileges
  • Basic familiarity with Linux command line

Step 1: Update Your 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

Step 2: Install InfluxDB

InfluxDB is a time-series database, ideal for storing and analyzing large amounts of timestamped data.

2.1 Add the InfluxData Repository

To install the latest version of InfluxDB, you need to add the official InfluxData repository.

wget -qO- | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/influxdb.list

2.2 Install InfluxDB

Now that the repository is added, update your package list and install InfluxDB:

sudo apt update
sudo apt install influxdb

2.3 Start and Enable InfluxDB

To ensure InfluxDB starts automatically at boot:

sudo systemctl start influxdb
sudo systemctl enable influxdb

2.4 (Optional) Configure 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

2.5 Install Telegraf

Install Telegraf to collect and send data and metrics to InfluxDB:

curl -s > 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] stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf

2.6 Configure Telegraf

  1. Configure Telegraf:Telegraf configurations can be adjusted according to what metrics you want to collect.
    sudo nano /etc/telegraf/telegraf.conf
    • Find the [[outputs.influxdb]] section and set the URLs to point to your InfluxDB instance, typically urls = [""].
    • Set the database name that Telegraf should write to. For example, database = "telegraf" (you might need to create this database in InfluxDB).

    Here is a sample configuration snippet:

    # Configuration for sending metrics to InfluxDB
      urls = ["http://localhost:8086"]
      database = "telegraf"
      timeout = "5s"
      username = "telegraf"
      password = "metricsmetrics"
  2. Start and Enable Telegraf:
    sudo systemctl start telegraf
    sudo systemctl enable telegraf

Step 3: Install Grafana

Grafana is an open-source platform for monitoring and observability, and it pairs well with InfluxDB for visualizing data.

3.1 Add Grafana Repository

Add the Grafana APT repository:

sudo apt install -y software-properties-common wget
wget -q -O - | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

3.2 Install Grafana

Update your package list and install Grafana:

sudo apt update
sudo apt install grafana

3.3 Start and Enable Grafana

Enable and start Grafana:

sudo systemctl enable grafana-server
sudo systemctl start grafana-server

Step 4: Configure Grafana to Connect to InfluxDB

4.1 Access Grafana Web Interface

  • Grafana is now accessible via your web browser. Open http://:3000/
  • The default login is admin for both username and password.

4.2 Add InfluxDB as a Data Source

  • Once logged in, click on “Configuration” (gear icon on the left panel), then “Data Sources.”
  • Click “Add data source,” select “InfluxDB” as the type.
  • Configure the data source:
    • URL: http://localhost:8086
    • Database: The name of your InfluxDB database
    • User & Password: Credentials if you’ve set them in InfluxDB

4.3 Save and Test

  • Click “Save & Test” to ensure Grafana can connect to InfluxDB successfully.

Step 5: Create Dashboards

Now that Grafana is set up and connected to InfluxDB, you can create dashboards:

  • Click “+” on the left panel and select “Dashboard.”
  • Add panels and select the InfluxDB data source to start visualizing your data.

Step 6: Secure Your Setup

6.1 Configure Firewall

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

Step 6.2: Set Up HTTPS for Grafana

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.

Step 6.2.1: Install Certbot

Certbot is a tool that simplifies the process of obtaining and renewing Let’s Encrypt certificates.

  1. Install Certbot:
    sudo apt install certbot
  2. Install the Python Certbot plugin for Nginx (if using Nginx as a reverse proxy):
    sudo apt install python3-certbot-nginx

    Alternatively, if you prefer using Apache as your reverse proxy, use:

    sudo apt install python3-certbot-apache

Step 6.2.2: Obtain an SSL/TLS Certificate

  1. For Nginx:Assuming you are using Nginx as a reverse proxy, replace with your domain name.
    sudo certbot --nginx -d

    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.

  2. For Apache:If using Apache as a reverse proxy, use:
    sudo certbot --apache -d

    Similar to Nginx, Certbot will handle the modifications required to serve Grafana via HTTPS.

Step 6.2.3: Configure Grafana to Serve over 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:

  1. Open Grafana’s Configuration File:
    sudo nano /etc/grafana/grafana.ini
  2. Modify the Protocol, Cert File Paths:Find the [server] section in the configuration file, and make the following changes (uncomment lines by removing ; at the beginning):
    protocol = https
    http_port = 3000
    domain =
    cert_file = /etc/letsencrypt/live/
    cert_key = /etc/letsencrypt/live/
  3. Restart Grafana:To apply the changes, restart Grafana:
    sudo systemctl restart grafana-server

Step 6.2.4: Verify HTTPS Setup

  1. Open your browser and navigate to your domain:

    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.

Step 6.2.5: Set Up Automatic Renewal

Let’s Encrypt certificates are valid for 90 days. To automate the renewal process:

  1. Edit the crontab:
    sudo crontab -e
  2. Add a line to run 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.

Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX and Phoenix, AZ.