HomeDockerVisualizing Time Series Data immediately over IoT Edge device using Dockerized RedisTimeSeries...

Visualizing Time Series Data immediately over IoT Edge device using Dockerized RedisTimeSeries & Grafana – Welcome to Collabnix

 1,728 views

Visualizing Time Series Data immediately over IoT Edge device using

Application developers gaze to Redis and RedisTimeSeries to work with real-time internet of things (IoT) sensor data. RedisTimeseries is a Redis module to enhance your experience managing time-series data with Redis. It simplifies the use of Redis for time-series use cases such as internet of things (IoT) data, stock prices, and telemetry. With RedisTimeSeries, you can ingest and query millions of samples and events at the velocity of Redis. Advanced tooling such as downsampling and aggregation ensures a small memory footprint without impacting performance. Use a variety of queries for visualization and monitoring with constructed-in connectors to wellliked monitoring tools like Grafana, Prometheus, and Telegraf.

Introducing Redis Data Source for Grafana

The Redis Data Source for Grafana is a plug-in that allows users to connect to the Redis database and construct dashboards in Grafana to easily monitor Redis and application data. It provides an out-of-the-box predefined dashboard but also lets you construct customized dashboards tuned to your specific needs.

I revealed a blog for Redis Labs where I showcased how to fetch sensor data and push it to Redis Enterprise Cloud. In this tutorial, I will show how you can use a python script to fetch IoT sensor data, push it to dockerized RedisTimeSeries and then plot it over Grafana ~ all using Docker container operating on the IoT device.

Let’s get initiated –

Hardware requirements:

Software requirements:

You can run RedisTimeSeries immediately over an IoT Edge device. Follow the below steps to construct RedisTimeSeries Docker Image over Jetson Nano:

Verifying Docker version

SSH to 70.167.220.160 and install Docker

[email protected]:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.3
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        48d30b5
 Built:             Fri Jan 29 14:33:34 2021
 OS/Arch:           linux/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimal version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:42 2021
  OS/Arch:          linux/arm64
  Experimental:     untrue
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 nvidia:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Verifying if Sensor is detected

 i2cdetect -r -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- --

Building Docker Image for RedisTimeSeries for Jetson Nano

git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git
cd RedisTimeSeries.git
docker construct -t ajeetraina/redistimeseries-jetson . -f Dockerfile.jetson.edge

Running RedisTimeSeries

docker run -dit -p 6379:6379 ajeetraina/redistimeseries-jetson

Verifying if RedisTimeSeries Module is loaded

redis-cli
127.0.0.1:6379> information modules
# Modules
module:name=timeseries,ver=999999,api=1,filters=0,usedby=[],using=[],options=[]
127.0.0.1:6379>

Clone the repository

$ git clone https://github.com/redis-developer/redis-datasets
$ cd redis-datasets/redistimeseries/realtime-sensor-jetson

Running Sensorload Script

sudo python3 sensorloader2.py --host localhost --port 6379

Running Grafana on Jetson Nano

docker run -d -e "GF_INSTALL_PLUGINS=redis-app" -p 3000:3000 grafana/grafana

There you go..

Point your browser to https://<IP_ADDRESS>:3000. Use “admin” as username and password to log in to the Grafana dashboard.

1626608739 497 Visualizing Time Series Data immediately over IoT Edge device using

Click the Data Sources option on the left side of the Grafana dashboard to add a data source.

1626608739 679 Visualizing Time Series Data immediately over IoT Edge device using

Under the Add data source option, search for Redis and the Redis data source will appear as proven below:

1626608740 152 Visualizing Time Series Data immediately over IoT Edge device using
1626608740 398 Visualizing Time Series Data immediately over IoT Edge device using

Supply the name, Redis Enterprise Cloud database endpoint, and password, then click Save & Test.

Click Dashboards to import Redis and Redis Streaming. Click Import for both these options.

1626608740 186 Visualizing Time Series Data immediately over IoT Edge device using

Click on Redis to see a fancy Grafana dashboard that shows the Redis database information:

1626608740 687 Visualizing Time Series Data immediately over IoT Edge device using
1626608740 633 Visualizing Time Series Data immediately over IoT Edge device using

Finally, let’s create a sensor dashboard that shows temperature, pressure, and humidity. To start with temperature,  first click on + on the left navigation window. Under Create option, Select Dashboard and click on the Add new panel button.

1626608741 559 Visualizing Time Series Data immediately over IoT Edge device using

A new window will open showing the Query section. Select SensorT from the drop-down menu, choose RedisTimeSeries as type, TS.GET as command and ts”temperature as key.

1626608741 836 Visualizing Time Series Data immediately over IoT Edge device using

Choose TS.GET as a command.

1626608741 294 Visualizing Time Series Data immediately over IoT Edge device using

Type ts”temperature as the key.

1626608741 960 Visualizing Time Series Data immediately over IoT Edge device using

Click Run followed by Save, as proven below:

1626608741 944 Visualizing Time Series Data immediately over IoT Edge device using

Now you can save the dashboard by your preferred name:

1626608742 379 Visualizing Time Series Data immediately over IoT Edge device using

Click Save. This will open up a sensor dashboard. You can click on Panel Title and select Edit.

1626608742 676 Visualizing Time Series Data immediately over IoT Edge device using

Type Temperature and choose Gauge under Visualization.

1626608742 542 Visualizing Time Series Data immediately over IoT Edge device using

Click Apply and you should be able to see the temperature dashboard as proven here:

1626608742 293 Visualizing Time Series Data immediately over IoT Edge device using

Follow the same process for pressure (ts:pressure) and humidity (ts:humidity), and add them to the dashboard. You should be able to see the complete dashboard readings for temperature, humidity, and pressure. Looks incredible. Isn’t it?

1626608742 834 Visualizing Time Series Data immediately over IoT Edge device using

References


Go to the source

Most Popular