How to use recording rules from Loki

Viewed 1111

I'm trying to use Loki new Recording Rules without alerting.

What is not clear to me is where would the result of the rule evaluation be available?

Can the ruler be scraped for the metrics values or they have to be pushed to something like Prometheus Pushgateway?

2 Answers

Accordingly, to the Loki documentation, metrics must be pushed to Prometheus, Cortex, or Thanos:

With recording rules, you can run these metric queries continually on an interval and have the resulting metrics written to a Prometheus-compatible remote-write endpoint. They produce Prometheus metrics from log entries.

At the time of writing, these are the compatible backends that support this:

  • Prometheus (>=v2.25.0)
  • Cortex
  • Thanos (Receiver)

As Marcelo mentioned in his answer the metrics have to be pushed.

This is a configuration example to push to prometheus

ruler:
  storage:
    type: local
    local:
      directory: /etc/loki/rules
  ring:
    kvstore:
      store: memberlist
  remote_write:
    enabled: true
    client:
      url: http://<prometheus_domain>:9090/api/v1/write
Related