How to Install TIG stack (Telegraf, Influx and Grafana) on Ubuntu

TIG Stack

A Few Basics First

Prerequisites

  • Ubuntu server
  • Root Privileges

What will we do?

  1. Install InfluxDB
  2. Create Influxdb database and user
  3. Install and Configure Telegraf
  4. Install Grafana
  5. Setup Grafana Data Source
  6. Setup Grafana Dashboard

Step 1: Install InfluxDB

$ sudo apt-get install influxdb influxdb-client
# Unmask influxdb service
$ sudo systemctl unmask influxdb.service
# To launch influxdb:
$ systemctl start influxdb
# To not run influxdb in background
$ influxd -config /etc/influxdb/influxdb.conf
netstat -plntu 
$ systemctl start influxdb
$ influxd -config /etc/influxdb/influxdb.conf

Step 2: Create Influxdb database and user

> create database telegraf
> create user telegraf with password 'pass-telegraf'
> show databases
> show users
influx

Step 3: Install and configure Telegraf

$ sudo apt-get install telegraf
  1. Download the latest Telegraf .deb release from the Telegraf section of the downloads page.
  2. Run the following command (making sure to supply the correct version number for the downloaded file):
sudo dpkg -i telegraf_1.17_amd64.deb
# To have launchd start telegraf now and restart at login:
$ systemctl start telegraf
# If you don’t want/need a background service you can just run:
$ telegraf -config /etc/telegraf/telegraf.conf
  1. Using the Input Plugins to collect metrics.
  2. Using the Processor Plugins to transform, decorate, and filter metrics.
  3. Using the Aggregator Plugins to create and aggregate metrics.
  4. And using the Output Plugins to write metrics to various destinations, including influxdb.
$ cp /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.default
$ vim /etc/telegraf/telegraf.conf
[[outputs.influxdb]]
$ systemctl restart telegraf
$ influx
Connected to http://localhost:8086 version v1.6.4
InfluxDB shell version: v1.6.4
> show databases
name: databases
name
----
_internal
telegraf
> use telegraf
Using database telegraf
> show measurements
name: measurements
name
----
cpu
disk
diskio
mem
processes
swap
system
[[inputs.statsd]]
> show measurements
name: measurements
name
----
cpu
custom_metric
disk
diskio
mem
processes
swap
system

Step 4: Install Grafana

$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
$ sudo apt update
$ apt-cache policy grafana
Output of apt-cache policy grafana grafana:
Installed: (none)
Candidate: 6.3.3
Version table:
6.3.3 500
500 https://packages.grafana.com/oss/deb stable/main amd64 Packages
...
$ sudo apt install grafana
$ sudo systemctl start grafana-server
$ sudo systemctl status grafana-server
Output of grafana-server status● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2019-08-13 08:22:30 UTC; 11s ago
Docs: http://docs.grafana.org
Main PID: 13630 (grafana-server)
Tasks: 7 (limit: 1152)
...
$ sudo systemctl enable grafana-server
Output of systemctl enable grafana-serverSynchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /usr/lib/systemd/system/grafana-server.service.

Hosting Grafana on Different Port

  1. /etc/grafana/grafana.ini
  2. /usr/share/grafana/conf/defaults.ini
  3. /usr/share/grafana/conf/sample.ini

Step 5: Setup Grafana Data Source

Grafana Login Page
Default Grafana Dashboard
InfluxDB data source configurations

Step 6: Setup Grafana Dashboard

Create New Dashboard from Scratch

Grafana Homepage
Grafana New Dashboard
Edit Dashboard
Example dashboard showing cpu usage of user

Import Dashboard from Grafana

Grafana Homepage
Import Grafana Dashboard
Dashboard Setup
Grafana Influxdb Dashboard — Id 5955

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store