sudo service influxdb start
sudo service influxdb status
const {InfluxDB} = require('@influxdata/influxdb-client')
// You can generate a Token from the "Tokens Tab" in the UI
const token = ''
const org = ''
const url = ''
const bucket = 'test'
const client = new InfluxDB({url, token})
const queryApi = client.getQueryApi(org)
const {Point} = require('@influxdata/influxdb-client')
const writeApi = client.getWriteApi(org, bucket)
writeApi.useDefaultTags({host: 'host1'})
const point = new Point('mem')
.floatField('used_percent', 23.43234543)
writeApi.writePoint(point)
writeApi
.close()
.then(() => {
console.log('FINISHED')
})
.catch(e => {
console.error(e)
console.log('\\nFinished ERROR')
})
const query = `from(bucket: "${bucket}") |> range(start: -1h)`
queryApi.queryRows(query, {
next(row, tableMeta) {
const o = tableMeta.toObject(row)
console.log(o)
},
error(error) {
console.error(error)
console.log('\\nFinished ERROR')
},
complete() {
console.log('\\nFinished SUCCESS')
},
})