Prometheus on Steroids: High-Performance Metrics with VictoriaMetrics

Prometheus is great. But it uses a lot of RAM. And long-term storage? That's a headache involving Thanos or Cortex.

VictoriaMetrics solves this. It's a drop-in replacement for Prometheus that:

  1. Uses 10x less RAM.
  2. Compresses data 7x better.
  3. Supports the Prometheus API (so Grafana works out of the box).

The Setup

We will run VictoriaMetrics (storage) and vmagent (scraper).

version: '3.5'
services:
  vmagent:
    container_name: vmagent
    image: victoriametrics/vmagent:latest
    depends_on:
      - "victoriametrics"
    ports:
      - 8429:8429
    volumes:
      - vmagentdata:/vmagentdata
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - "-promscrape.config=/etc/prometheus/prometheus.yml"
      - "-remoteWrite.url=http://victoriametrics:8428/api/v1/write"

  victoriametrics:
    container_name: victoriametrics
    image: victoriametrics/victoria-metrics:latest
    ports:
      - 8428:8428
    volumes:
      - vmdata:/storage
    command:
      - "-storageDataPath=/storage"
      - "-retentionPeriod=12" # 12 months retention

  grafana:
    container_name: grafana
    image: grafana/grafana:latest
    depends_on:
      - "victoriametrics"
    ports:
      - 3000:3000

volumes:
  vmagentdata: {}
  vmdata: {}

The Config (prometheus.yml)

This is standard Prometheus config. vmagent reads it and scrapes targets.

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'vmagent'
    static_configs:
      - targets: ['localhost:8429']
  - job_name: 'victoriametrics'
    static_configs:
      - targets: ['victoriametrics:8428']

Why Switch?

Because efficiency matters. If you can store a year of metrics on a $5 VPS instead of a $50 dedicated server, why wouldn't you?

Switch your Grafana Data Source URL to http://victoriametrics:8428. That's it. You're done.

Leave a comment

👁️ Views: 979