PipedreamHQ / PipedreamHQ/pipedream

InfluxDB App Example Always Fail

Open
#1,717 7 comments 0 reactions 0 assignees View on GitHub
bug triaged
Dominant language
JavaScript
Stars
11.7k
Forks
5.8k
Avg merge
3d 10h
Merged PRs (30d)
102

Description

**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.

```js
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__:
```js
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__:
```js
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)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.