I am trying to get the last value inserted into a table in infuxdb. What I need to do is send it to another system via HTTP.
I would like to do all this in a bash script, but I am also open to Python.
$ curl -sG 'https://influx.server:8086/query' --data-urlencode "db=iotaWatt" --data-urlencode "q=SELECT LAST(\"value\") FROM \"grid\" ORDER BY time DESC" | jq -r
{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "grid",
"columns": [
"time",
"last"
],
"values": [
[
"2018-01-17T04:15:30Z",
690.1
]
]
}
]
}
]
}
What I'm struggling with is turning this value into a clean format that I can use. I really don't want to use sed, and I tried jq, but it complains that the data is a string, not an index:
jq: error (at <stdin>:1): Cannot index array with string "series"
Anyone have a good suggestion?
source
share