InfluxDB (TICK Stack) — Part1

Nidhin kumar
Jan 15 · 7 min read
Image for post
Image for post

Overview

Now we are in the digital age where every second produces data a.k.a. information from your phone, the video you watch, the food you order, the car you drive, the sensor you touch, and of course the article which you read right now everything counts in the digital age. Every small thing counts on :)

So what we do with these pieces of information? To create a better future we use this information.

Okay so, what does the title InfluxDB meant and what is the benefit that i will get by reading this article?

If that’s the question that comes to your mind means then cool down my friend :)

What we are going to do

In this InfluxDB series, we are going to see about time-series platform where we will learn how to process data and send it to InfluxDB and visualize those data.

We will split our InfluxDB series into 2 parts

  • Intro about Timeseries database and basic terminologies of TICK Stack
  • Installation of TICK Stack in Local and VM instance
  • Visualizing system metrics
  • Intro about Telegraf Plugin Architecture
  • Downloading GoLang and cloning Telegraf repo
  • Create a custom Telegraf input plugin to collect Youtube Statistics
  • Create a dropdown menu and add FLUX queries for the data
  • Add a threshold value and create notifications when thresholds met

So let’s begin with Part 1

Part 1 Objectives

  1. What is a time-series database?
  2. What is InfluxDB
  3. Why InfluxDB
  4. What is TICK Stack
  5. Installing TICK Stack in Local Machine
  6. Installing InfluxDB in Digital Ocean (Optional)
  7. Display the System Metrics in Chronograf Dashboard

Don’t worry about the huge list we will take baby steps to understand everything with fun :)

Prerequisite

  • Stable Internet connection
  • Digital ocean account (Optional) — Needed only if you want to host the InfluxDB in Digital Ocean

1. What is a time-series database?

A time-series database (TSDB) is a database optimized for time series data. The time-series data are simply measurements or events which are tracked, monitored, and aggregated over time.

These data could be server metrics, application performance monitoring, network data, sensor data, and many other types of analytics data

A time-series database is built specifically for handling metrics and events that are time-stamped.

Image for post
Image for post
Top 15 time-series databases

Time-series data can be useful for

  • Tracking daily, hourly, or weekly weather data
  • Tracking changes in application performance
  • Tracking network logs

Time-series data can be classified into 2 types

  • Metrics — Measurements gathered at regular time intervals
  • Events — Measurements gathered at irregular time intervals
Image for post
Image for post
Types of Time-series data

Examples of Time-series data

  • Metrics — Health monitoring such as ECG
  • Events — Log Data

2. What is InfluxDB

InfluxDB is an open-source time-series platform that empowers developers to build IoT, analytics, and monitoring software. It is built to handle massive volumes and countless sources of time-stamped data produced by sensors and applications.

3. Why InfluxDB

InfluxDB was built from the ground up to be a time-series database.InfluxDB is part of a comprehensive platform that supports the collection, storage, monitoring, visualization, and alerting of time series data. The whole InfluxData platform is built from an open-source core.

4. What is TICK Stack

TICK Stack is a collection of open source components that combine to deliver a platform for easily storing, visualizing, and monitoring time-series data such as metrics and events.

Image for post
Image for post
TICK Stack

The Components are

  • Telegraf — Agent to collect and report metrics and events
  • InfluxDB — High-performance time-series database
  • Chronograf — The user interface for the platform
  • Kapacitor — Data processing engine that can process, stream and batch data from InfluxDB

The InfluxDB model is different from other time series solutions like Graphite, RRD. InfluxDB has a line protocol for sending time series data which takes the following form

  • measurement-name — string
  • tag-set — a collection of key/value pairs(Where values can be a string)
  • field-set -a collection of key/value pairs (Where values can be int64,float64, bool, or string)
  • timestamp

TICK stack is based on the push model of collecting data

5.Installing TICK Stack in Local Machine

Now we will install the TICK Stack in the Local Machine. Open a terminal in your local machine and install the following based on your OS

I am Installing the TICK Stack in Ubuntu 16.0.4

wget https://dl.influxdata.com/telegraf/releases/telegraf_1.17.0-1_amd64.deb
sudo dpkg -i telegraf_1.17.0-1_amd64.deb
wget https://dl.influxdata.com/influxdb/releases/influxdb2_2.0.3_amd64.deb
sudo dpkg -i influxdb2_2.0.3_amd64.deb
wget https://dl.influxdata.com/chronograf/releases/chronograf_1.8.9.1_amd64.deb
sudo dpkg -i chronograf_1.8.9.1_amd64.deb
wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.5.7-1_amd64.deb
sudo dpkg -i kapacitor_1.5.7-1_amd64.deb

Once the TICK stack is installed you can start the Telegraf, InfluxDB service using the following command

sudo service telegraf start
sudo service influxd start

Now to check everything works smooth you can check the status of the service using the following command

sudo service telegraf status
sudo service influxd status

where you could see a status like below

Image for post
Image for post
Telegraf status
Image for post
Image for post
Influx status

Now we will connect the Telegraf agent to InfluxDB service to push the metrics and events for that navigate to the following path

cd /etc/telegraf

Where you could see 3 files below

Image for post
Image for post
Telegraf configuration files

Now open the telegraf.conf file in any of the text editor and scroll down to OUTPUTS Plugin and uncomment the highlighted lines

Image for post
Image for post
Output Plugins

Save the telegraf.conf file and restart the telegraf service using the below command

sudo service telegraf stop
sudo service telegraf start

Now we will open the influx CLI to check whether the telegraf database is available or not. Open the terminal and type influx and type the following command to see the list of databases

show databases

which will list the databases now use the following command to make the telegraf database as the default one use telegraf

Now we can see the list of tables available in the telegraf database using the command show measurements

Image for post
Image for post
influx DB

use the command exit if you are done with influx :)

Now we will visualize the metrics in a dashboard (Chronograf).To visualize the dashboard make sure the Chronograf service is running or not

sudo service chronograf status

If it is not running then start the service. Now open your browser and in the search bar type the command localhost:8888 which will open the Chronograph dashboard like below

Image for post
Image for post
Chronograf

Now we have installed the TICK stack in our local machine

6. Installing InfluxDB in Digital Ocean

Now we will install the InfluxDB in Digital Ocean as a VM instance Open Digital Ocean and create a new droplet like below

Image for post
Image for post
Droplet creation

Once the droplets are selected fill in the basic information of the location and the root password and create the Droplet

Image for post
Image for post
Droplet creation

Once the droplet is created copy the Public IP address and open a terminal in your local machine and connect to the Droplet using the command

ssh root@public_ip_address

Enter the password which you have entered while creating a droplet. Now you would have connected to the droplet from your local machine

Image for post
Image for post
SSH Connection

Once connected install the InfluxDB in the Droplet using the below command

wget https://dl.influxdata.com/influxdb/releases/influxdb2_2.0.3_amd64.deb
sudo dpkg -i influxdb2_2.0.3_amd64.deb

Once the InfluxDB is installed start the influxd service using the command influxd

Image for post
Image for post
influxd service

Now you could see the influxd service running. Open your browser and paste the public IP address of your Droplet in the port 8086 PUBLIC_IP:8086

7. Display the System Metrics in Chronograf Dashboard

Now we will see the System metrics in the chronograph which is running in our local machine

Now we will see how we can connect the Telegraf from our local machine to which will send the metrics to the InfluxDB which is installed in the Digital Ocean Droplet

Congratulations!

You have learned what is time-series database and how to install a TICK stack in the local machine as well as in a VM instance.

In the next part, we will learn about Telegraf architecture and create a custom input plugin till then Happy Learning :)

CodingTown

Today a Reader, Tomorrow a Leader

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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