Search code examples
epochinfluxdb

Saving EPOCH time value in user define column in influxDB


I am using InfluxDB and want to write Epoch time values in user define column as shown below in v1 field.

cpu_load,host=server01,core=0 value=0.45,v1=1437171724
cpu_load,host=server01,core=0 value=0.45,v1=1437171725

Now, how can i query this column just like i can query regular time based column

select * from cpu_load where v1 > '2016-08-31 00:42:24.000'

This query is not working, however if i switch v1 with time column it works just fine.

select * from cpu_load where time > '2016-08-31 00:42:24.000'

Wondering how can i use user define time/column value in InfluxDB?


Solution

  • InfluxDB only supports field types of string, integer, float, and boolean.

    The time column is a special case. Even though it is stored as an integer under the hood, only the time field can be filtered with time based constraints.

    There is a longstanding feature request to allow comparison of fields to time.

    In the meantime, the raw integer Epoch time value can be used to set a constraint on the v1 field. E.g.

    select * from "cpu_load" where "v1" > 1472604144000