Configure the Grafana Loki ruler to evaluate LogQL-based alerting and recording rules

domain: grafana.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add a `ruler:` block to Loki's config file specifying rule storage (`storage.type`: local/gcs/s3/azure/swift/cos) and a `rule_path` scratch directory for temporary rule files.
  2. Set `ruler.alertmanager_url` to your Alertmanager endpoint so rules that fire alerts get dispatched there.
  3. Enable the ruler API with `enable_api: true` so rules can be managed via the Loki ruler HTTP API or `lokitool`.
  4. Write rule groups in Prometheus-compatible YAML using LogQL expressions, e.g. `groups: - name: ... rules: - alert: ... expr: 'sum(rate({app="foo"} |= "error" [5m])) by (job)' for: 10m`.
  5. To make recording-rule results queryable as real metrics, set `ruler.remote_write.enabled: true` and `ruler.remote_write.client.url` to a Prometheus-compatible remote_write endpoint (Prometheus, Grafana Mimir, or Thanos Receive).
  6. For multiple ruler replicas, set `enable_sharding: true` and configure `ring.kvstore` (e.g. consul or memberlist) so rule evaluation is divided across instances via a hash ring.

Known gotchas

Related routes

Configure Grafana Mimir ruler to evaluate recording rules and alerting rules at scale with per-tenant rule namespaces
grafana.com · 5 steps · unrated
Write Grafana Loki LogQL metric queries and manage label cardinality
grafana.com · 5 steps · unrated
Query Grafana Loki log streams using LogQL via the HTTP API
grafana.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans