
Deploy Grafana Loki
Grafana Loki 3.7 log aggregation with volume storage and auth gateway.
gateway
Just deployed
Just deployed
/loki
Deploy and Host Grafana Loki on Railway
Grafana Loki is a horizontally scalable, cost-efficient log aggregation system inspired by Prometheus. It indexes only labels, not full text, and stores compressed log chunks, so it is cheap to run. Logs are pushed by Grafana Alloy, Promtail, Fluent Bit, Vector or OpenTelemetry and queried with LogQL in Grafana.
About Hosting Grafana Loki
This template deploys Loki v3.7.8 in single-binary mode with filesystem storage on a Railway volume, plus a Caddy gateway that is the only public entry point. The gateway has two logins: push for shipping logs and admin for queries from Grafana; each works only on its own routes. Logs are kept for 14 days by the compactor, and usage reporting is off. Loki itself stays private and runs as root so it can write to the volume. Watch the volume size on the Hobby plan, since storage grows with log volume.
Common Use Cases
- Centralized logs for apps and services running on Railway and elsewhere
- LogQL queries and alerts in Grafana next to metrics and traces
- A low-cost self-hosted alternative to hosted log platforms
Dependencies for Grafana Loki Hosting
grafana/loki:3.7.8(official image) with a volume at/lokicaddy:2.11.4-alpine(official image) as the authenticated gateway
Deployment Dependencies
Implementation Details
| Service | Image | Networking | Storage |
|---|---|---|---|
| loki | grafana/loki:3.7.8 | private only, port 3100 | volume at /loki |
| gateway | caddy:2.11.4-alpine | public domain on 8080 | none |
Push (Alloy / Promtail / Fluent Bit) to https:///loki/api/v1/push with basic auth push:; OTLP logs go to /otlp/v1/logs. In Grafana, add a Loki data source with URL https:// and basic auth admin:, or ${{loki.LOKI_PRIVATE_URL}} from inside the project.
| Variable | Service | Default | Purpose |
|---|---|---|---|
LOKI_PUSH_USERNAME / _PASSWORD | gateway | push / generated | Log shipping credentials |
LOKI_QUERY_USERNAME / _PASSWORD | gateway | admin / generated | Query credentials |
CADDYFILE | gateway | gateway config | Routing and auth |
Notes:
- Retention (
-store.retention=14d) and compaction are set in the Loki start command; change the value there. - Loki has no authentication of its own, which is why it stays private behind the gateway.
This is a community-maintained deployment package and does not imply affiliation with or endorsement by the Grafana Loki project or its maintainers.
Why Deploy Grafana Loki 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 Loki 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.
Template Content
gateway
caddy:2.11.4-alpine
