// Module included in the following assemblies:
//
// assembly-monitoring-kube.adoc
// assembly-monitoring-oc.adoc

[id='deploy-prometheus-rules-{context}']
= Deploying Prometheus Rules for alerting

You must deploy Prometheus rules to enable alerting for {ProductName}.

.Prerequisites
* Monitoring infrastructure must be present, whether pre-existing or link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#deploy-monitoring-infrastructure-messaging[installed following this procedure], and the link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#deploy-service-monitors-messaging[service monitors for {ProductName} must be deployed].

.Procedure

ifeval::["{cmdcli}" == "oc"]
. Select the `{ProductMonitoringNamespace}` project:
+
[options="nowrap",subs="+quotes,attributes"]
----
{cmdcli} project {ProductMonitoringNamespace}
----
endif::[]
ifeval::["{cmdcli}" == "kubectl"]
. Select the `{ProductMonitoringNamespace}` namespace:
+
[options="nowrap",subs="+quotes,attributes"]
----
{cmdcli} config set-context $(kubectl config current-context) --namespace={ProductMonitoringNamespace}
----
endif::[]

. Deploy the `prometheus-rules`:
+
[options="nowrap",subs="attributes"]
----
{cmdcli} apply -f install/components/prometheus
----
