如何使用 Loki 的录制规则

How to use recording rules from Loki

我正在尝试使用 Loki new Recording Rules 而不提醒。

我不清楚规则评估的结果在哪里可用?

是否可以从标尺中提取指标值,或者必须将它们推送到 Prometheus Pushgateway 之类的东西?

因此,根据 Loki 文档,指标必须推送到 Prometheus、Cortex 或 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)

正如 Marcelo 在 中提到的,必须推送指标。

这是推送到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