I’m using VictoriaMetrics in combination with Home Assistant for a couple of months now, and I am pretty pleased with it. It runs very stable, and the database size remains within limits. I run both HA and VM in docker containers, and wanted to share my configuration for those who would like to run the same, or a similar setup.
Here is my docker compose file to start the VM service, and to have the VM data stored in an external data container:
I use the influxDB integration of HA to write to the VM database, so I don’t need a VM agent and prometheus configuration. Note that I do not use an Influx database, I only use the HA integration. In my configuration.yaml file I have added:
That’s it. In Grafana I can now choose to use the VM database as InfluxDB Timeseries Database, or as Prometheus Timeseries Database, or both. Both work, but use a different query language.
I have about 1000 HA entities, and my VM database grows about 1 MB per day.
@CreebleHoost , thanks for sharing your configs! They look great except one thing - it is better to specify a particular release tag for victoriametrics instead of latest, since the latest tag may point to some testing release. For example, it is much better to use v1.90.0 instead of latest. It is also recommended periodically checking VictoriaMetrics changelog for new releases.
Thanks, that is a good suggestion. Ideally there would also be a stable release tag. Then I would get the release with the latest fixes, without running the risk of getting experimental code.
Typically I don’t check manually if there are new stable releases available. Not only for VM, but for any docker.
For migrating your influxdb data you should use the vmctl tool from victoria metrics. You can use it on your host or any other linux machine.
In this thread you might find some hints using it:
The bug i posted is sorted out and it runs without any errors even if you have empty measurements.
Using the config suggested above, I’m getting ..._value and a ..._state metric for each binary_sensor when looking at the data via Grafana (using the VictoriaMetrics plugin for connection). And a light goes between 1 and 0 for on vs off. Is this by design or a misconfiguration on my part? Is there a way to have the actual states (occupied, on, etc) tracked? I also don’t see the UX to do things like aggregate (e.g., average for each hour, etc). Perhaps user error here?
I have a fundamental question concerning the feeding of measurements to VM if using the influxdb integration:
Is there a fix schedule when all metrics are pushed to VM (say 1min or 1sec or…) or is every metric only pushed if it has changed?
And if the former: is there a way to adjust the interval?
If I use prometheus integration I can set the interval for scraping myself.
A time-based push would lead to much redundancy (or does VM suppress doublettes internally?) but with pushing on-change only, I’d imagine future downsampling would be tricky?
Prefer using Home Assistant’s Prometheus integration rather than its InfluxDB one. VictoriaMetrics supports InfluxDB data sources but it really seems like it’s more designed for Prometheus-compatible ones.
I’m just using VictoriaMetrics’ web UI (VMUI) at the moment. Haven’t gotten around to setting up Grafana yet. VMUI is pretty good for ad-hoc queries. I was just using it today to check the daily peak output reached by my solar power system for the past six months:
I haven’t used InfluxDB for a long time, but I reduced the size of one of my DBs from 43GB to 15GB by switching from Prometheus to VictoriaMetrics. This particular DB was for server monitoring. 2 years of data, ~70k time series, with most metrics logged once per minute.
VictoriaMetrics (and Prometheus) are time series databases, which means they can only store numbers and how those numbers change over time, with tags per time series (entity name, etc). Boolean values (true/false, on/off) are always logged as 0 and 1. Do you have a use case where this isn’t sufficient?