I am looking through all the InfluxDB examples, and they all seem to insert with "time now" (time of insert). There is a well-defined "time" field, but none of the examples use it.
Recording the time of an event as "insert time into the DB" is a poor pattern. It's always better to have the sensor attach to the sensor value its idea of the current time, pass that record around, and insert into various analytics DBs with that time value. ( really small sensors might have a "controller" that knows time better, but that's still not the database insert ).
An obvious example is log files. Each line has a timestamp, right at the beginning. Love it or hate it, but that's your best view of the time the event happened.
I'm looking for examples of inserting into InfluxDB with a specified time value, and haven't come up with one yet. Time appears to always be the implied current time.
Simply specify a timestamp
along side your tags and values in your points, see here for examples:
https://docs.influxdata.com/influxdb/v1.3/guides/writing_data/#writing-data-using-the-http-api
Docs for the 0.9 version :
http://influxdb.com/docs/v0.9/concepts/schema_and_data_layout.html
If you are using 0.8, then you'll want your points to start with a time
column instead:
http://influxdb.com/docs/v0.8/api/reading_and_writing_data.html
Yes, it's perfectly possible. You just have to specify a "time" column together with a value field. For instance:
{
name: "my_serie",
columns: ["time", "value1", "value2"],
points: [
[1429807111, 1, 2],
[1429807111, 11, 22],
[1429807111, 111, 222]
]
}
Of course you can specify as many columns as you want.
In the influx CLI, you can add the timestamp at the end of the line, in nanosecond-precision Unix time, per the Line Protocol:
$ influx
Connected to http://localhost:26131 version 1.3.5
InfluxDB shell version: 1.3.5
> insert log value=1 1504225728000123456
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With