Delete selected old data from InfluxDB

Hi,
I am using InfluxDB to store power consumption data. The Z wave module reports data every few seconds and I am using “Utility Meter” to aggregate data hourly, daily, weekly etc.

I would like to delete the raw data reported by the Utility Meter that is older than a month and keep only the value generated by the Utility Meter… is this possible?

thanks in advance!

How about a retention policy? You can configure the DB to drop measurements after a certain time.

https://docs.influxdata.com/influxdb/v1.7/guides/downsampling_and_retention/

The retention is disabled. I would like to keep all data except the raw values

I would like to delete the raw data reported by the Utility Meter that is older than a month and keep only the value generated by the Utility Meter

What are the raw values of the utility meter vs. the generated value?

The raw values are genereted every 20sec. Then I aggregate the values every hour, day, weekly, monthly.

Guess I’m trying to clarify, are the raw values from the utility meter entity, or from the zwave entity?

I was going to suggest, if you don’t need the raw values and they are coming from the zwave entity, then you could just exclude them from influxdb entirely. But, since you’re storing them presumably you do want them for sub-hour data.

Otherwise, I think you would want to do something with multiple retention policies and a continuous query. Make the 30-day policy the default and with a CQ write the data you want to save to the no-retention policy. Or something like that.

Or, I suppose you could DELETE series. You would need to do that on your own, via some sort of command line script and an automation, or outside of HA.

The Influx python API that HA is using has the ability to set a retention policy when writing data points, but the HA integration does not have the ability to use it. Theoretically you could write the raw values with a non-default retention policy, while the utility meter values are written to the policy with infinite retention.

hi freshcoast, thanks for following up. The below diagram shows were I am using the RAW data (left graphs), the other graphs are being generated by the Utility Meter config.

I will out the DELETE suggestion, I dont mind if I have to do it manually every month or so, but also think I can do it from Node-Red … will keep you posted.

1 Like