Multiple retention policies for influxdb

It would be great to define retention policy for different sensors in the integration.
It could be one default retention policy for all and override by specify a different policy on a tag/measurement level.

InfluxDB retention policy is only defined at InfluxDB database level to my knowledge no ? You can’t override it from Home Assistant.
I’m not even sure you can define different retention policies for different users in InfluxDB. The only solution might be to use different InfluxDB databases, one for each retention policy. But is it doable to define several InfluxDB in Home Assistant configuration ? Maybe, I’ve never tried.

It should be possible to do. It is working like this from Node Red. There I can write to different retention policies. I would like to do this from HA and not take all data into NR to get it correct into Influx.
My request is to extend the HA integration to handle the posibility to use multiple retention policies.

1 Like

Nice, I didn’t know it was possible from Node Red. So it should definitely be possible from HA, I understand and support your request !

1 Like

It is possible to define multiple retention policies for the same database in influxdb, please see a very good tutorial of influxdb retention policies.

I echo @Mr.Morten and also really need to define a different retention policy for different sensors

A feature request has been submitted

1 Like

My input on this matter is this:
We need the ability to specify/override which retention policy the HA influxdb component writes data to.
Retention policies define how long data is stored in a database, each measurement can have data in one or more retention policies. We need the ability to control in which retention policy data is stored.
CQ in influxdb always downsamples data and this might not be the desired action for data which doesn’t need it.

A few examples of what I have in mind:

component_config_domain:
  climate:
    override_measurement: climate
    override_retention_policy: rp_90days

component_config_glob:
  sensor.*thermostat*:
    override_measurement: thermostat
    override_retention_policy: longterm

Another form, which uses influxdb syntax <retention_policy>.<measurement> could be:

component_config_glob:
  sensor.*thermostat*:
    override_measurement: longterm.thermostat

@friendodevil: I think the feature request is for HA influxdb component, not the “influxdb add-on” which is the InfluxDB itself. @frenck closed it there, I tried to open a new one but then I realised the confusion.

Saw that @frenck recommended to open it as a Home Assistant feature.

@isorin did you end up opening a feature request?

@friendodevil Sorry, I lost track of this issue, I thought this is the feature request, do we need to create a new one and call it “Ability to specify an InfluxDB retention policy”?

There did this request end?

Managed to use multiple retention policies using this tutorial :slight_smile: InfluxDB and Home Assistant (Part 2) | dummylabs.com

the attached link does not work. please send a new link to this guide. I am very interested. Thanks