---
title: "Deploy Grafana Stack"
description: "Deploy and Host Grafana Stack with Railway"
category: "Analytics"
url: https://railway.com/deploy/grafana-stack-1
---

# Deploy Grafana Stack

Deploy and Host Grafana Stack with Railway

**[Deploy Grafana Stack on Railway](https://railway.com/template/grafana-stack-1)**

- **Creator:** self
- **Category:** Analytics

## Template content

### Grafana https://devicons.railway.app/Graf

- **Source:** devlzcode/grafana-stack

### Loki https://devicons.railway.app/Loki

- **Source:** devlzcode/grafana-stack

### Alloy https://devicons.railway.app/Alloy

- **Source:** devlzcode/grafana-stack

### Prometheus https://devicons.railway.app/Prom

- **Source:** devlzcode/grafana-stack

## Documentation

# Deploy and Host Grafana Stack on Railway

Grafana Stack is an integrated observability bundle: Grafana for dashboards and alerts, Prometheus for metrics, Loki for logs, and Alloy as a single OpenTelemetry collector. Applications send telemetry via OTLP to Alloy, which routes logs to Loki and metrics to Prometheus — all visualized in one Grafana instance.

## About Hosting Grafana Stack

Hosting Grafana Stack means running four coordinated services with persistent storage, private networking, and pre-wired datasource configuration. You deploy Grafana, Prometheus, Loki, and Alloy as separate Railway services, attach a volume to each so metrics and logs survive redeploys, and wire internal URLs so components communicate over Railway's private network. Alloy is the single ingest endpoint (OTLP on ports 4317/4318); Prometheus can also scrape `/metrics` endpoints directly. Grafana ships with Prometheus and Loki datasources already provisioned. You set admin credentials, reference sibling services via `${{service.RAILWAY_PRIVATE_DOMAIN}}`, and optionally pin Docker image versions per service.

## Common Use Cases

- Centralized monitoring and alerting for microservices, APIs, and background workers deployed on Railway
- Unified logs-and-metrics dashboards without operating separate ingest pipelines or SaaS observability tools
- Self-hosted observability with a single OTLP endpoint — point any OpenTelemetry SDK at Alloy and data lands in the right backend automatically

## Dependencies for Grafana Stack Hosting

- **Persistent volumes** — one per service (`/var/lib/grafana`, `/prometheus`, `/loki`, `/var/lib/alloy/data`) so data survives redeploys
- **Private networking** — Grafana, Alloy, Prometheus, and Loki must reach each other via Railway internal domains

### Deployment Dependencies

- [Grafana Documentation](https://grafana.com/docs/grafana/latest/)
- [Alloy Documentation](https://grafana.com/docs/alloy/latest/)
- [Loki Documentation](https://grafana.com/docs/loki/latest/)
- [Prometheus Documentation](https://prometheus.io/docs/introduction/overview/)
- [OpenTelemetry OTLP Exporter](https://opentelemetry.io/docs/specs/otlp/)
- [Locomotive](https://railway.com/template/jP9r-f) — optional template to forward Railway service logs to Loki with no code changes

### Implementation Details

Each top-level directory (`grafana`, `prometheus`, `loki`, `alloy`) is one Railway service. Set the **Root Directory** to the matching folder; Railway builds from the `dockerfile` inside it.

**Volumes**

| Service | Mount path |
|---------|------------|
| Grafana | `/var/lib/grafana` |
| Prometheus | `/prometheus` |
| Loki | `/loki` |
| Alloy | `/var/lib/alloy/data` |

**Key environment variables**

| Service | Variable | Example |
|---------|----------|---------|
| Grafana | `GF_SECURITY_ADMIN_USER` / `GF_SECURITY_ADMIN_PASSWORD` | set a strong password |
| Grafana | `LOKI_INTERNAL_URL` | `http://${{loki.RAILWAY_PRIVATE_DOMAIN}}:3100` |
| Grafana | `PROMETHEUS_INTERNAL_URL` | `http://${{prometheus.RAILWAY_PRIVATE_DOMAIN}}:9090` |
| Alloy | `LOKI_INTERNAL_URL` | `http://${{loki.RAILWAY_PRIVATE_DOMAIN}}:3100` |
| Alloy | `PROMETHEUS_INTERNAL_URL` | `http://${{prometheus.RAILWAY_PRIVATE_DOMAIN}}:9090` |

**Connect your apps** — set in any Railway service that should emit telemetry:

```
OTEL_EXPORTER_OTLP_ENDPOINT=http://${{alloy.RAILWAY_PRIVATE_DOMAIN}}:4318
```

**Architecture**

```
                        ┌──────────► Loki (logs) ◄──────┐
your apps ──OTLP──► Alloy                               Grafana
  (gRPC :4317 /         └──► Prometheus (metrics) ◄─────┘
   HTTP :4318)                    ▲
                                  └── scrapes /metrics targets too
```

Traces are intentionally out of scope (no Tempo). Add a Tempo service and a traces pipeline in `alloy/config.alloy` if needed later.

**Local development**

```sh
docker compose up --build
```

| Service | URL |
|---------|-----|
| Grafana | http://localhost:3000 (admin / yourpassword123) |
| Prometheus | http://localhost:9090 |
| Loki | http://localhost:3100 |
| Alloy UI | http://localhost:12345 |
| OTLP ingest | grpc://localhost:4317, http://localhost:4318 |

**Default image versions** (override via `VERSION` build arg)

| Service | Default |
|---------|---------|
| Grafana | `12.0.2` |
| Prometheus | `v3.4.1` |
| Loki | `3.5` |
| Alloy | `v1.9.2` |

## Why Deploy Grafana Stack on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Grafana Stack on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

---

Inspired by [MykalMachon/railway-grafana-stack](https://github.com/MykalMachon/railway-grafana-stack).


## Similar templates

- [Betterlytics](https://railway.com/deploy/betterlytics) — Betterlytics is a cookieless analytics platform GDPR-compliant.
- [Finance Tracker](https://railway.com/deploy/finance-tracker-1) — Private multi-user household finance ledger with budgets and CSV import.
- [Matomo Analytics + MariaDB](https://railway.com/deploy/matomo-analytics-mariadb) — Privacy-friendly analytics with MariaDB and persistent volumes.

Open this page in a browser: https://railway.com/deploy/grafana-stack-1
