InfluxDB V2 Datasource Integration

Knowi enables data discovery, query, aggregation, visualization, and reporting automation from InfluxDB V2 along with other unstructured and structured datasources.

Overview

  1. Connect, extract, and transform data from your InfluxDB V2, using one of the following options:

    a. Through our UI to connect directly. b. Using our Cloud9Agent. This can securely pull data inside your network. See agent configuration for more details.

  2. Visualize and Automate your Reporting instantly.

UI Based Approach

Connecting

  1. Log in to Knowi and select Queries from the left sidebar.
  2. Click on New Datasource + button and select InfluxDB V2 from the list of datasources.
  3. After navigating to the New Datasource page, either uses the pre-configured settings into Cloud9 Chart's own demo InfluxDB V2 database or follow the prompts and configure the following details to set up connectivity to your own InfluxDB V2 database:

    a. Datasource Name: Enter a name for your datasource
    b. URL: Enter the URL to connect to the InfluxDBV2 instance
    c. API Key: Enter API Key to connect to InfluxDBV2 instance
    d. Org ID: Enter the unique identifier to identify the organization when making API calls and to control access to resources within the organization.
    e. Default Bucket: Enter the name of the bucket that a particular measurement belongs to
    f. Internal Datasource: Checking this option enables you to define datasource configurations here that are automatically synced with your agent.

  4. Click on the Save button and start Querying.

 InfluxDB Connect

Query

Step 1: Query using a visual builder or query editor

Visual Builder: After connecting to the InfluxDB V2 datasource, Knowi will pull out a list of tables along with field samples. Using these tables, you can automatically generate queries through our visual builder in a no-code environment by either dragging and dropping fields or making your selections through the drop-down.

 InfluxDB Connect

Tip: You can also write queries directly in the Query Editor, a versatile text editor that offers more advanced editing functionalities like InfluxDB2 Query support for multiple language modes, Cloud9QL, and more.

Step 2: Define data execution strategy by using any of the following two options:

Non-direct execution can be put into action if you choose to run the Query once or at scheduled intervals. For more information, feel free to check out this documentation- Defining Data Execution Strategy.

 InfluxDB Connect

Step 3: Click on the Preview button to analyze the results of your Query and fine-tune the desired output, if required.

 InfluxDB Connect

The result of your Query is called Dataset. After reviewing the results, name your dataset and then hit the Create & Run button.

 InfluxDB Connect

AI Query Generator

The AI query generator automatically generates queries from plain English statements for searching the connected databases and retrieving information. The goal is to simplify and speed up the search process by automatically generating relevant and specific queries, reducing the need for manual input, and improving the probability of finding relevant information.

STEPS:

Step 1: Enter the details of the query you'd like to generate in plain English. Details can include table or collection names, fields, filters, etc. The AI generator uses OpenAI to generate a query.

Only the question is sent to OpenAI APIs and not the data.

Example:

return sensor_id, field, from table airSensors

 InfluxDB Connect

Step 2: Click on the Run and the query will be generated which you can copy to the clipboard and paste into the Query Editor.

 InfluxDB Connect

Step 3: Click on the Preview button to analyze the results of your Query and fine-tune the desired output, if required.

Note 1: The OpenAI must be enabled by the admin before using the AI Query Generator.

Note 2: The user can copy the API key from the personal OpenAI account and use the same or use the default key provided by Knowi.

{Account Settings > Customer Settings > OpenAI Integration}

 InfluxDB Connect

Furthermore, AI Assistant offers you additional features that can be performed on top of the generated query as listed below:

Explain Query

Provides explanations for your existing query. For example, an explanation requested for the query generated below AI Assistant has returned the description-

This InfluxDB V2 query is selecting the location, degrees, and time from the h2o_temperature table. The query is asking for the location, the temperature in degrees, and the time that the temperature was recorded.

Find Issues

Helps in debugging and troubleshooting the query. For example, finding issues in the query generated below returns this error- The location is misspelled (should be "location")

Syntax Help

Ask questions around query syntax for this datasource. For example, suggesting the syntax for the requested query returned the response- SELECT location FROM table_name

Cloud9Agent Configuration

As an alternative to the UI based connectivity above, you can use Cloud9Agent inside your network to pull from InfluxDB V2 securely. See Cloud9Agent to download your agent along with instructions to run it.

Highlights:

  • Pull data using SQL.
  • Execute queries on a schedule, or, one time.

The agent contains a datasource_example_influxdbV2.json and query_example_influxdbV2.json under the examples folder of the agent installation to get you started.

  • Edit those to point to your database and modify the queries to pull your data.
  • Move it into the config directory (datasource_XXX.json files first if the Agent is running).

Datasource Configuration:

Parameter Comments
name Unique Datasource Name.
datasource Set value to influxdb V2
url URL to connect to, where applicable for the datasource. Example for InfluxDB V2: localhost:3306/test
userId User id to connect, where applicable.
Password Password, where applicable
userId User id to connect, where applicable.

Query Configuration:

Query Config Params Comments
entityName Dataset Name Identifier
identifier A unique identifier for the dataset. Either identifier or entityName must be specified.
dsName Name of the datasource name configured in the datasource_XXX.json file to execute the query against. Required.
queryStr InfluxDB V2 query to execute. Required.
frequencyType One of minutes, hours, days,weeks,months. If this is not specified, this is treated as a one time query, executed upon Cloud9Agent startup (or when the query is first saved)
frequency Indicates the frequency, if frequencyType is defined. For example, if this value is 10 and the frequencyType is minutes, the query will be executed every 10 minutes
startTime Optional, can be used to specify when the query should be run for the first time. If set, the the frequency will be determined from that time onwards. For example, is a weekly run is scheduled to start at 07/01/2014 13:30, the first run will run on 07/01 at 13:30, with the next run at the same time on 07/08/2014. The time is based on the local time of the machine running the Agent. Supported Date Formats: MM/dd/yyyy HH:mm, MM/dd/yy HH:mm, MM/dd/yyyy, MM/dd/yy, HH:mm:ss,HH:mm,mm
c9QLFilter Optional post processing of the results using Cloud9QL. Typically uncommon against SQL based datastores.
overrideVals This enables data storage strategies to be specified. If this is not defined, the results of the query is added to the existing dataset. To replace all data for this dataset within Knowi, specify {"replaceAll":true}. To upsert data specify "replaceValuesForKey":["fieldA","fieldB"]. This will replace all existing records in Knowi with the same fieldA and fieldB with the the current data and insert records where they are not present.

Examples

Datasource Example:

[
    {
        "name": "demoInfluxDBV2",
        "host": "http://demo.knowi.com:8086",
        "dbName": "NOAA_water_database",
        "userId": "",
        "password": "",
        "datasource": "influxdbV2"
    }
]

Query Example:

[
  {
    /* This runs every 10 minutes, on the datasource defined in the any of the files that begin with datasource_  */
    "entityName":"Water level",
    "dsName":"demoInfluxDBV2",
    "queryStr":"select mean(water_level) as \"avg\" from h2o_feet group by location",
    "frequencyType":"minute",
    "frequency":10,
    "overrideVals":{
      /* Tells Knowi to replace all existing values for this dataset with this one */
      "replaceAll":true
    }
  }
]

The first query is run every 10 minutes at the top of the hour and replaces all data for that dataset in Knowi. The second is run once a day at 07:20 AM and updates existing data with the same Type field, or inserts new records otherwise.