How to install a TIG stack on Ubuntu 18.04

A TIG stack is a powerful tool for monitoring your Linux server. Jack Wallen walks you through the installation of this admin-friendly server stack.

tuxnetworkhero.jpg
Image: Jack Wallen

System admins are always looking for ways to gain access to more and better information about the servers they manage. To that end, they'll go to just about any length for the right tool. If the servers in question are the Linux sort, there are a host of options available for the producing and displaying of data. One such option is a combination of tools, called a TIG stack.

TIG stands for:

  • Telegraf - An agent for collecting, processing, aggregating, and producing metrics.
  • InfluxDB - An open source database, optimized for large amounts of time-stamped data.
  • Grafana - An open source data visualization tool.

When combined, these services make for an incredibly powerful tool that gives the admin real-time information about a server. I'm going to walk you through the process of installing a TIG stack on the Ubuntu Server 18.04 platform.

SEE: Network security policy (Tech Pro Research)

What you need

All you need to make this happen is an Ubuntu Server 18.04 and a user account with sudo privileges.

Update/upgrade

Before we install the TIG stack, let's update and upgrade Ubuntu. Know that, if the upgrade includes the kernel, you need to restart the server. Because of this, make sure to run the update/upgrade at a time when a server reboot is possible. With that said, open a terminal and issue the commands:

sudo apt-get update
sudo apt-get upgrade -y

Once that completes, reboot the server (if necessary) and prepare to install.

Install the database

The first step is the installation of the database. To do this, open a terminal window and issue the following commands:

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-releaseecho "deb https://repos.influxdata.com/${DISTRIB_ID,,}
${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install influxdb -y

With that installation complete, start and enable the database with the commands:

sudo systemctl start influxdb
sudo systemctl enable influxdb

Before we move on to the next installation, let's create the database with the commands:

influx
create database telegraf
create user telegraf with password 'PASSWORD'

Where PASSWORD is a unique, strong password.

Install and configure Telegraf

Next, we install the Telegraf agent. This is accomplished with the following command:

sudo apt install telegraf -y
Start and enable Telegraf with the commands:
sudo systemctl start telegraf
sudo systemctl enable telegraf

We now need to configure the Telegraf agent. Out of the box, it comes with a default configuration file. We'll rename that with the following command:

sudo mv /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.DEFAULT.conf

Create a new configuration file with the command:

sudo nano /etc/telegraf/telegraf.conf

Paste the following into the new file:

# Global Telegraf Agent Configuration
[agent]
  hostname = "HOSTNAME"
  flush_interval = "15s"
  interval = "15s"


# Input Plugins
[[inputs.cpu]]
    percpu = true
    totalcpu = true
    collect_cpu_time = false
    report_active = false
[[inputs.disk]]
    ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]

# Output Plugin InfluxDB
[[outputs.influxdb]]
  database = "telegraf"
  urls = [ "http://127.0.0.1:8086" ]
  username = "telegraf"
  password = "PASSWORD"

where HOSTNAME is the hostname of the hosting machine and PASSWORD is the password you created for the influxdb.

Save and close that file.

We now have to run a command to re-configure our newly created config file (so that it meets the Telegraf requirements). That command is:

telegraf config -input-filter cpu:mem:disk:swap:system -output-filter influxdb > telegraf.conf

Restart telegraf with the command:

sudo systemctl restart telegraf

Install Grafana

The installation of Grafana can be taken care of with the following commands:

sudo curl https://packagecloud.io/gpg.key | sudo apt-key add -
echo 'deb https://packagecloud.io/grafana/stable/debian/ stretch main' > /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install grafana -y

When the installation completes, start and enable Grafana with the commands:

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

Setup your data source

Open a browser and point it to http://SERVER_IP:9000. You will be prompted to log into Grafana. Use the following credentials:

  • User - admin
  • Password - admin

You will then be prompted to change the admin password. Do so, and you will be logged into Grafana. From the main window (Figure A), click Add data source.

Figure A

Figure A

The Grafana main window.


In the resulting window (Figure B), fill out the following information;

where PASSWORD is the password you created for the InfluxDB user.

Figure B

Figure B

Setting up the data source.

Scroll down and click the Save and test button.

Setup the dashboard

Finally, we have to add a dashboard to Grafana. Back at the Grafana main window, click the + button and select Import. In the resulting window (Figure C), paste the following URL in the section labeled Paste Grafana.com dashboard url or id:

https://grafana.com/dashboards/5955

Figure C

Figure C

Adding the new dashboard to Grafana.

Click Load, and the dashboard will automatically load into Grafana. In the resulting window, you must select your InfluxDB server from the Select a InfluxDB data source drop-down list. Click Import and the dashboard will be added to Grafana (Figure D).

Figure D

Figure D

The TIG-fueled Grafana dashboard.


You are ready to start monitoring your server, via the newly installed TIG stack. Happy administrating.

Also see

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.