Railway

Deploy Grafana Stack

Deploy and Host Grafana Stack with Railway

Deploy Grafana Stack

Just deployed

/var/lib/grafana

Just deployed

/loki

Just deployed

/var/lib/alloy/data

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

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

ServiceMount path
Grafana/var/lib/grafana
Prometheus/prometheus
Loki/loki
Alloy/var/lib/alloy/data

Key environment variables

ServiceVariableExample
GrafanaGF_SECURITY_ADMIN_USER / GF_SECURITY_ADMIN_PASSWORDset a strong password
GrafanaLOKI_INTERNAL_URLhttp://${{loki.RAILWAY_PRIVATE_DOMAIN}}:3100
GrafanaPROMETHEUS_INTERNAL_URLhttp://${{prometheus.RAILWAY_PRIVATE_DOMAIN}}:9090
AlloyLOKI_INTERNAL_URLhttp://${{loki.RAILWAY_PRIVATE_DOMAIN}}:3100
AlloyPROMETHEUS_INTERNAL_URLhttp://${{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
ServiceURL
Grafanahttp://localhost:3000 (admin / yourpassword123)
Prometheushttp://localhost:9090
Lokihttp://localhost:3100
Alloy UIhttp://localhost:12345
OTLP ingestgrpc://localhost:4317, http://localhost:4318

Default image versions (override via VERSION build arg)

ServiceDefault
Grafana12.0.2
Prometheusv3.4.1
Loki3.5
Alloyv1.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

More templates in this category

View Template
Matomo Analytics + MariaDB
Privacy-friendly analytics with MariaDB and persistent volumes.

leodev
View Template
Bugsink
Self-hosted Error Tracking. Sentry-SDK compatible

zǝʇɹoɔ oɓıɹpoɹ
View Template
SubTrackr
Self-hosted Subscription Tracker

amnesia