---
title: "Deploy Grafana + Loki + Prometheus | (Just Updated) Logs and Metrics That Scrape Your Apps"
description: "Grafana + Loki + Prometheus that scrape your apps and expire old data"
category: "Observability"
url: https://railway.com/deploy/grafana-loki-prometheus-or-just-updated-
---

# Deploy Grafana + Loki + Prometheus | (Just Updated) Logs and Metrics That Scrape Your Apps

Grafana + Loki + Prometheus that scrape your apps and expire old data

**[Deploy Grafana + Loki + Prometheus | (Just Updated) Logs and Metrics That Scrape Your Apps on Railway](https://railway.com/template/grafana-loki-prometheus-or-just-updated-)**

- **Creator:** SuperSlowSloth
- **Category:** Observability

## Template content

### grafana

- **Image:** ghcr.io/bon5co/lgtm-railway-grafana:13.0.2
- **Health check:** /api/health
- **Public domain:** Yes

### loki

- **Image:** ghcr.io/bon5co/lgtm-railway-loki:3.7.7

### prometheus

- **Image:** ghcr.io/bon5co/lgtm-railway-prometheus:v3.14.0

## Documentation

# Deploy and Host Grafana, Loki and Prometheus on Railway

Grafana is the open-source dashboard and exploration UI, Loki is Grafana Labs' log
aggregation system, and Prometheus is the de-facto open-source metrics database. Together
they are the standard self-hosted alternative to Datadog, New Relic and Grafana Cloud:
metrics scraped from your services, logs shipped from them, and one UI over both.

This template runs all three as a single Railway deploy — Grafana on your public domain,
Loki and Prometheus on the private network, each with its own volume — with both data
sources already wired up and Prometheus already scraping targets you name in a variable.

## About Hosting Grafana, Loki and Prometheus

Each component is a single Go binary with a configuration file, which makes the stack easy
to run and easy to run badly. Three details decide whether the deploy is useful: Prometheus
only scrapes what its configuration file lists, so a stack shipped with the stock file
collects nothing but its own metrics; Loki deletes nothing unless a compactor is running in
retention mode, so its volume grows until writes fail; and Railway mounts volumes owned by
root while the upstream Grafana image runs as an unprivileged user, so a naive deploy either
crash-loops or has to run the whole dashboard as root.

This template handles all three. Prometheus reads its scrape targets from an environment
variable and writes its configuration at boot, Loki ships a compactor with retention
enabled and a configurable retention period, and Grafana repairs the ownership of its data
directory as root and then drops to its own uid before starting.

## Why Deploy Grafana, Loki and Prometheus 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 this 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.

Observability belongs next to the services it observes. Deployed into the same Railway
project as your apps, Prometheus scrapes them over the private network with no egress and no
public exposure, and Grafana is the only service with a domain.

## Common Use Cases

- Metrics and dashboards for services already running in the same Railway project, scraped
  over private networking.
- Central log store for those services, shipped with Promtail, Alloy, Vector, Fluent Bit or
  any Loki-compatible client.
- A self-hosted replacement for Datadog or Grafana Cloud for a small team.
- Alerting on both logs and metrics from one Grafana instance.

## Dependencies for Grafana, Loki and Prometheus

- Grafana OSS 13.0.2, Loki 3.7.7 and Prometheus v3.14.0, each as a prebuilt pinned image.
- One Railway volume per service: Grafana's database, Loki's chunks and index, and
  Prometheus's TSDB.

### Deployment Dependencies

- Grafana: https://github.com/grafana/grafana (AGPL-3.0)
- Loki: https://github.com/grafana/loki (AGPL-3.0)
- Prometheus: https://github.com/prometheus/prometheus (Apache-2.0)

### Implementation Details

Every variable carries a working default, so the deploy form asks for nothing:

- `GF_SECURITY_ADMIN_PASSWORD` — generated per deploy. Log in at your public URL as `admin`
  with this password. Grafana refuses to boot if it is emptied.
- `PROMETHEUS_SCRAPE_TARGETS` — comma-separated `job=host:port/metrics_path` entries.
  Loki is pre-registered; add your own services by their private domains, for example
  `api=api.railway.internal:8080/metrics`. Prometheus always scrapes itself as well.
- `PROMETHEUS_RETENTION_TIME` — how long metrics are kept (default `31d`).
- `LOKI_RETENTION_PERIOD` — how long logs are kept (default `744h`, i.e. 31 days). The
  compactor enforces it; without one Loki keeps every log line forever.
- `LOKI_URL` / `PROMETHEUS_URL` — the private addresses Grafana's provisioned data sources
  point at. Both data sources are read-only and appear the moment the stack is up.

Ship logs to Loki at `http://loki.railway.internal:3100/loki/api/v1/push` from inside the
project. Loki and Prometheus have no public domain by design.


## 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/grafana-loki-prometheus-or-just-updated-
