Deploy Grafana Stack
Deploy and Host Grafana Stack with Railway
Grafana
Just deployed
/var/lib/grafana
Just deployed
/loki
Just deployed
/var/lib/alloy/data
Prometheus
Just deployed
/prometheus
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
- Alloy Documentation
- Loki Documentation
- Prometheus Documentation
- OpenTelemetry OTLP Exporter
- Locomotive — 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
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.
Template Content
Grafana
devlzcode/grafana-stackPrometheus
devlzcode/grafana-stack