InfluxDB | Installation | How To Use | Time Series Database ?

In this post, You can know about Time Series Databases. InfluxDB is most popular and useful time series database. You can find Installation and getting started guidelines in this post.

What is a Time Series Database?

A Time Series Database (TSDB) is a database optimized for time-stamped or time series data. Time series data are simply measurements or events that are tracked, monitored, downsampled, and aggregated over time. This could be server metrics, application performance monitoring, network data, sensor data, events, clicks, trades in a market, and many other types of analytics data.

A Time Series Database is built specifically for handling metrics and events or measurements that are time-stamped. A TSDB is optimized for measuring change over time. Properties that make time series data very different than other data workloads are data lifecycle management, summarization, and large range scans of many records.

Why is a Time Series Database Important Now?

Time Series Databases are not new, but the first-generation Time Series Databases were primarily focused on looking at financial data, the volatility of stock trading, and systems built to solve trading. Today, everything that can be a component is a component. In addition, we are witnessing the instrumentation of every available surface in the material world—streets, cars, factories, power grids, ice caps, satellites, clothing, phones, microwaves, milk containers, planets, human bodies. Everything has, or will have, a sensor. So now, everything inside and outside the company is emitting a relentless stream of metrics and events or time series data. This means that the underlying platforms need to evolve to support these new workloads—more data points, more data sources, more monitoring, more controls.

Independent Ranking of Top 15 Time Series Databases

db ranking
Source: https://www.influxdata.com/

Why InfluxDB Time Series Database Unique?

The whole InfluxData platform is built from an open source core. InfluxData is an active contributor to the Telegraf, InfluxDB, Chronograf  and Kapacitor (TICK) projects as well as selling InfluxEnterprise and InfluxCloud on this open source core. The InfluxDB data model is quite different from other time series solutions like Graphite, RRD, or OpenTSDB. InfluxDB has a line protocol for sending time series data which takes the following form: measurement-name tag-set field-set timestamp The measurement name is a string, the tag set is a collection of key/value pairs where all values are strings, and the field set is a collection of key/value pairs where the values can be int64, float64, bool, or string.

Features of InfluxDB

  • DevOps Observability – Observing and automating key customer-facing systems, infrastructure, applications and business processes.
  • IoT Analytics – Analyzing and automating sensors and devices in real-time delivering insight and value while it still matters
  • Real-Time Analytics – Leveraging the investment in instrumentation and observability—detecting patterns and creating new business opportunities
  • Ease of Scale-Out & Deployment – Millions of writes per second, and clustering to eliminate single points of failure.
  • Quickly find value in data — control systems, identify patterns, and predict the future.

Open Source Time Series Platform

The InfluxData Platform is built upon a set of open source projects — Telegraf, Influx DB, Chronograf, and Kapacitor, which are collectively called the TICK Stack. Below, learn more information about Telegraf, InfluxDB, Chronograf, and Kapacitor and their specific functions within InfluxDB’s open source core.

The Open Source Time Series Platform provides services and functionality to accumulate, analyze, and act on time series data.

influxdb
Source: https://www.influxdata.com/

Note: Clustering is only available in InfluxEnterprise and InfluxCloud – Compare Editions.

Telegraf

Telegraf is a plugin-driven server agent for collecting and reporting metrics. Telegraf has plugins or integrations to source a variety of metrics directly from the system it’s running on, to pull metrics from third party APIs, or even to listen for metrics via a StatsD and Kafka consumer services. It also has output plugins to send metrics to a variety of other datastores, services, and message queues, including InfluxDB, Graphite, OpenTSDB, Datadog, Librato, Kafka, MQTT, NSQ, and many others.

Chronograf

Chronograf is the administrative user interface and visualization engine of the platform. It makes the monitoring and alerting for your infrastructure easy to setup and maintain. It is simple to use and includes templates and libraries to allow you to rapidly build dashboards with real-time visualizations of your data and to easily create alerting and automation rules.

Kapacitor

Kapacitor is a native data processing engine. It can process both stream and batch data from InfluxDB. Kapacitor lets you plug in your own custom logic or user-defined functions to process alerts with dynamic thresholds, match metrics for patterns, compute statistical anomalies, and perform specific actions based on these alerts like dynamic load rebalancing. Kapacitor integrates with HipChat, OpsGenie, Alerta, Sensu, PagerDuty, Slack, and more.

How to Install InfluxDB on Ubuntu

1. First, update all your current system packages by the command

sudo apt-get update

2. Add “Influx DB” key to verify the packages that will be installed by the below command.

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add –

3. Add “InfluxDB” to the repository file by the below command.

sudo echo “deb https://repos.influxdata.com/ubuntu trusty stable” | sudo tee /etc/apt/sources.list.d/influxdb.list

4. Re-update your system packages with the command

sudo apt-get update

5. Now you are ready to run the below command to install InfluxDB.

sudo apt-get -y install influxdb

6. Now you had successfully installed InfluxDB, you can open it from the web page by entering your IP address following by “:8083”.

7. To create a super admin with all privileges by the command below on the query box.

CREATE USER “admin” WITH PASSWORD ‘password’ WITH ALL PRIVILEGES

8. Run the query “Show users” to make sure that your admin user is created successfully.

Enable authentication

By default, authentication isn’t enabled on InfluxDB to enable follow the given below steps.

1.Open the configuration file with the nano editor by the below command.

sudo nano /etc/influxdb/influxdb.conf

2. Search for “Auth-Enabled” and change it from “false” to “true” like the screenshot below.

3. Restart InfluxDB so changes take effect by the below command.

sudo service influxdb restart

Getting Started with InfluxDB

I use ubuntu 16.04 LTS OS . Follow instructions are given below:

  • Download and install InfluxDB

Read This article How to Install InfluxDB on Ubuntu and follow instructions.

  • Now Check status of InfluxDB
systemctl status influxdb.service
  • After Activation start Influx
influx
  • First create a database
> create database mydb
  • To view the list of databases
> show databases
name: databases
---------------
name
_internal
mydb

>
  • For using the database
> use mydb

Note : In influxdb we call tables as measurements and columns as fields.

We don’t need to define measurements(tables) and fields(columns). It will create measurements and add columns automatically when we insert data.

Inserting Data

Format for writing data is

measurementName field1=value1,field2=value2,field3=value3 timestamp
  • The timestamp is in nanoseconds. If we don’t provide timestamp it will assign the local current timestamp.
  • By default it assumes all the numbers as doubles. For integer value we have to append i at the end.
    > insert measurementName field4=12i
  • String values should be in double quotes.
    > insert measurementName field5="qwqw"
  • For boolean values use t, T, true, True, or TRUE for TRUE, and f, F, false, False, or FALSE for FALSE
    > insert measurementName field6=T
  • We can use \ character for escaping comma, space, equal and other special character in field (field) value

For more details refer official documentation

Querying Data

To select all fields from measurement

> select * from measurementName

To select particular fields

> select field1, field2 from measurement

Note : If your mesurement name or field name contains characters such as .# or =, then use double quotes

> select "field1.name", "field2.name" from "measurement.name"

Where clause

A typical usage of where clause

> select * from measurement where field1 > 12 and field2 = 'sparta' and time > now() - 1d

We can also use or logic using separaters ( and ).

Supported comaparaters in influxdb are

  • = equal to
  • <> not equal to
  • != not equal to
  • > greater than
  • < less than
  • =~ matches against
  • !~ doesn’t match against

You can learn about queries in details from official influxDB Documentation.


I hope you like this post. Do you have any questions? Leave a comment down below!Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.

We have other tutorials with ESP32 that you may find useful:

You may like also:

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. I am a tech blogger and an IoT Enthusiast. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning! Follow and send tweets me on @harshvardhanrvm

3 thoughts on “InfluxDB | Installation | How To Use | Time Series Database ?

Leave a Reply

%d bloggers like this: