You can see the full API for our history service at http://HOST/history/api/doc
.
Example call for metrics:
curl \
-X POST \
-H 'Content-Type: application/json' \
http://localhost/history/history/last_values \
-w "\n" \
-d '{
"fields": [
"HERMS MT Sensor/value[degC]",
"WiFiSettings/signal"
],
"measurement": "sparkey",
"epoch": "s"
}'
Used arguments:
-
fields
is a list of /-separated values. The service name is not included. In the UI, if you go to Graph/Metrics widget settings, and click on a field in the selection tree, the dialog title will be the field name. You can also call http://HOST/history/history/fields
to get a list.
-
measurement
is the service name.
-
epoch
is the timestamp precision. ns
, ms
, s
are some valid arguments.
Example output (prettified):
[
{
"field": "HERMS MT Sensor/value[degC]",
"time": 1626629899,
"value": 20
},
{
"field": "WiFiSettings/signal",
"time": 1626629899,
"value": 2
}
]
For inline formatting, I can recommend jq. For example:
curl \
-X POST \
-H 'Content-Type: application/json' \
http://localhost/history/history/last_values \
-w "\n" \
-d '{
"fields": [
"HERMS MT Sensor/value[degC]",
"WiFiSettings/signal"
],
"measurement": "sparkey",
"epoch": "s"
}' \
| jq -r '.[] | [(.time|strftime("%H:%m")),.field,.value] | @tsv'
Gives as output:
18:07 HERMS MT Sensor/value[degC] 20
18:07 WiFiSettings/signal 2
Edit: added time formatting for completeness sake.