Configuring DB Connector - InfluxDB

DronaHQ Studio enables you to use databases by configuring their connectors and now InfluxDB Connector is available in the studio.
InfluxDB is a high-performance Time Series Database that can store data ranging from hundreds of thousands of points per second. The InfluxDB is a SQL-kind of query language which was built specifically for time series data.

Configuring InfluxDB connector

To add a third-party DB connector, under Studio > Connectors, click (+) Connector. Select InfluxDB connector

Enter connector Name.

To connect to the InfluxDB database you would need a few parameters or fields. The connection parameters that are required are the Host and database name. Add the other configuration details for Port, Username, and Password.

Once these configurations are added, click Test connection. If the authentication is successful, you will get a response accordingly. Click to Save your configuration.

Adding Queries to InfluxDB Connector

Now that you have configured the connector you will find it under the Custom Database connectors list. Further to fetch data or undertake any other action, click the Add query option available after your connection is ready.

Here you can add your queries by simply clicking add query.
Next, you have to provide the details such as query name, action, and more. In InfluxDB there are only two actions that can be performed, which are Write Point and Run Query.

  • Write Point: It is for writing into the database. This will have a body field (JSON editor) to write into InfluxDB.

  • Run Query: It is basically retrieving data from the database. This action will have a query field (text area) to retrieve data. Users can write aggregate, transpose, retention policies, continuous queries, etc. Here.

On the right-hand side of the screen, you can see the list of tables from the database. You can expand the tables to view the fields from the table.

To use a dynamic variable in a query, you simply need to put it into double Curly brackets. You can add a sample value to test your query before saving it. When using the connector queries the dynamic variables would have to be linked to the respective control for further run-time functioning.

You can now view the queries that you saved for use in your apps later under your specific connector under Custom Database connectors.

Queries of InfluxDB Connector

Write Point – Inserting Data

Let us build a query to insert data from the user into the database of InfluxDB. We will be using write point for this.
Since the write point is in JSON format we will provide a JSON code in this.
JSON code:

    "measurement": "{{table}}", 
    "tags": { 
        "host": "", 
        "app": "DHQ", 
        "Instance": "Node1", 
        "userdname": "pawan" 
   "fields": { 
       "uname": "pawan" 
   "timestamp": 1609746029444 

JSON code explanation:
In the above JSON code, we have details that we want to insert inside the table of the database. It consists of a variable which is the table, this would need to be inserted by the user at the time of running the query also the JSON code has a timestamp in it which is important since InfluxDB is time-series database.

Run Query – Fetching Data

Now let us build a query to fetch the details from the database provided that it should retrieve details that are between specified timestamps.

Query used:

SELECT COUNT(*) FROM login_info WHERE time >= '2021-01-04T00:00:00Z' AND time <= '2021-02-03T00:00:00Z' GROUP BY time(1d)

Query Explanation:
The above query is to get the number of records from the login_info table provided on the condition that it should be between two specified timestamps and should be grouped respectively to their time(1d)

Using InfluxDB connector

Now that we have added our queries for InfluxDB, you can use the connector query anytime within your apps. Now if you want to display the details in a tablegrid control you simply need to add the connector to the app and then bind the connector in the respective control’s properties (tablegrid in this case).