Hi i am totally new at Influxdb. And have problem with writing data via curl.
My bash is like this,
curl -i -XPOST
–header "Authorization: Token $TOKEN "
–header “Content-Type: text/plain; charset=utf-8”
–header “Accept: application/json”
–data-binary “ampguard,phase=L1 Ampere=$a1,Voltage=$v1,Watt=$w1,Cosphi=$w1,Freq=$f1 $unixtime
ampguard,phase=L2 Ampere=$a2,Voltage=$v2,Watt=$w2,Cosphi=$c2,Freq=$f2 $unixtime
ampguard,phase=L3 Ampere=$a3,Voltage=$v3,Watt=$w3,Cosphi=$c3,Freq=$f3 $unixtime”
and I´ve got this message when i run the bash file,
date: Fri, 15 Jul 2022 14:19:42 GMT
but i cant see anything in the web GUI in InflexDB.
My Influx runs in docker environment.
The issue could be in the time - InfluxDB expects timestamps in the UTC.
What is exactly $unixtime?
Just for a test, try sending data without a timestamp. The server will assign the current time automatically.
sorry late answer VlastaHajek,
$unixtime is the variable i create from the time in the device i get data from,
curl -s $AMPGUARD | jq '.time' | tr -d '"'
date -d "$date" '+%s'
As you mentioned it works when i removed $unixtime and also add a new post “Check=1”, without “Check=1” it doesn’t work. Check=1 is just random named post.
I´m not comfortable with how InfluxDB shall have the input of data.
Writing data using
curl and manually composing line protocol is a complicated expert way. Using some client library is the best user experience for writing or querying data
There is a client library for each common programming language: Use InfluxDB client libraries | InfluxDB OSS 2.3 Documentation
If you still need to write data using
curl, make sure the timestamp is in seconds since epoch in UTC:
date --utc -d "$date" '+%s'.
HTTP status code 204 expresses that have you successfully written data.
Try removing double quotes around fields. Double quotes, if they are sent, results in data are written in the text format.
However, if you have already written fields in the text format you cannot simply change it. Either change the measurement name (
ampguard) or rename fields.