Influxdb usage

From wikinotes

Documentation

official docs https://docs.influxdata.com/influxdb/v2.7/
flux syntax https://docs.influxdata.com/influxdb/v2.7/reference/syntax/flux/
annotated csv format https://docs.influxdata.com/influxdb/v2.7/reference/syntax/annotated-csv/

Interfaces

Web Interface

open 'http://localhost:8086'

Commandline Interface

influx -h

influx user ls  # list users
influx write --bucket mybucket --file /var/tmp/my-data.csv  # write data to bucket

Rest API

curl 'http://localhost:8086/api/v2' \
  --header "Authorization: Token ${YOUR_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-urlencode "db=default" \
  --data-urlencode "q=SELECT * FROM cpu_usage" \
  | jq

Inputs

CSV

TODO:

needs some experimentation

A single measurement can have multiple field-values.
That field value can be assigned various tags.

A sample input.csv with a series of points.

#
_time                , _value , _field , _measurement , my-tag1 , my-tag2 , ...
2023-06-10T12:00:00Z , 11111  , heat   , cpuSensor    , foo     , bar     , ...
2023-06-10T12:00:00Z , 55555  , power  , cpuSensor    , foo     , bar     , ...
2023-06-10T13:00:00Z , 22222  , heat   , cpuSensor    , foo     , bar     , ...
2023-06-10T13:00:00Z , 66666  , power  , cpuSensor    , foo     , bar     , ...

Querying Data

Flux Script