Query databases
You can query various databases like InfluxDB, CouchDB, Postgres, and MinIO using the credentials of the respective database.
Querying InfluxDB using Passport
Passport is the proxy service used for InfluxDB. It receives requests that use Keycloak credentials and validates those credentials through OAuth Helper. It then sends the request to the appropriate database using the database credentials. This enables you to take advantage of Keycloak roles and control user access.
The external port used by InfluxDB for the Passport service is 30223. Using this port, you can also use Passport to access other supported databases like CouchDB, Postgres, and MinIO.
Before you begin
- Create a data route using Influx data type, AMQP data source, and InfluxDB as the destination. Use NiFi to send some data to the route to ensure that the data route is working.
- Log in to the InfluxDB UI with the following information and view the buckets and data needed for this procedure:
URL https://<cluster_fqdn>:30086/ Username and Password Admin username and password. See the iiot install configuration.yaml file for username and password.
Procedure
Use the following code for querying InfluxDB through Passport using the REST client.
{ "query":"import "influxdata/influxdb/schema" schema.measurementFieldKeys(bucket: "test_db", measurement: "test_table")", "type":"flux" }
Change the bucket and measurement names based on your environment.
Check the basic authentication credentials. Click the Basic tab and check that the admin username and password created in Keycloak are specified to use basic authentication.
Click the Query tab and check that the parameter org=hiota is specified. The organization name can be found in the InfluxDB UI.
Click Send to execute the query.