Chapter 6. Enabling alert routing for user-defined projects Important Alert routing for user-defined projects is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope . In OpenShift Container Platform 4.10, a cluster administrator can enable alert routing for user-defined projects. 6.1. Understanding alert routing for user-defined projects As a cluster administrator, you can enable alert routing for user-defined projects. After doing so, you can allow users to configure alert routing for their user-defined projects. Users can then create and configure user-defined alert routing by creating or editing the AlertmanagerConfig objects. After a user has defined alert routing for a user-defined project, user-defined alerts are routed to the alertmanager-main pods in the openshift-monitoring namespace. Note the following limitations and features of alert routing for user-defined projects: For user-defined alerting rules, user-defined routing is scoped to the namespace in which the resource is defined. For example, a routing configuration in namespace ns1 only applies to PrometheusRules resources in the same namespace. The Cluster Monitoring Operator (CMO) does not deploy a second Alertmanager service dedicated to user-defined alerts. Cluster administrators continue to define the main Alertmanager configuration by using a custom secret or the OpenShift Container Platform web console. When a namespace is excluded from user-defined monitoring, AlertmanagerConfig resources in the namespace cease to be part of the Alertmanager configuration. 6.2. Enabling alert routing for user-defined projects You can enable alert routing for user-defined projects. By doing so, you enable users with the alert-routing-edit role to configure alert routing and receivers for user-defined projects in Alertmanager. Prerequisites You have enabled monitoring for user-defined projects. You have access to the cluster as a user with the cluster-admin role. You have installed the OpenShift CLI ( oc ). Procedure Edit the cluster-monitoring-config ConfigMap object: USD oc -n openshift-monitoring edit configmap cluster-monitoring-config Add enableUserAlertmanagerConfig: true under the alertmanagerMain key in data/config.yaml : apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true alertmanagerMain: enableUserAlertmanagerConfig: true 1 1 When set to true , the enableUserAlertmanagerConfig parameter enables alert routing for user-defined projects in a cluster. Save the file to apply the changes. Alert routing for user-defined projects is enabled automatically. 6.3. Granting users permission to configure alert routing for user-defined projects You can grant users permission to configure alert routing for user-defined projects. Prerequisites You have access to the cluster as a user with the cluster-admin cluster role. The user account that you are assigning the role to already exists. You have installed the OpenShift CLI ( oc ). You have enabled monitoring for user-defined projects. Procedure Assign the alert-routing-edit cluster role to a user in the user-defined project: USD oc -n <namespace> adm policy add-role-to-user alert-routing-edit <user> 1 1 For <namespace> , substitute the namespace for the user-defined project, such as ns1 . For <user> , substitute the username for the account to which you want to assign the role. 6.4. Disabling alert routing for user-defined projects If you have enabled alert routing for user-defined projects, you can disable it. By doing so, you prevent users with the alert-routing-edit role from configuring alert routing for user-defined projects in Alertmanager. Note Alert routing for user-defined projects is disabled by default. You do not need to disable it if the feature is not already enabled. Prerequisites You have enabled monitoring for user-defined projects. You have enabled alert routing for user-defined projects. You have access to the cluster as a user with the cluster-admin role. You have installed the OpenShift CLI ( oc ). Procedure Edit the cluster-monitoring-config ConfigMap object: USD oc -n openshift-monitoring edit configmap cluster-monitoring-config Change the value to false for enableUserAlertmanagerConfig under the alertmanagerMain key in data/config.yaml : apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true alertmanagerMain: enableUserAlertmanagerConfig: false 1 1 When set to false , the enableUserAlertmanagerConfig parameter disables alert routing for user-defined projects in a cluster. Save the file to apply the changes. Alert routing for user-defined projects is disabled automatically. Additional resources Enabling monitoring for user defined projects Managing alerts 6.5. steps Creating alert routing for user defined projects

Commands:
oc -n openshift-monitoring edit configmap cluster-monitoring-config
apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true alertmanagerMain: enableUserAlertmanagerConfig: true 1
oc -n <namespace> adm policy add-role-to-user alert-routing-edit <user> 1
oc -n openshift-monitoring edit configmap cluster-monitoring-config
apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true alertmanagerMain: enableUserAlertmanagerConfig: false 1