How To Setup Grafana Monitoring with Telgraf & InfluxDB
Tags: Technology, Grafana, Programming, Monitoring, DevOps

Grafana is an open-source monitoring tool that can be used to monitor various kinds of things in an IT company.

Namely, it includes, server usage monitoring like CPU, memory, disk, network loads, endpoints, and many.

But the main reason of using this tool is that it provides a wide variety of visualization dashboard which makes very easy to understand for a non-technical person also.

Grafana offers many dashboards which includes System Overview, Elasticsearch logs, Prometheus monitoring, world ping, etc

Yes, if you want to use more features then you have to pay for Grafana Cloud which provides extended support and features.

Let us dive into the installation process for the ubuntu 20.04 version.

Along with Grafana we also have to install two tools that will have to save data and send data to the Grafana dashboard.

InfluxDB

Telegraf

Influx dB Installation (Ubuntu 15.04+. Debian 8+):

sudo apt-get update && sudo apt-get install influxdb sudo systemctl unmask influxdb.service sudo systemctl start influxdb

The config file of Influx dB will be located at /etc/influxdb/influxdb.conf

sudo systemctl status influxdb

The screenshot is taken by the author

By default, Influx dB runs on 8086 Port. To access the shell fire “influx” on the terminal.

CREATE DATABASE SHOW DATABSES USE <db_name>

Telegraf Installation

sudo apt-get update

sudo apt-get install apt-transport-https

sudo apt-get install telegraf

sudo systemctl start telegraf

sudo systemctl status telegraf

The screenshot is taken by the author

Now create an admin account for the Influx dB server Go to your influx shell and follow these queries

CREATE USER admin WITH PASSWORD ‘root’ WITH ALL PRIVILEGES

SHOW USERS

Then, to enable http authentication for influx dB Server, Head over to /etc/influxdb/influxdb.conf and edit the following lines.

# Determines whether HTTP endpoint is enabled.

enabled = true

# The bind address used by the HTTP service.

bind-address = “:8086”

# Determines whether user authentication is enabled over HTTP/HTTPS. auth-enabled = true

Configure HTTP authentication on Telegraf

Go to the configuration file of Telegraf, located at /etc/telegraf/telegraf.conf. Modify the changes as mentioned below

## HTTP Basic Auth

username = “telegraf”

password = “root”

Note: To perform the above step you need to create a user in Influx dB same as we have created for admin in the above steps.

sudo systemctl restart influxdb

sudo systemctl restart telegraf

sudo journalctl -f -u telegraf.service

Configure Telegraf for HTTP

# Configuration for sending metrics to InfluxDB

[[outputs.influxdb]] urls = [“https://127.0.0.1:8086"]

## Use TLS but skip chain & host verification

insecure_skip_verify = true

Grafana Dashboard Installation



sudo apt-get upgrade

sudo wget -q -O —

sudo apt-get install grafana sudo apt-get updatesudo apt-get upgradesudo wget -q -O — https://packages.grafana.com/gpg.key | apt-key add—sudo apt-get install grafana If you are using systemd, Grafana created a grafana-server service for you. To ensure it, run the following command:

sudo ls /usr/lib/systemd/system/grafana-server.service

cat /usr/lib/systemd/system/grafana-server.service

sudo systemctl start grafana-server

sudo systemctl status grafana-server

The screenshot is taken by the author

The default port for Grafana is 3000. The default login is “admin” “admin”

The screenshot is taken by the author

Your Grafana Setup is done. Now you can manage dashboards, alerts, and many more things as per your use case.

I will be adding more articles regarding Grafana in the future and in the meantime explore on your own and please give this article a clap so that it helps the algorithm.

Thanks.