Inserting with a specific time?

Brian Bulkowski picture Brian Bulkowski · Apr 20, 2015 · Viewed 18.3k times · Source

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.

Answer

Mahn picture Mahn · Apr 22, 2015

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