InfluxDB 2.X — A quick hands-on intro to timeseries DB

Shashank Vivek
4 min readJan 10, 2021

In today’s world where data is the new oil, we are often lured into collecting all forms of data. Once we have those data, the next step comes as the visualization of the data to make some sense out of it. One such data which is associated with time stamps are stored in timeseries database (TMDB).

In TMDB, the time is treated as first class citizen. Recording each and every change to the system as a new, different row is what makes time-series data so powerful. It allows us to measure and analyze change: what has changed in the past, what is changing in the present, and what can we forecast changes may look like in the future.

Now, the first question comes into our mind is

Why so we need a dedicated timeseries database ? Can’t we use any existing DBs ?

The reason has been explained here very clearly.

Note: InfluxDB is NoSQL based TMDB, there are TMDBs which are based on relational model such as TimescaleDB.

Before we proceed further, I would like to highlight that there are breaking changes if you are coming from 1.x to 2.x version. Covering all the differences is a different topic all together which should be handled separately. One major thing which you’ll notice is introduction of flux in 2.X.

As a part of exercise to this article, we’ll be :

  • Quickly setting up the InfluxDB2.0 on our local machine
  • Populate some sample data
  • Query using Flux

1. Create service using docker-compose with docker image on port as "8099":

Make sure you have docker on your machine to follow through this article

Once we have created above file, run below command to run the service:

docker-compose up

To check the service, use http://localhost:8099

2. Setup user details:

Click on “Get Started” and fill below details. With 2.x version, a user token based authentication has been added in InfluxDB. I’ll be creating a separate article to cover API based queries.

In this demo, I am using below details.

Organization Name: test-org

Bucket Name: test-bucket

After clicking on “Continue” , we will be required to complete the setup. Select “Quick Start” option to do quick setting and skip setup complexities.

As soon as the setup is done, we’ll land on the below dashboard page:

3. Check the available “Buckets”

A bucket is a named location where time series data is stored. All buckets have a retention policy, a duration of time that each data point persists. A bucket belongs to an organization.

To quickly verify the bucket we have created earlier, we can navigate to

Data > Buckets
Navigation to buckets

4. Load sample data into bucket

To load a sample data into influxDB, we can get into the bucket by clicking on “Bucket Name” . On the next screen, we can see bunch of options to play around.

We’ll be loading the data using flux command. To run the flux commands, click on “Script Editor” as shown below:

Once the editor is opened, we will run below command

A successfully loaded data will immediately show us a plotted graph.

Please note that we have mentioned the bucket and org name as created earlier.

Now if we go back to “Query Builder” and refresh the page, we’ll be seeing all the fields on which can apply filtering.

A custom query built for demo

The above graphical filtering can be translated into

That’s it for a quick setup of InfluxDB 2.X on your local machine. I hope this article will help someone new to InfluxDB TMDB.

If you liked what you read, please 👏 👏 clap 👏 👏 few times to encourage me 🐼 for writing such articles. Cheers !!

--

--