InfluxDB size sensor

I have this sensor for reporting my InfluxDB database size:

- platform: influxdb
  host: a0d7b954-influxdb
  port: 8086
  username: homeassistant
  password: !secret influxdb_pssword
  queries:
    - name: InfluxDb DB Size
      unit_of_measurement: MB
      value_template: '{{ (value | float / 1024 /1024) | round(1) }}'
      group_function: sum
      measurement: '"monitor"."shard"'
      database: _internal
      where: 'time > now() - 10s'
      field: diskBytes

Unfortunately when it is unavailable (once or twice a day) it reports 0 instead of unavailable which makes graphing the minimum daily size in Grafana difficult.

Does anyone have a better approach?

I´d use a filter sensor to get the outliers filtered out.

- platform: filter
  name: influxdb_db_size filtered
  entity_id: sensor.influxdb_db_size
  filters:
    - filter: outlier
      window_size: 2
      radius: 70
1 Like

I’m doing that in the grafana query, but I’d still prefer to have a more reliable sensor.