Tools
Labs
basica
The TIG Stack is an acronym for a platform of open source tools built to make collection, storage, graphing, and alerting on time series data incredibly easy.
A time series is simply any set of values with a timestamp where time is a meaningful component of the data. The classic real world example of a time series is stock currency exchange price data.
Let’s start by adding the influxdb repositories:
We can now install Telegraf and Influxdb:
Install Grafana:
We can now activate all the services:
InfluxDB is a time-series database compatible with SQL, so we can setup a database and a user easily. You can launch its shell with the influx
command:
Next step is creating a database called "telegraf"
Next step is creating a user (called “telegraf”) and granting it full access to the database.
A Retention Policy (RP) is the part of InfluxDB’s data structure that describes for how long InfluxDB keeps data.
InfluxDB compares your local server’s timestamp to the timestamps on your data and deletes data that are older than the RP’s DURATION. A single database can have several RPs and RPs are unique per database.
Exit from InfluxDB:
Next, we have to configure the Telegraf instance to read from the TTN (The Things Network) server.
Luckily TTN runs a simple MQTT broker, so all we have to do is, first:
then create a new telegraf.conf
file, in the same directory, with the content below:
[agent]
flush_interval = "15s"
interval = "15s"
[[inputs.mqtt_consumer]]
servers = ["tcp://eu.thethings.network:1883"]
qos = 0
connection_timeout = "30s"
topics = [ "+/devices/+/up" ]
client_id = "ttn"
username = "XXX"
password = "ttn-account-XXX"
data_format = "json"
[[outputs.influxdb]]
database = "telegraf"
urls = [ "http://localhost:8086" ]
username = "telegraf"
password = "superpa$$word"
where you have to change: "username" and "password" with the values:
Then we can restart telegraf and the metrics will begin to be collected and sent to InfluxDB:
We can check if the data is sent from Telegraf to InfluxDB:
Enter an InfluxQL query using database 'telegraf':
> use telegraf
> select * from "mqtt_consumer"
you should start seeing something like:
name: mqtt_consumer
time counter host metadata_airtime metadata_frequency metadata_gateways_0_altitude metadata_gateways_0_channel metadata_gateways_0_latitude metadata_gateways_0_longitude metadata_gateways_0_rf_chain metadata_gateways_0_rssi metadata_gateways_0_snr metadata_gateways_0_timestamp metadata_gateways_1_channel metadata_gateways_1_latitude metadata_gateways_1_longitude metadata_gateways_1_rf_chain metadata_gateways_1_rssi metadata_gateways_1_snr metadata_gateways_1_timestamp payload_fields_humidity payload_fields_lux payload_fields_temperature port topic
---- ------- ---- ---------------- ------------------ ---------------------------- --------------------------- ---------------------------- ----------------------------- ---------------------------- ------------------------ ----------------------- ----------------------------- --------------------------- ---------------------------- ----------------------------- ---------------------------- ------------------------ ----------------------- ----------------------------- ----------------------- ------------------ -------------------------- ---- -----
1572521236113061054 499 ubuntu 1482752000 867.5 10 5 39.48262 -0.34657 0 -88 7.2 409385364 5 39.48646 -0.3589999 0 -113 2.5 2717632268 34.882110595703125 55.22838592529297 34.37117004394531 2 rse_testing/devices/device001/up
1572521255767137586 500 ubuntu 1482752000 867.5
Log into Grafana using a web browser:
you will be asked to change the password the first time.
You have to add a data source:
then select
then fill in the fields indicated with the red arrow
If everything is fine you should see:
Now you have to add a dashboard and add graphs to it to visualize the data:
click on
then "New Dashboard", and "Add Query":
and then specify the data you want to plot:
you can actually see a lot of data "fields":
Try to get something like: