Influxdb usage: Difference between revisions
From wikinotes
No edit summary |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Web Interface = | = Documentation = | ||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| 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/ | |||
|- | |||
|} | |||
</blockquote><!-- Documentation --> | |||
= Interfaces = | |||
<blockquote> | |||
== Web Interface == | |||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 6: | Line 21: | ||
</blockquote><!-- Web Interface --> | </blockquote><!-- Web Interface --> | ||
= Commandline Interface = | == Commandline Interface == | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 12: | Line 27: | ||
influx user ls # list users | influx user ls # list users | ||
influx write --bucket mybucket --file /var/tmp/my-data.csv # write data to bucket | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Commandline Interface --> | </blockquote><!-- Commandline Interface --> | ||
= Rest API = | == Rest API == | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="bash"> | |||
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 | |||
</syntaxhighlight> | |||
</blockquote><!-- HTTP API --> | |||
</blockquote><!-- Interfaces --> | |||
</blockquote><!-- | = Inputs = | ||
<blockquote> | |||
== CSV == | |||
<blockquote> | |||
{{ TODO | | |||
needs some experimentation | |||
}} | |||
A single measurement can have multiple field-values.<br> | |||
That field value can be assigned various tags. | |||
A sample input.csv with a series of points. | |||
<syntaxhighlight lang="csv"> | |||
# | |||
_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 , ... | |||
</syntaxhighlight> | |||
</blockquote><!-- CSV --> | |||
</blockquote><!-- Inputs --> | |||
= Querying Data = | |||
<blockquote> | |||
== Flux Script == | |||
<blockquote> | |||
</blockquote><!-- Flux Script --> | |||
</blockquote><!-- Querying Data --> |
Latest revision as of 17:58, 10 June 2023
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 bucketRest 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