8
votes

Is it possible to treat different measurements in influxdb with different a retention policy?

1
I'm not sure I understand the question. What would you like to do?Michael Desa
I want to collect sensor data into one database from 2 kinds of sensors. Data from type 1 should expire at another age than that from sensor type 2.p0fi

1 Answers

13
votes

This is entirely possible with InfluxDB. To do this you'll need to create a database that has two retention policies and then write the data to the associated retention policy.

Example:

$ influx
> create database mydb
> create retention policy rp_1 on mydb duration 1h replication 1
> create retention policy rp_2 on mydb duration 2h replication 1

Now that our retention policies have been created we simple write data in the following manner:

Sensor 1 will write data to rp_1

curl http://localhost:8086/write?db=mydb&rp=rp_1 --data-binary SOMEDATA

Sensor 2 will write data to rp_2

curl http://localhost:8086/write?db=mydb&rp=rp_2 --data-binary SOMEDATA