---
title: "Deploy VictoriaMetrics"
description: "Time-series database for storing and querying metrics"
category: "Observability"
url: https://railway.com/deploy/victoria-metrics
---

# Deploy VictoriaMetrics

Time-series database for storing and querying metrics

**[Deploy VictoriaMetrics on Railway](https://railway.com/template/victoria-metrics)**

- **Creator:** A3A
- **Category:** Observability

## Template content

### vminsert https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Image:** victoriametrics/vminsert:v1.151.0-cluster
- **Start command:** `/bin/sh -c '[ -n "$VMSTORAGE_HOST" ] || VMSTORAGE_HOST=vmstorage.railway.internal; exec /vminsert-prod -enableTCP6 -httpListenAddr=:$PORT -storageNode=$VMSTORAGE_HOST:8400'`
- **Health check:** /health

### vmstorage https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Image:** victoriametrics/vmstorage:v1.151.0-cluster
- **Start command:** `/bin/sh -c 'exec /vmstorage-prod -enableTCP6 -httpListenAddr=:$PORT -storageDataPath=/storage/data -retentionPeriod=$VM_RETENTION_PERIOD -vminsertAddr=:8400 -vmselectAddr=:8401'`
- **Health check:** /health

### alertmanager https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/alertmanager-dark.svg

- **Source:** https://github.com/gridalpha/victoriametrics-railway
- **Health check:** /api/v2/status

### vmalert https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Source:** https://github.com/gridalpha/victoriametrics-railway
- **Health check:** /health

### vmagent https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Source:** https://github.com/gridalpha/victoriametrics-railway
- **Health check:** /health

### vmselect https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Image:** victoriametrics/vmselect:v1.151.0-cluster
- **Start command:** `/bin/sh -c '[ -n "$VMSTORAGE_HOST" ] || VMSTORAGE_HOST=vmstorage.railway.internal; [ -n "$VMALERT_HOST" ] || VMALERT_HOST=vmalert.railway.internal; exec /vmselect-prod -enableTCP6 -httpListenAddr=:$PORT -storageNode=$VMSTORAGE_HOST:8401 -vmalert.proxyURL=http://$VMALERT_HOST:8880'`
- **Health check:** /health

### vmauth https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/victoriametrics-light.svg

- **Source:** https://github.com/gridalpha/victoriametrics-railway
- **Health check:** /health
- **Public domain:** Yes

## Documentation

![VictoriaMetrics logo](https://miro.medium.com/v2/resize:fit:1400/1*90WIilajuGP_t7nH5tLyFw.png)

# Deploy and Host VictoriaMetrics on Railway

VictoriaMetrics is an open-source time-series database and monitoring stack that speaks the Prometheus remote-write and query APIs, so anything already writing to Prometheus can write to it unchanged. Teams adopt it when one Prometheus server stops being enough: it stores the same metrics in far less disk space, answers queries over months of history, and separates ingestion from querying so a dashboard cannot stall a scrape. It serves as long-term storage behind Grafana, as a drop-in Prometheus replacement, and as a metrics backend for teams who would rather run one dependency than a stack of sidecars.

Deploy VictoriaMetrics in its cluster shape rather than as a single box. Seven services come up together: `vmstorage` holds the data on a persistent volume, `vminsert` accepts writes and shards them across storage nodes, `vmselect` answers MetricsQL and PromQL queries, and `vmauth` is the only public service, authenticating every request and routing it to the right tier. `vmagent` scrapes each component back into the cluster, `vmalert` evaluates the project's rules, and Alertmanager delivers what fires. Everything but the gateway stays private.

![Diagram of the seven VictoriaMetrics cluster services on Railway](https://res.cloudinary.com/rroe4rtk/image/upload/v1788210290/victoriametrics-architecture.png)

## Getting Started with VictoriaMetrics on Railway

Set a username and password at deploy time — the only credentials in the stack, guarding every route on the public domain. Open the public URL and you land in VMUI, the built-in query interface, scoped to tenant `0`. Type `up` and press Execute: seven series come back, one per service, because the bundled scraper already monitors the cluster itself. That query alone confirms writes, storage and reads all work.

Point your own metrics at it next. Prometheus, vmagent, an OpenTelemetry collector or Grafana Alloy can remote-write to `https:///insert/0/prometheus/api/v1/write` with basic auth. In Prometheus:

```
remote_write:
  - url: https://your-app.up.railway.app/insert/0/prometheus/api/v1/write
    basic_auth:
      username: admin
      password: your-password
```

For Grafana, add a Prometheus datasource pointing at `https://` with basic auth — the gateway maps `/api/v1/*` onto tenant `0`, so the bare domain is a working datasource URL. VMUI's Explore menu opens the cardinality explorer, and the Alerting menu opens the rule browser.

![VMUI graphing checkout request rates across three regions](https://res.cloudinary.com/rroe4rtk/image/upload/v1788210293/victoriametrics-vmui-graph.png)

![VMUI cardinality explorer listing the highest-cardinality metric names](https://res.cloudinary.com/rroe4rtk/image/upload/v1788210295/victoriametrics-cardinality-explorer.png)

![vmalert showing the bundled cluster health alerting rules](https://res.cloudinary.com/rroe4rtk/image/upload/v1788210296/victoriametrics-vmalert-rules.png)

## About Hosting VictoriaMetrics

VictoriaMetrics solves the problem every growing Prometheus deployment hits: retention. Prometheus is built for short local retention and no clustering, so long history usually means bolting on Thanos or Cortex. VictoriaMetrics is one project covering ingestion, storage, querying and alerting.

- **MetricsQL** — a PromQL superset, so existing dashboards keep working
- **Wide ingestion support** — Prometheus remote write, InfluxDB line protocol, Graphite, OpenTSDB, DataDog, CSV and JSON import on one endpoint
- **Aggressive compression** — far less disk per sample than Prometheus' TSDB, which is what makes long retention affordable
- **Multi-tenancy** — an account ID in the URL path separates teams
- **Cardinality tooling** — an explorer for the labels quietly inflating your series count

Writers reach only `vminsert`, readers only `vmselect`. Because those tiers are separate Railway services, a query storm cannot slow ingestion.

## Why Deploy VictoriaMetrics on Railway

Railway runs the full cluster shape with no orchestration work.

- Seven services deploy in one click, wired together
- Persistent volumes for metrics, the scrape queue and alert state
- Private networking keeps every tier but the gateway off the internet
- A public HTTPS domain with authentication in front
- Scale ingestion, query or storage independently

## Common Use Cases

- **Long-term Prometheus storage** — remote-write existing servers here and keep months of history without Thanos
- **Central metrics for many services** — one endpoint, tenant IDs separating teams
- **Grafana backend** — point dashboards at the gateway, in PromQL or MetricsQL
- **Infrastructure monitoring** — pair with node_exporter, cAdvisor or OpenTelemetry and alert on it

## Dependencies for VictoriaMetrics

Every service runs an official image, all on the same version:

- `victoriametrics/vmstorage:v1.151.0-cluster` — samples and index on a volume
- `victoriametrics/vminsert:v1.151.0-cluster` — accepts writes, shards them across storage
- `victoriametrics/vmselect:v1.151.0-cluster` — executes queries, serves VMUI
- `victoriametrics/vmauth:v1.151.0` — authenticating gateway, the only public service
- `victoriametrics/vmagent:v1.151.0` — scrapes the cluster, writes it back
- `victoriametrics/vmalert:v1.151.0` — evaluates alerting and recording rules
- `prom/alertmanager:v0.28.1` — groups firing alerts and delivers notifications

Components must run the same VictoriaMetrics version — move every tag together when you upgrade.

### Environment Variables Reference

| Variable | Service | Purpose |
|---|---|---|
| `VM_USERNAME` | vmauth | Username for the public gateway |
| `VM_PASSWORD` | vmauth | Password for the public gateway |
| `VM_RETENTION_PERIOD` | vmstorage | How long samples are kept (`1` = a month) |
| `ALERT_WEBHOOK_URL` | alertmanager | Optional webhook for alert delivery |
| `VMALERT_EVALUATION_INTERVAL` | vmalert | How often rules are evaluated |
| `VM_INTERNAL_AUTH_KEY` | vmauth | Optional key guarding the gateway's metrics endpoints |

Host variables such as `VMSTORAGE_HOST` are pre-wired to Railway's private domains and need no attention.

### Deployment Dependencies

- Source: [github.com/VictoriaMetrics/VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics)
- Docs: [docs.victoriametrics.com](https://docs.victoriametrics.com)
- Images: [hub.docker.com/u/victoriametrics](https://hub.docker.com/u/victoriametrics)
- Alertmanager: [github.com/prometheus/alertmanager](https://github.com/prometheus/alertmanager)

## Hardware Requirements for Self-Hosting VictoriaMetrics

| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 2 vCPU total | 4+ vCPU, weighted to vmselect and vmstorage |
| RAM | 2 GB total | 8 GB+, most of it on vmstorage |
| Storage | 5 GB volume | Sized from series count, retention |
| Runtime | Linux container | Same for all components |

Memory on `vmstorage` scales with active series, not sample volume — cardinality is the number to watch.

## Self-Hosting VictoriaMetrics

The single-node build is one binary, and the right starting point elsewhere:

```
docker run -d --name victoriametrics \
  -p 8428:8428 \
  -v vmdata:/victoria-metrics-data \
  victoriametrics/victoria-metrics:v1.151.0 \
  -storageDataPath=/victoria-metrics-data -retentionPeriod=12
```

The cluster version splits that into three processes; storage listens on two internal ports:

```
vmstorage -storageDataPath=/storage -vminsertAddr=:8400 -vmselectAddr=:8401
vminsert  -storageNode=vmstorage:8400
vmselect  -storageNode=vmstorage:8401
```

Every component listens and dials on IPv4 only unless started with `-enableTCP6`, which this template sets.

## Is VictoriaMetrics Free?

VictoriaMetrics is open source under the Apache 2.0 licence, cluster version included, with no seat, series or retention limit. The company sells an enterprise edition adding downsampling and backup automation, plus a managed cloud, but nothing here depends on either. On Railway you pay only for the compute and volumes the services use.

## VictoriaMetrics vs Prometheus and Thanos

| | VictoriaMetrics | Prometheus | Thanos |
|---|---|---|---|
| Long-term storage | Built in | Local, short | Object storage |
| Clustering | Native, role-based | None | Layered on Prometheus |
| Query language | MetricsQL | PromQL | PromQL |
| Moving parts | One project | One binary | Several components |

Prometheus stays excellent at scraping and short-term storage; VictoriaMetrics is what goes behind it when history and scale matter. Against Thanos, fewer moving parts for the same outcome.

## FAQ

**What is VictoriaMetrics?**
An open-source, Prometheus-compatible time-series database and monitoring stack built for high ingestion rates, low disk usage and long retention.

**What does this Railway template deploy?**
A seven-service VictoriaMetrics cluster: storage, insert and select tiers, an authenticating gateway on the public domain, a scraper, a rule evaluator and Alertmanager.

**Why does the template include volumes and an alerting service?**
The storage tier writes metrics to disk and needs a volume that survives redeploys; the scrape queue and alert silences need their own. The alerting services turn stored metrics into notifications rather than dashboards someone has to watch.

**How do I send metrics to self-hosted VictoriaMetrics?**
Remote-write from Prometheus, vmagent, an OpenTelemetry collector or Grafana Alloy to `/insert/0/prometheus/api/v1/write` on your public domain, with the username and password you set at deploy time.

**How do I scale VictoriaMetrics on Railway?**
Add another storage service and list both in the `-storageNode` flags on insert and select, or raise replicas on insert and select, which keep no local state.


## Similar templates

- [Pyroscope profiling](https://railway.com/deploy/pyroscope-profiling) — Protected continuous profiling with durable Pyroscope storage.
- [SigOnly](https://railway.com/deploy/sigonly) — Deploy SigNoz with a working demo app & config in one click
- [Unwrapped Spotify Music Stats](https://railway.com/deploy/wide-bold) — Unwrapped Spotify Music Stats, Estatísticas de músicas disponíveis

Open this page in a browser: https://railway.com/deploy/victoria-metrics
