// Module included in the following assemblies:
//
// * observability/logging/logging_alerts/custom-logging-alerts.adoc

:_mod-docs-content-type: PROCEDURE
[id="configuring-logging-loki-ruler_{context}"]
= Configuring the ruler

When the LokiStack ruler component is enabled, users can define a group of link:https://grafana.com/docs/loki/latest/query/[LogQL] expressions that trigger logging alerts or recorded metrics.

Administrators can enable the ruler by modifying the `LokiStack` custom resource (CR).

.Prerequisites

* You have installed the {clo} and the {loki-op}.
* You have created a `LokiStack` CR.
* You have administrator permissions.

.Procedure

* Enable the ruler by ensuring that the `LokiStack` CR contains the following spec configuration:
+
[source,yaml]
----
apiVersion: loki.grafana.com/v1
kind: LokiStack
metadata:
  name: <name>
  namespace: <namespace>
spec:
# ...
  rules:
    enabled: true <1>
    selector:
      matchLabels:
        openshift.io/<label_name>: "true" <2>
    namespaceSelector:
      matchLabels:
        openshift.io/<label_name>: "true" <3>
----
<1> Enable Loki alerting and recording rules in your cluster.
<2> Add a custom label that can be added to namespaces where you want to enable the use of logging alerts and metrics.
<3> Add a custom label that can be added to namespaces where you want to enable the use of logging alerts and metrics.
