Adding InfluxDB did not nuke my data

Hey,

I was adding influxdb and mariadb to optimize my instance and I noticed that after adding influxdb my sensor historic data did not disappear but after I also added mariadb it did.
Have I misconfigured influxdb and it still writing data into maria/sqlite or is it that influx has a graceful data handling?

recorder:
  db_url: !secret mariadb_url
  purge_keep_days: 30
  commit_interval: 20
  exclude:
    domains:
      - automation
      - update
      - sensor
      - binary_sensor
    entity_globs:
      - sensor.sun*
      - weather.*
    entities:
      - sensor.date
      - sensor.last_boot # Comes from 'systemmonitor' sensor platform
      - sun.sun # Don't record sun data
    event_types:
      - call_service # Don't record service calls
influxdb:
  api_version: 2
  ssl: false
  host: !secret influx_host
  port: 8086
  token: !secret influxdb_token
  organization: !secret influxdb_org
  bucket: !secret influxdb_bucket
  tags:
    source: HA
  tags_attributes:
    - friendly_name
  default_measurement: units
  # exclude:
  #   entities:
  #     - zone.home
  #   domains:
  #     - persistent_notification
  #     - person
  include:
    domains:
      - sensor
      - binary_sensor
  #     - sun
  #   entities:
  #     - weather.home

Influxdb does not replace recorder. It works in parallel.

So when I added influxdb it was reading sqlite+influx data but maria replaces sqlite outright and I was looking at mariadb+influx but on replacing it did have any sqlite data, so hence it looked like the data got dumped. I understand now.
Went to influx web panel and data is being sent there, so it looks like it is working!

SQLite is the default HA recorder database engine. When you switched over to MariaDB, it completely replaced SQLite and thus all of the historical data was deleted.

InfluxDB is a data historian, that HA pushes data to and is independent of the SQLite/MariaDB databases.

None of the built-in HA charting tools use InfluxDB. They all look to the HA recorder DB (i.e. SQLite or MariaDB). InfluxDB is a completely separate data historian. Most use Grafana to create dashboards based on the InfluxDB data.

@ogiewon said it better than me.

1 Like

Now I understand! Well am still confused but I understand.
I was getting confused because in the recorder section I excluded sensor data because i thought HA is going to use (read) influxdb for that data but when I would look at History tab for sensors while using mariadb+influxdb configuration and I would not see updates but then I check influxdb directly it had data coming to it. I though maybe I got something misconfigured and because of it data is not being from influx.

Now I understand that influxdb is effectively a sensor backup/export. What now confuses me… why not just use/integrate into HA? Influxdb is optimized for timeseries data and if you already have an instance running.

EDIT: Less confused.
I presumed that “Sensor” section in Home assistant’s influxdb documentation page was not to monitor the database itself but exactly for what I was looking for for reading sensor data from influxdb to display sensor data inside of HA. However, influxdb version 2 syntax for doing looks… well messy.

1 Like