Influxdb
warning
The document is a continuation of the previous document, if you have landed directly on this page then, Please read from page Get started.
#
What is Time Series Database?- A database used to store data with time information
- For example: Temperature sensor at time 11:50 pm located at factory 1 recorded 31 deg Celsius.

#
List of Time Series Database features implemented in Shunya stackWith Shunya stack you can make IoT device
- Insert data into Time Series Database.
- Query data from Time Series Database.
note
Shunya stack uses InfluxDB database program to store and query the timeseries data.
#
Using Time Series Database in Shunya stack#
Requirements to use Time Series Database in Shunya stack- Shunya OS installed (supported Arm devices) or Shunya OS docker container (X86 based windows/linux devices)
- InfluxDB installed on either Shunya OS or on external server.
#
Steps to use Time Series Database in Shunya stack- Set Time Series Database settings in Shunya.
- Insert data into Time Series Database.
- Query data from Time Series Database.
note
Run the steps given below inside Shunya OS installed (supported Arm devices) or Shunya OS docker container (X86 based windows/linux devices) terminals.
#
Step 1: Set Time Series Database settings in Shunya.Set PLC Modbus details, by editing the config file /etc/shunya/config.json
inside Shunya OS.
A simple configuration should contain these parameters.
Config | Descriptions |
---|---|
influxdbUrl | URL to the Influx DB instance. |
influxdbDBName | Name of the database in which the data gets stored. |
#
Example configuration:- InflusDB on Server
- InfluxDB on Shunya
Writing the below json in /etc/shunya/config.json
file, will tell the Shunya stack to
connect to InfluxDB installed on Shunya OS.
Writing the below json in /etc/shunya/config.json
file, will tell the Shunya stack to
connect to InfluxDB installed on server 146.253.91.253
with port 8086
.
#
Step 2: Insert data into Time Series Database.Let's take an example use case: Say
- We have connected an IoT device in a Wahrehouse
- It is recording temperature data and storing it in Time series database.
- Read data from the temperature sensor connected to Shunya and,
- Insert the data to database
shunya_test
.
Steps are :
Start with an ready to use template for sending messages via MQTT
Open the
store-influxdb.c
in an text editor and modify as per your use case.For our example, we need to first get the temperature data, add the code in your
main()
functionInserting temperature data to database 'test-db', modify the code
This will store data in Table warehouse and column temperature.
Once you are done editing, save and compile the code , by running
Run the code
More examples Inserting temperature data to database,
- Insert Integer
- Insert string
- Insert Multiple values
For Inserting Integer value, change code in step 4. with the example given below.
For Inserting String value, change code in step 4. with the example given below.
For inserting multiple variables, change code in step 4. with the example given below.
#
Step 3: Query data from Time Series Database.Let's take an example use case: Say we need to
- Query all warehouse data from Time series database and dump all the data into CSV file.
Steps are :
Start with an ready to use template for sending messages via MQTT
Open the
read-influxdb.c
in an text editor and modify as per your use case.For our example, we need to first write a query for dumping all the warehouse data, add the code in your
main()
functionDumping all the data to CSV file "warehouse-data", modify the code
Once you are done editing, save and compile the code , by running
Run the code
More examples on Querying Time series database,
- Query one Value
For Querying "temperature" value from table "warehouse", change code in step 3. with the example given below.