Enabling The Things Network for InfluxDB
Want to bring The Things Network's IoT data-gathering capabilities to a time series database that can handle it? Here's how to connect it to InfluxDB.
Join the DZone community and get the full member experience.
Join For FreeI’ve been on the road a bit lately. Ok, so a lot. I spent a week at KubeCon EU demoing InfluxDB and IoT at the EclipseIoT booth, and then I spent a week presenting at the ICTP Workshop on monitoring Radiation data via LoRa networks. I’m sure that all sounds ridiculously exciting to you. It was more exhausting than anything. As a side note, I managed to walk a total of 25 miles over 2 days during those trips, which is personally pretty amazing.
While I was instructing at the ICTP workshop — and let me say that it was both an honor and a privilege to be around the incredibly smart attendees under the auspices of the United Nations — I was asked if it was possible to connect The Things Network, which the workshop was using to collect sensor data, to InfluxDB. I figured it would be, and that it wouldn’t be that hard, but I was a little shocked at how simple it really was! Here’s the rundown.
First, I installed InlfuxDB, Telegraf, etc. on a server in the ICTP Lab. Next, I had to configure the Telegraf instance to read from the TTN (The Things Network) server. Luckily, it is a simple MQTT broker, so all I had to do was edit the telegraf.conf file and add the following section:
[[inputs.mqtt_consumer]]
servers = ["tcp://eu.thethings.network:1883"]
qos = 0
connection_timeout = "30s"
topics = [ "+/devices/+/up" ]
client_id = ""
username = “username"
password = “password"
data_format = "json"
A restart of Telegraf, and suddenly, a ton of data was streaming from their sensors! Of course, you’ll have to use real values for your own username and password.
I wish that this was a longer blog post, but it’s hard to stretch this out much more given how easy it was to integrate TTN with InfluxDB. The really neat thing about the Telegraf MQTT plugin is that it automatically ‘flattened’ the JSON payload from the TTN MQTT broker and imported the resultant data into InfluxDB with no additional effort on my part.
If you’re using TTN, and you want an easy way to analyze and visualize your data, try pulling it into InfluxDB! It’s super easy, super fast, and gives you access to data analysis and dashboarding very quickly.
Published at DZone with permission of David G. Simmons, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments