question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InfluxDB App Example Always Fail

See original GitHub issue

Describe the bug https://pipedream.com/apps/influxdb-cloud example always fails. It uses InfluxDB health API that has never been available in the cloud, it is available only in a standalone (OSS) InfluxDB installation.

const {InfluxDB} = require('@influxdata/influxdb-client')
const {HealthAPI} = require('@influxdata/influxdb-client-apis')

// See the Node.js client docs at
// https://github.com/influxdata/influxdb-client-js
const influxDB = new InfluxDB(auths.influxdb_cloud)
const healthAPI = new HealthAPI(influxDB)

// Execute a health check to test our credentials
return await healthAPI.getHealth()

To Reproduce

  1. Go to https://pipedream.com/apps/influxdb-cloud
  2. Click Connect InfluxDB and Run
  3. Fill in InfluxDB cloud credentials
  4. Run it, it does not contain any health result, the request simply contains HTML page of InfluxDB cloud UI

Expected behavior From a user perspective, it would be much better to offer examples that write or query InfluxDB. I created and tested the following examples:

Write to InfluxDB:

const {InfluxDB, Point} = require('@influxdata/influxdb-client')
const {url, token, org} = auths.influxdb_cloud
// InfluxDB bucket to write data to
const bucket = 'my-bucket'

// Create write API. See the InfluxDB client docs at
// https://github.com/influxdata/influxdb-client-js
const influxDB = new InfluxDB({url, token})
const writeApi = influxDB.getWriteApi(org, bucket)

// write measurement point: random temperature, current time, example tag
const point = new Point('test')
  .tag('source', 'pipedream')
  .floatField('temperature', 20 + Math.round(100 * Math.random()) / 10)
  .timestamp(new Date())
writeApi.writePoint(point)
// flush and close the client
await writeApi.close()

Query InfluxDB:

const {InfluxDB, flux} = require('@influxdata/influxdb-client')
const {url, token, org} = auths.influxdb_cloud

// InfluxDB bucket to query data from
const bucket = 'my-bucket'

// Create query API. See the InfluxDB client docs at
// https://github.com/influxdata/influxdb-client-js
const queryApi = new InfluxDB({url, token}).getQueryApi(org)
const fluxQuery = flux`
from(bucket: ${bucket}) // query bucket
  |> range(start: -1h) // in the last hour
  |> filter(fn: (r) => r._measurement == "test" and r._field == "temperature" and r.source == "pipedream")
  |> last() // get the last value
  |> keep(columns: [ "_time", "_value", "_field", "_measurement", "source"]) // optional, return only selected properties
`

// collect results into an array that looks like this:
// [
//   {
//     _time: '2021-09-21T03:27:14.318Z',
//     _value: 21.5,
//     _field: 'value',
//     _measurement: 'test',
//     source: 'pipedream'
//   }
// ]
return await queryApi.collectRows(fluxQuery)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dylburgercommented, Sep 29, 2021

Thanks for the reply and sorry for the delay. This is still on our backlog to address. When I get to it I may have other questions for you. Appreciate the help so far.

0reactions
srankacommented, Sep 24, 2021

You can test whether the InfluxDB is running using a ping operation. It has no side effects, but it does not validate the supplied organization and token.

InfluxDB tokens are granted for specific operations and the only universal way to validate a token-organization pair is to execute a specific operation. It necessarily comes with a side-effect for a write operation that also requires a bucket parameter. A simple query buckets() |> last(column: "name") could be possibly used to validate a read token.

There is also /users/me endpoint, but it cannot be executed without extra permission, which would then effectively force the users to create an ‘all access token’ for pipedream to have the ability to validate the token.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asynchronous write fails when writing data to multiple buckets
Hi all, I have following problem when sending data points to InfluxDB using asynchronous WriteApi. The problem occurs only when processing data points...
Read more >
InfluxDB frequently asked questions - InfluxData Documentation
Why does InfluxDB fail to parse microsecond units in the configuration file? Does InfluxDB have a file system size limit? Command line interface...
Read more >
Troubleshoot issues writing data | InfluxDB Cloud ...
Troubleshoot issues writing data. Find response codes for failed writes. Discover how writes fail, from exceeding rate or payload limits, to syntax errors ......
Read more >
Data exploration using InfluxQL - InfluxData Documentation
Explore time series data using InfluxData's SQL-like query language. Understand how to use the SELECT statement to query data from measurements, tags, ...
Read more >
InfluxDB v2.4 API documentation
For example, you can use the PATCH /api/v2/scripts endpoint to update ... Doesn't allow you to manage passwords through the API; always responds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found