---
title: "Deploy Prometheus | Open Source Monitoring, Datadog Alternative on Railway"
description: "Self host Prometheus. Time-series metrics, alerting, PromQL & more"
category: "Observability"
url: https://railway.com/deploy/prometheus
---

# Deploy Prometheus | Open Source Monitoring, Datadog Alternative on Railway

Self host Prometheus. Time-series metrics, alerting, PromQL & more

**[Deploy Prometheus | Open Source Monitoring, Datadog Alternative on Railway on Railway](https://railway.com/template/prometheus)**

- **Creator:** Heimdall
- **Category:** Observability
- **Total deploys:** 2

## Template content

### Prometheus https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/prometheus.svg

- **Source:** praveen-ks-2001/prometheus-railway
- **Public domain:** Yes

## Documentation

![Prometheus logo](https://observability.thomasriley.co.uk/prometheus/what-is-prometheus/images/logo.png?classes=shadow&amp;width=40pc)

# Deploy and Host Prometheus on Railway

Prometheus is the de-facto open source monitoring system and time-series database — it scrapes metrics from your services, stores them locally with high compression, and lets you query and alert on them via PromQL. Self-host Prometheus on Railway to keep application, infrastructure, and Kubernetes metrics in your own environment without per-host SaaS fees.

The template wraps `prom/prometheus:v3.11.3` (custom Dockerfile at `praveen-ks-2001/prometheus-railway`) with bcrypt-hashed HTTP basic auth, an auto-generated default `prometheus.yml`, and a persistent `/prometheus` volume. Web UI, `/metrics`, `/api/v1/*`, and health endpoints are all protected — safe on the public internet.

## Getting Started with Prometheus on Railway

After deploy, open the Railway domain — your browser prompts for HTTP basic auth. Log in with `ADMIN_USER` / `ADMIN_PASSWORD` from the Variables tab. The default config self-scrapes Prometheus on `localhost:9090`, so the UI is immediately useful: open **Status -&gt; Targets** to confirm scrape health, then run a query like `up` from the Graph tab. To monitor your own services, write a `prometheus.yml`, base64-encode it (`base64 -w0 prometheus.yml`), paste into `PROMETHEUS_CONFIG_B64`, and redeploy.

![Prometheus dashboard screenshot](https://res.cloudinary.com/asset-cloudinary/image/upload/v1777752818/bdb9d593-f6b8-4998-a628-c996ffb6ec78.png)

## About Hosting Prometheus

Prometheus is a CNCF graduated project originally built at SoundCloud. It pulls metrics over HTTP from instrumented targets (apps, exporters, Kubernetes pods), stores them in a local TSDB, and exposes PromQL for ad-hoc analysis, dashboards, and alert evaluation.

Key features of self-hosted Prometheus on Railway:

- Pull-based scraping with service discovery (static, DNS, file_sd)
- PromQL — vectorised queries with rate, histogram, aggregation operators
- Built-in TSDB, ~1KB per active series
- Recording and alerting rules (Alertmanager-compatible)
- Toggleable remote-write receiver and admin API
- HTTP basic auth on every endpoint by default

## Why Deploy Prometheus on Railway

- One-click deploy with `/prometheus` volume mounted automatically
- Public HTTPS domain auto-issued, basic auth from first boot
- Drop-in `prometheus.yml` via base64 env var — no SSH needed
- Vertical scaling as active series grow
- Pay only for the compute and storage you use
- Private networking to scrape Railway services over `*.railway.internal`

## Common Use Cases for Self-Hosted Prometheus

- Scrape Kubernetes clusters, Node Exporter, cAdvisor, and your own `/metrics` endpoints
- Pair with Grafana for dashboards (Grafana data source with basic auth)
- PromQL alerts evaluated on a schedule, fired to Alertmanager / Slack / PagerDuty
- Ingest from edge agents (Grafana Agent, OpenTelemetry Collector, Vector) via remote_write
- Replace Datadog/New Relic for metric pipelines without per-host billing

## Dependencies for Prometheus on Railway

- **Prometheus** — built on `prom/prometheus:v3.11.3`, repackaged via custom Dockerfile at [praveen-ks-2001/prometheus-railway](https://github.com/praveen-ks-2001/prometheus-railway). Multi-stage build copies the static Prometheus binary onto `python:3.12-slim` for entrypoint scripting and `bcrypt` password hashing.

### Environment Variables Reference

| Variable | Default | Purpose |
|---|---|---|
| `ADMIN_USER` | `admin` | Basic-auth username for UI and API |
| `ADMIN_PASSWORD` | `${{secret(32)}}` | Basic-auth password (bcrypt-hashed) |
| `PROMETHEUS_RETENTION_TIME` | `15d` | TSDB retention window |
| `PROMETHEUS_RETENTION_SIZE` | `0` | Max TSDB size (`0` = uncapped) |
| `PROMETHEUS_SCRAPE_INTERVAL` | `15s` | Default scrape interval |
| `PROMETHEUS_EVALUATION_INTERVAL` | `15s` | Default rule evaluation interval |
| `PROMETHEUS_LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` |
| `PROMETHEUS_ENABLE_ADMIN_API` | `false` | Enable snapshot/delete API |
| `PROMETHEUS_ENABLE_REMOTE_WRITE_RECEIVER` | `false` | Accept `remote_write` |
| `PROMETHEUS_CONFIG_B64` | (empty) | Base64 `prometheus.yml` override |

### Deployment Dependencies for Prometheus on Railway

- Runtime: Go binary from `prom/prometheus:v3.11.3`
- Source: [github.com/prometheus/prometheus](https://github.com/prometheus/prometheus)
- Docker Hub: [prom/prometheus](https://hub.docker.com/r/prom/prometheus)
- Custom wrapper: [github.com/praveen-ks-2001/prometheus-railway](https://github.com/praveen-ks-2001/prometheus-railway)
- Docs: [prometheus.io/docs](https://prometheus.io/docs/)

## Hardware Requirements for Self-Hosting Prometheus

| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 0.5 vCPU | 1–2 vCPU |
| RAM | 512 MB | 2 GB (~1KB per active series) |
| Storage | 1 GB volume | 5–20 GB |
| Runtime | Go 1.22 (bundled) | Go 1.22 (bundled) |

512 MB handles a few thousand series. Heavy Kubernetes fleets with millions of active series should plan ~1KB/series plus query headroom.

## Self-Hosting Prometheus with Docker

The plain `prom/prometheus` image runs out of the box but has no auth — this template wraps it with basic auth for production. The simplest local equivalent:

```
docker run -d --name prometheus -p 9090:9090 \
  -v prometheus_data:/prometheus \
  prom/prometheus:v3.11.3
```

To use a custom scrape config on Railway, write the YAML below, run `base64 -w0 prometheus.yml`, paste into `PROMETHEUS_CONFIG_B64`, and redeploy:

```
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: my-app
    static_configs:
      - targets: ['my-app.railway.internal:8080']
```

The entrypoint decodes the config on every boot — no rebuild needed.

## How Much Does Prometheus Cost to Self-Host?

Prometheus is 100% free under Apache 2.0 — no enterprise tier, no per-host fees, no metric ingestion limits. The only costs are infrastructure and engineering time. On Railway, expect a few dollars a month for a 512 MB / 1 GB volume instance scraping a handful of services. Compare to Grafana Cloud's metered pricing (~$6.50 per 1K active series after the free tier) or Datadog's $15+ per host per month.

## Prometheus vs Datadog vs Grafana Cloud vs VictoriaMetrics

| | Prometheus (self-hosted) | Datadog | Grafana Cloud | VictoriaMetrics |
|---|---|---|---|---|
| License | Apache 2.0 | Proprietary SaaS | Proprietary SaaS | Apache 2.0 |
| Pricing | Infra only | Per host + ingest | Per active series | Infra only |
| PromQL | Native | Compatible | Native (Mimir) | Native |
| Best for | Owning your stack | All-in-one APM | Managed Prom + Loki | High-cardinality |

Self-hosted Prometheus wins on control, predictable cost, and PromQL-native pipelines. Pair with Grafana for dashboards and Alertmanager for routing.

## FAQ

**What is Prometheus and why self-host it?**
Prometheus is an open-source metrics database and monitoring system. Self-hosting on Railway keeps your metrics in your own environment, avoids per-host SaaS fees, and gives you full control over retention and scrape configs.

**What does this Railway template deploy?**
A single Prometheus service running `prom/prometheus:v3.11.3` behind HTTP basic auth, with a `/prometheus` volume for TSDB persistence and a base64 env var (`PROMETHEUS_CONFIG_B64`) to drop in your own scrape config.

**Why does this Prometheus template require a persistent volume?**
The TSDB writes blocks to `/prometheus` every two hours and compacts older blocks. Without a volume, every redeploy wipes your historical metrics.

**How do I add custom scrape targets to self-hosted Prometheus on Railway?**
Write a `prometheus.yml`, run `base64 -w0 prometheus.yml`, paste the output into `PROMETHEUS_CONFIG_B64`, and redeploy. The entrypoint decodes the config and starts Prometheus with it.

**How do I connect Grafana to self-hosted Prometheus on Railway?**
In Grafana, add a Prometheus data source pointing at `https://`, set auth type to Basic auth, and enter `ADMIN_USER` / `ADMIN_PASSWORD`. PromQL works identically to a local Prometheus.


## 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/prometheus
