Create a Cortex or Loki managed recording rule

    For Cortex and Loki data sources to work with Grafana 8.0 alerting, enable the ruler API by configuring their respective services.

    Loki - The rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other rule storage types.

    Cortex - When configuring a Grafana Prometheus data source to point to Cortex, use the legacy prefix, not . Currently, we support only single-binary mode and you cannot provide a separate URL for the ruler API.

    Add a Cortex or Loki managed recording rule

    1. In the Grafana menu, click the Alerting (bell) icon to open the Alerting page listing existing alerts.
    2. Click New alert rule.
    3. In Step 1, add the rule name, type, and storage location.

      • From the Rule type drop-down, select Cortex / Loki managed alert.
      • From the Select data source drop-down, select an external Prometheus, an external Loki, or a Grafana Cloud data source.
      • From the Namespace drop-down, select an existing rule namespace. Otherwise, click Add new and enter a name to create a new one. Namespaces can contain one or more rule groups and only have an organizational purpose.
      • From the Group drop-down, select an existing group within the selected namespace. Otherwise, click Add new and enter a name to create a new one. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.

        Create Cortex or Loki managed recording rule - 图2

    4. In Step 3, add additional metadata associated with the rule.

      • Add a description and summary to customize alert messages. Use the guidelines in .
      • Add Runbook URL, panel, dashboard, and alert IDs.
      • Add custom labels.
    5. Click Save to save the rule or Save and exit to save the rule and go back to the Alerting page.