InfluxDB vs VictoriaMetrics

I just recently noticed a problem with my long term storage and after some digging around I realized my InfluxDB container must have, at some point, updated to 2.x while my HA config was still setup for 1.x. With some effort, I’m now up and running with InfuxDB 2 but struggling with the syntax within Grafana. InfluxDB has its own query builder in its UI, as well as data display and panels, so I guess I could just use this and do away with Grafana… or build the query there and paste it into Grafana (but at this point seems more of a hassle).

In all of this I stumbled upon VictoriaMetrics and with a little effort I now have that configured with HA as well. Grafana can build queries for VictoriaMetrics so it’s easier to use than InfluxDB 2 (if I want to stay with Grafana).

So I’ve got both running now, and doing some quick compares, both seem to be capturing the data as expected. I’m curious about other’s experience with either InfluxDB 2 or VictoriaMetrics. Those who updated to InfluxDB 2 are you using Grafana or InfluxDB UI? Anyone prefer VictoriaMetrics over InfluxDB for HA? Other thoughts or opinions from long time users of either?

Side note: I’m not going to use the latest tag for docker compose anymore.

1 Like

I have not used InfluxDb/Grafana much since it changed to v2 for the same reason. I think to myself 'you’re saving the data so you can worry about interogating it tomorrow)".

Can you share your docker-compose for Victoria and any HA config that was necessary for it (or point to to where I can find it out) - I’ll give it a go.


[edit]
This seems to work for VM itself

victoriametrics:
  container_name: victoriametrics
  image: victoriametrics/victoria-metrics:latest
  ports:
    - 8428:8428
  volumes:
    - ./victoria-metrics-data:/victoria-metrics-data
  environment:
    - TZ=Europe/London
  restart: unless-stopped

…used latest just for the trial. Trying to goggle what the HA config is but canl;t see much info on that. I am running Container so cannot use the add-on.


[edit]
OK found the docker-compose here.

Here’s my relevant docker compose entries…

  vmagent:
    container_name: vmagent
    image: victoriametrics/vmagent:v1.80.0
    depends_on:
      - "victoriametrics"
    volumes:
      - $HOME/docker/vmagentdata:/vmagentdata
      - $HOME/docker/vmprometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - "--promscrape.config=/etc/prometheus/prometheus.yml"
      - "--remoteWrite.url=http://192.168.0.97:8428/api/v1/write"
    network_mode: host
    restart: always

  victoriametrics:
    container_name: victoriametrics
    image: victoriametrics/victoria-metrics:v1.80.0
    volumes:
      - $HOME/docker/vmdata:/storage
    command:
      - "--storageDataPath=/storage"
      - "--graphiteListenAddr=:2003"
      - "--opentsdbListenAddr=:4242"
      - "--httpListenAddr=:8428"
      - "--influxListenAddr=:8089"
      - "--vmalert.proxyURL=http://vmalert:8880"
    network_mode: host
    restart: always

…with my machine’s IP being 192.168.0.97 for the --remoteWrite.url command.

The rest of the setup involves turning on the Prometheus integration and then using this prometheus.yml

scrape_configs:
  - job_name: "hass"
    scrape_interval: 60s
    metrics_path: /api/prometheus
    bearer_token: "your token"
    scheme: http
    static_configs:
      - targets: ['192.168.0.97:8123']

…which is used by vmagent and referenced by one of it’s volumes ($HOME/docker/vmprometheus/prometheus.yml:/etc/prometheus/prometheus.yml).

2 Likes

awesome - thanks. I was halfway there but this is super helpful.

is $HOME defined in your .env file?

…no, it’s just another way to reference the user’s home directory (similar to ~/).

cool. Is that OS specific?

…I’ve got it up and running so will play around with it now - thanks for your help!

…it could be, but not too sure. I’m running everything on a raspberrypi… on a win10 machine $HOME works in PowerShell but not in CMD.

Glad it was of some use, and I’m interested in what you find. I’m not too experienced in the inner workings of databases but I’m going to run both for a few weeks and try to compare. It seems like InfluxDB is not concerned with compatibility so I’m leaning towards VictoriaMetrics (works with Grafana and compatible with Prometheus ecosystem), but slightly hesitant because it doesn’t seem to be as widely adopted (at least not by HA community).

1 Like

I have been doing a little playing and reading the docs etc. It seems easier to query which is good.

For docker-compose, you might want to check out retentionPeriod which has a default of 1 month (not long). The only 2 commands I have found I need (so far) for it to work with HA is:

command:
  - "--retentionPeriod=3y"                # default is "1 m"
  - "--storageDataPath=/storage"

Also playing with - --selfScrapeInterval=60s to enable self-monitoring in a Grafana dashboard, but I am getting an error in Grafana (Failed to upgrade legacy queries Datasource was not found). The dashboard to import is here. I need to read up a little more on this.

Also worth noting the command - --downsampling.period=30d:5m,180d:1h incase you need to claim space back later. The explanation is here.

3 Likes

@jchh thanks for this info! I think you also need the --httpListenAddr=:8428 command (at least I do) and could be why you’re not seeing the self scrape results??? I’ve reduced my victoriametrics entry in docker-compose.yml to:

  victoriametrics:
    container_name: victoriametrics
    image: victoriametrics/victoria-metrics:v1.80.0
    volumes:
      - $HOME/docker/vmdata:/storage
    command:
      - "--storageDataPath=/storage"
      - "--httpListenAddr=:8428"
      - "--retentionPeriod=3y"
      - "--selfScrapeInterval=60s"
      #- "--downsampling.period=30d:5m,360d:1h"
    network_mode: host
    restart: always

I don’t have the down sampling part working yet.

thanks for that! …with that extra line we are pretty much identical. The error was in Grafana not VictoriaMetrics but I;ll give it a go and let you know what happens.

I would also change restart: always to restart: unless-stopped as a general rule incase you want it stopped manually fore some reason.

Regarding downsampling… as far as I can tell it’s only available on the Enterprise version, which, I assume, is a paid version.

good info - thanks!

This link downloads the correct JSON to create a VM monitoring dashboard in Grafana.

1 Like

I was using InfluxDB for some years and now i switched to VictoriaMetrics. I tried Influx2 but it was not my friend and is no fun in combination with Grafana. So the search for alternatives began and VictoriaMetrics is the way to go. Because i am using Home Assistant OS (Hass.io) on a RaspberryPi 4 and wanted to run Victoria Metrics on the same system i created VictoriaMetrics as Add-on for Home Assistant.

Maybe you are interested in Victoria Metrics Add-on for Homeassistant

1 Like

Very kind of you to share! I currently use HA docker so cannot use add-ons. However I will bookmark that link in case things change for mew :slight_smile:

There is an official docker Image of victoriametrics for all platforms, too. I can send you a docker-compose.yml and some examle config of you like. I used this for testing in a ARM MacBook m1 before i created the addon.

I have been using the official docker image since the start of this thread :slight_smile:

The title of this thread was " InfluxDB vs VictoriaMetrics"

What I read is InfluxDB 1.x was what people were using. InfluxDB 2.x is different and not so HA friendly.
Q1: Is it likely that InfluxDB 1 will become unsupported, stop working at some version change and leave the HA Grafana community with a broken solution

If Q1 would the HA community not be migrating or planning to migrate to something else?
Clearly the positive voices and contributors to community solutions in this thread have already moved away from InfluxDB

Q2: Do we think the HA community will move enmass to victoria metrics or is there some other time based DB the community will flock to (and support)?

Q3: How resource intensive is Victoria Metrics? Do I read correctly it has the least resource requirements of the time based DBs I might use?
[The question is can I run it (happily) on my Pi - B 1GB?
I know I could do with a better PI its on the list for when they become generally available again]

Any thoughts or answers gratefully received :slight_smile:

@ fuslwusl
or anyone using this add-on

Does this add-on auto-update the Victoria Metrics code/ executable?

Do I have to have a PI4?
“This Add-on makes it easy to run a Victoria Metrics Time Series Database on your Home Assistant OS on ARM64 systems like Raspberry Pi 4.”
( homeassistant-addon-victoriametrics/victoria-metrics at main · fuslwusl/homeassistant-addon-victoriametrics · GitHub )

Q3: How resource intensive is Victoria Metrics? Do I read correctly it has the least resource requirements of the time based DBs I might use?

Correct, VM is not (relatively) resource intensive.

The question is can I run it (happily) on my Pi - B 1GB?

Not sure what a Pi B is (it runs fine on my Pi 4b 2Gb though) alongside HA (docker) and a bunch of other things.