How to integrate Prometheus time series with thethings.iO IoT platform


Today we would like to explain how to integrate the Prometheus time series server and database with thethings.iO IoT platform using exclusively thethings.iO Cloud Code Functions and Triggers. Rendering real-time sensor data is not a problem with thethings.iO IoT platform but computing historical metrics – like how many times a button has been pressed within a certain time period – is a lot harder unless you are thethings.iO Cloud Code proficient. There is another possibility, so we shall use a time series database, Prometheus, to store time series data and compute time series metrics. Learn here more about Prometheus.

Assumes that you are using 4 things (e.g. wireless push buttons) connected to thethings.iO via the Sigfox IoT network. The 4 buttons make up a customer feedback survey panel, labelled as: Excellent, Good Job, Fair, Poor. Each button shall be connected to thethings.iO via the standard Sigfox callback provided by thethings.iO.

Prometheus system shall use the time series data to compute a new metric named button_presses_5m, which is the incremental number of button presses in the past 5 mins. The computed metric is pushed back into thethings.iO via a Cloud Code Function and stored in thethings.iO things resources that correspond to each of the four things in thethings.iO IoT platform. The computed metric is then rendered in a thethings.iO dashboard.

This demonstration uses Prometheus to compute a simple time series metric. Prometheus supports sophisticated time-series queries that have been used for monitoring highly complex computer networks in real time. Details on the advanced time series functions supported by Prometheus.

Find on thethings.iO github repository the code to replicate the integration among Prometheus time series and thethings.iO.