Este contenido no está disponible en el idioma seleccionado.
Chapter 3. Configuring user workload monitoring
3.1. Preparing to configure the user workload monitoring stack Copiar enlaceEnlace copiado en el portapapeles!
This section explains which user-defined monitoring components can be configured and how to prepare for configuring the user workload monitoring stack.
- Not all configuration parameters for the monitoring stack are exposed. Only the parameters and fields listed in the Config map reference for the Cluster Monitoring Operator are supported for configuration.
3.1.1. Configurable monitoring components Copiar enlaceEnlace copiado en el portapapeles!
This table shows the monitoring components you can configure and the keys used to specify the components in the user-workload-monitoring-config config map.
Do not modify the monitoring components in the cluster-monitoring-config ConfigMap object. Red Hat Site Reliability Engineers (SRE) use these components to monitor the core cluster components and Kubernetes services.
| Component | user-workload-monitoring-config config map key |
|---|---|
| Prometheus Operator |
|
| Prometheus |
|
| Alertmanager |
|
| Thanos Ruler |
|
3.1.2. Enabling alert routing for user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
In OpenShift Dedicated, an administrator can enable alert routing for user-defined projects. This process consists of the following steps:
- Enable alert routing for user-defined projects to use a separate Alertmanager instance.
- Grant users permission to configure alert routing for user-defined projects.
After you complete these steps, developers and other users can configure custom alerts and alert routing for their user-defined projects.
3.1.2.1. Enabling a separate Alertmanager instance for user-defined alert routing Copiar enlaceEnlace copiado en el portapapeles!
In OpenShift Dedicated, you may want to deploy a dedicated Alertmanager instance for user-defined projects, which provides user-defined alerts separate from default platform alerts. In these cases, you can optionally enable a separate instance of Alertmanager to send alerts for user-defined projects only.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configConfigMapobject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add
enabled: trueandenableAlertmanagerConfig: truein thealertmanagersection underdata/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set the
enabledvalue totrueto enable a dedicated instance of the Alertmanager for user-defined projects in a cluster. Set the value tofalseor omit the key entirely to disable the Alertmanager for user-defined projects. If you set this value tofalseor if the key is omitted, user-defined alerts are routed to the default platform Alertmanager instance. - 2
- Set the
enableAlertmanagerConfigvalue totrueto enable users to define their own alert routing configurations withAlertmanagerConfigobjects.
- Save the file to apply the changes. The dedicated instance of Alertmanager for user-defined projects starts automatically.
Verification
Verify that the
alert-manager-user-workloadpods are running:oc -n openshift-user-workload-monitoring get pods
$ oc -n openshift-user-workload-monitoring get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE alertmanager-user-workload-0 6/6 Running 0 38s alertmanager-user-workload-1 6/6 Running 0 38s ...
NAME READY STATUS RESTARTS AGE alertmanager-user-workload-0 6/6 Running 0 38s alertmanager-user-workload-1 6/6 Running 0 38s ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.2.2. Granting users permission to configure alert routing for user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
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
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. - The user account that you are assigning the role to already exists.
-
You have installed the OpenShift CLI (
oc).
Procedure
Assign the
alert-routing-editcluster role to a user in the user-defined project:oc -n <namespace> adm policy add-role-to-user alert-routing-edit <user>
$ oc -n <namespace> adm policy add-role-to-user alert-routing-edit <user>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- For
<namespace>, substitute the namespace for the user-defined project, such asns1. For<user>, substitute the username for the account to which you want to assign the role.
3.2. Configuring performance and scalability for user workload monitoring Copiar enlaceEnlace copiado en el portapapeles!
You can configure the monitoring stack to optimize the performance and scale of your clusters. The following documentation provides information about how to distribute the monitoring components and control the impact of the monitoring stack on CPU and memory resources.
3.2.1. Controlling the placement and distribution of monitoring components Copiar enlaceEnlace copiado en el portapapeles!
You can move the monitoring stack components to specific nodes:
-
Use the
nodeSelectorconstraint with labeled nodes to move any of the monitoring stack components to specific nodes. - Assign tolerations to enable moving components to tainted nodes.
By doing so, you control the placement and distribution of the monitoring components across a cluster.
By controlling placement and distribution of monitoring components, you can optimize system resource use, improve performance, and separate workloads based on specific requirements or policies.
3.2.1.1. Moving monitoring components to different nodes Copiar enlaceEnlace copiado en el portapapeles!
You can move any of the components that monitor workloads for user-defined projects to specific worker nodes.
It is not permitted to move components to control plane or infrastructure nodes.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
If you have not done so yet, add a label to the nodes on which you want to run the monitoring components:
oc label nodes <node_name> <node_label>
$ oc label nodes <node_name> <node_label>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<node_name>with the name of the node where you want to add the label. Replace<node_label>with the name of the wanted label.
Edit the
user-workload-monitoring-configConfigMapobject in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the node labels for the
nodeSelectorconstraint for the component underdata/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Substitute
<component>with the appropriate monitoring stack component name. - 2
- Substitute
<node_label_1>with the label you added to the node. - 3
- Optional: Specify additional labels. If you specify additional labels, the pods for the component are only scheduled on the nodes that contain all of the specified labels.
NoteIf monitoring components remain in a
Pendingstate after configuring thenodeSelectorconstraint, check the pod events for errors relating to taints and tolerations.- Save the file to apply the changes. The components specified in the new configuration are automatically moved to the new nodes, and the pods affected by the new configuration are redeployed.
3.2.1.2. Assigning tolerations to monitoring components Copiar enlaceEnlace copiado en el portapapeles!
You can assign tolerations to the components that monitor user-defined projects, to enable moving them to tainted worker nodes. Scheduling is not permitted on control plane or infrastructure nodes.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists in theopenshift-user-workload-monitoringnamespace. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Specify
tolerationsfor the component:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Substitute
<component>and<toleration_specification>accordingly.For example,
oc adm taint nodes node1 key1=value1:NoScheduleadds a taint tonode1with the keykey1and the valuevalue1. This prevents monitoring components from deploying pods onnode1unless a toleration is configured for that taint. The following example configures thethanosRulercomponent to tolerate the example taint:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.2.2. Managing CPU and memory resources for monitoring components Copiar enlaceEnlace copiado en el portapapeles!
You can ensure that the containers that run monitoring components have enough CPU and memory resources by specifying values for resource limits and requests for those components.
You can configure these limits and requests for monitoring components that monitor user-defined projects in the openshift-user-workload-monitoring namespace.
3.2.2.1. Specifying limits and requests Copiar enlaceEnlace copiado en el portapapeles!
To configure CPU and memory resources, specify values for resource limits and requests in the user-workload-monitoring-config ConfigMap object in the openshift-user-workload-monitoring namespace.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admincluster role, or as a user with theuser-workload-monitoring-config-editrole in theopenshift-user-workload-monitoringproject. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add values to define resource limits and requests for each component you want to configure.
ImportantEnsure that the value set for a limit is always higher than the value set for a request. Otherwise, an error will occur, and the container will not run.
Example of setting resource limits and requests
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.2.3. Controlling the impact of unbound metrics attributes in user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
A dedicated-admin can use the following measures to control the impact of unbound metrics attributes in user-defined projects:
- Limit the number of samples that can be accepted per target scrape in user-defined projects
- Limit the number of scraped labels, the length of label names, and the length of label values
- Configure the intervals between consecutive scrapes and between Prometheus rule evaluations
Limiting scrape samples can help prevent the issues caused by adding many unbound attributes to labels. Developers can also prevent the underlying cause by limiting the number of unbound attributes that they define for metrics. Using attributes that are bound to a limited set of possible values reduces the number of potential key-value pair combinations.
3.2.3.1. Setting scrape intervals, evaluation intervals, and enforced limits for user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
You can set the following scrape and label limits for user-defined projects:
- Limit the number of samples that can be accepted per target scrape
- Limit the number of scraped labels
- Limit the length of label names and label values
You can also set an interval between consecutive scrapes and between Prometheus rule evaluations.
If you set sample or label limits, no further sample data is ingested for that target scrape after the limit is reached.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configConfigMapobject in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the enforced limit and time interval configurations to
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- A value is required if this parameter is specified. This
enforcedSampleLimitexample limits the number of samples that can be accepted per target scrape in user-defined projects to 50,000. - 2
- Specifies the maximum number of labels per scrape. The default value is
0, which specifies no limit. - 3
- Specifies the maximum character length for a label name. The default value is
0, which specifies no limit. - 4
- Specifies the maximum character length for a label value. The default value is
0, which specifies no limit. - 5
- Specifies the interval between consecutive scrapes. The interval must be set between 5 seconds and 5 minutes. The default value is
30s. - 6
- Specifies the interval between Prometheus rule evaluations. The interval must be set between 5 seconds and 5 minutes. The default value for Prometheus is
30s.
NoteYou can also configure the
evaluationIntervalproperty for Thanos Ruler through thedata/config.yaml/thanosRulerfield. The default value for Thanos Ruler is15s.- Save the file to apply the changes. The limits are applied automatically.
3.2.4. Configuring pod topology spread constraints Copiar enlaceEnlace copiado en el portapapeles!
You can configure pod topology spread constraints for all the pods for user-defined monitoring to control how pod replicas are scheduled to nodes across zones. This ensures that the pods are highly available and run more efficiently, because workloads are spread across nodes in different data centers or hierarchical infrastructure zones.
You can configure pod topology spread constraints for monitoring pods by using the user-workload-monitoring-config config map.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following settings under the
data/config.yamlfield to configure pod topology spread constraints:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify a name of the component for which you want to set up pod topology spread constraints.
- 2
- Specify a numeric value for
maxSkew, which defines the degree to which pods are allowed to be unevenly distributed. - 3
- Specify a key of node labels for
topologyKey. Nodes that have a label with this key and identical values are considered to be in the same topology. The scheduler tries to put a balanced number of pods into each domain. - 4
- Specify a value for
whenUnsatisfiable. Available options areDoNotScheduleandScheduleAnyway. SpecifyDoNotScheduleif you want themaxSkewvalue to define the maximum difference allowed between the number of matching pods in the target topology and the global minimum. SpecifyScheduleAnywayif you want the scheduler to still schedule the pod but to give higher priority to nodes that might reduce the skew. - 5
- Specify
labelSelectorto find matching pods. Pods that match this label selector are counted to determine the number of pods in their corresponding topology domain.
Example configuration for Thanos Ruler
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.3. Storing and recording data for user workload monitoring Copiar enlaceEnlace copiado en el portapapeles!
Store and record your metrics and alerting data, configure logs to specify which activities are recorded, control how long Prometheus retains stored data, and set the maximum amount of disk space for the data. These actions help you protect your data and use them for troubleshooting.
3.3.1. Configuring persistent storage Copiar enlaceEnlace copiado en el portapapeles!
Run cluster monitoring with persistent storage to gain the following benefits:
- Protect your metrics and alerting data from data loss by storing them in a persistent volume (PV). As a result, they can survive pods being restarted or recreated.
- Avoid getting duplicate notifications and losing silences for alerts when the Alertmanager pods are restarted.
For production environments, it is highly recommended to configure persistent storage.
In multi-node clusters, you must configure persistent storage for Prometheus, Alertmanager, and Thanos Ruler to ensure high availability.
3.3.1.1. Persistent storage prerequisites Copiar enlaceEnlace copiado en el portapapeles!
- Use the block type of storage.
3.3.1.2. Configuring a persistent volume claim Copiar enlaceEnlace copiado en el portapapeles!
To use a persistent volume (PV) for monitoring components, you must configure a persistent volume claim (PVC).
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add your PVC configuration for the component under
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following example configures a PVC that claims persistent storage for Thanos Ruler:
Example PVC configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteStorage requirements for the
thanosRulercomponent depend on the number of rules that are evaluated and how many samples each rule generates.Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed and the new storage configuration is applied.
WarningWhen you update the config map with a PVC configuration, the affected
StatefulSetobject is recreated, resulting in a temporary service outage.
3.3.2. Modifying retention time and size for Prometheus metrics data Copiar enlaceEnlace copiado en el portapapeles!
By default, Prometheus retains metrics data for 24 hours for monitoring for user-defined projects. You can modify the retention time for the Prometheus instance to change when the data is deleted. You can also set the maximum amount of disk space the retained metrics data uses.
Data compaction occurs every two hours. Therefore, a persistent volume (PV) might fill up before compaction, potentially exceeding the retentionSize limit. In such cases, the KubePersistentVolumeFillingUp alert fires until the space on a PV is lower than the retentionSize limit.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the retention time and size configuration under
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The retention time: a number directly followed by
ms(milliseconds),s(seconds),m(minutes),h(hours),d(days),w(weeks), ory(years). You can also combine time values for specific times, such as1h30m15s. - 2
- The retention size: a number directly followed by
B(bytes),KB(kilobytes),MB(megabytes),GB(gigabytes),TB(terabytes),PB(petabytes), andEB(exabytes).
The following example sets the retention time to 24 hours and the retention size to 10 gigabytes for the Prometheus instance:
Example of setting retention time for Prometheus
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.3.2.1. Modifying the retention time for Thanos Ruler metrics data Copiar enlaceEnlace copiado en el portapapeles!
By default, for user-defined projects, Thanos Ruler automatically retains metrics data for 24 hours. You can modify the retention time to change how long this data is retained by specifying a time value in the user-workload-monitoring-config config map in the openshift-user-workload-monitoring namespace.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configConfigMapobject in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the retention time configuration under
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the retention time in the following format: a number directly followed by
ms(milliseconds),s(seconds),m(minutes),h(hours),d(days),w(weeks), ory(years). You can also combine time values for specific times, such as1h30m15s. The default is24h.
The following example sets the retention time to 10 days for Thanos Ruler data:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.3.3. Setting log levels for monitoring components Copiar enlaceEnlace copiado en el portapapeles!
You can configure the log level for Alertmanager, Prometheus Operator, Prometheus, and Thanos Ruler. You can use these settings for troubleshooting and to gain better insight into how the components are functioning.
The following log levels can be applied to the relevant component in the user-workload-monitoring-config ConfigMap object:
-
debug. Log debug, informational, warning, and error messages. -
info(default). Log informational, warning, and error messages. -
warn. Log warning and error messages only. -
error. Log error messages only.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add log configuration for a component under
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
Verify that the log configuration is applied by reviewing the deployment or pod configuration in the related project.
The following example checks the log level for the
prometheus-operatordeployment:oc -n openshift-user-workload-monitoring get deploy prometheus-operator -o yaml | grep "log-level"
$ oc -n openshift-user-workload-monitoring get deploy prometheus-operator -o yaml | grep "log-level"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
- --log-level=debug
- --log-level=debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that the pods for the component are running:
oc -n openshift-user-workload-monitoring get pods
$ oc -n openshift-user-workload-monitoring get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf an unrecognized
logLevelvalue is included in theConfigMapobject, the pods for the component might not restart successfully.
3.3.4. Enabling the query log file for Prometheus Copiar enlaceEnlace copiado en el portapapeles!
You can configure Prometheus to write all queries that have been run by the engine to a log file.
Because log rotation is not supported, only enable this feature temporarily when you need to troubleshoot an issue. After you finish troubleshooting, disable query logging by reverting the changes you made to the ConfigMap object to enable the feature.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
queryLogFileparameter for Prometheus underdata/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Add the full path to the file in which queries will be logged.
- Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
Verify that the pods for the component are running. The following sample command lists the status of pods:
oc -n openshift-user-workload-monitoring get pods
$ oc -n openshift-user-workload-monitoring get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Read the query log:
oc -n openshift-user-workload-monitoring exec prometheus-user-workload-0 -- cat <path>
$ oc -n openshift-user-workload-monitoring exec prometheus-user-workload-0 -- cat <path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantRevert the setting in the config map after you have examined the logged query information.
3.4. Configuring metrics for user workload monitoring Copiar enlaceEnlace copiado en el portapapeles!
Configure the collection of metrics to monitor how cluster components and your own workloads are performing.
You can send ingested metrics to remote systems for long-term storage and add cluster ID labels to the metrics to identify the data coming from different clusters.
3.4.1. Configuring remote write storage Copiar enlaceEnlace copiado en el portapapeles!
You can configure remote write storage to enable Prometheus to send ingested metrics to remote systems for long-term storage. Doing so has no impact on how or for how long Prometheus stores metrics.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc). You have set up a remote write compatible endpoint (such as Thanos) and know the endpoint URL. See the Prometheus remote endpoints and storage documentation for information about endpoints that are compatible with the remote write feature.
ImportantRed Hat only provides information for configuring remote write senders and does not offer guidance on configuring receiver endpoints. Customers are responsible for setting up their own endpoints that are remote-write compatible. Issues with endpoint receiver configurations are not included in Red Hat production support.
You have set up authentication credentials in a
Secretobject for the remote write endpoint. You must create the secret in theopenshift-user-workload-monitoringnamespace.WarningTo reduce security risks, use HTTPS and authentication to send metrics to an endpoint.
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a
remoteWrite:section underdata/config.yaml/prometheus, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The URL of the remote write endpoint.
- 2
- The authentication method and credentials for the endpoint. Currently supported authentication methods are AWS Signature Version 4, authentication using HTTP in an
Authorizationrequest header, Basic authentication, OAuth 2.0, and TLS client. See Supported remote write authentication settings for sample configurations of supported authentication methods.
Add write relabel configuration values after the authentication credentials:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Add configuration for metrics that you want to send to the remote endpoint.
Example of forwarding a single metric called
my_metricCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example of forwarding metrics called
my_metric_1andmy_metric_2inmy_namespacenamespaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The new configuration is applied automatically.
3.4.1.1. Supported remote write authentication settings Copiar enlaceEnlace copiado en el portapapeles!
You can use different methods to authenticate with a remote write endpoint. Currently supported authentication methods are AWS Signature Version 4, basic authentication, authorization, OAuth 2.0, and TLS client. The following table provides details about supported authentication methods for use with remote write.
| Authentication method | Config map field | Description |
|---|---|---|
| AWS Signature Version 4 |
| This method uses AWS Signature Version 4 authentication to sign requests. You cannot use this method simultaneously with authorization, OAuth 2.0, or Basic authentication. |
| Basic authentication |
| Basic authentication sets the authorization header on every remote write request with the configured username and password. |
| authorization |
|
Authorization sets the |
| OAuth 2.0 |
|
An OAuth 2.0 configuration uses the client credentials grant type. Prometheus fetches an access token from |
| TLS client |
| A TLS client configuration specifies the CA certificate, the client certificate, and the client key file information used to authenticate with the remote write endpoint server using TLS. The sample configuration assumes that you have already created a CA certificate file, a client certificate file, and a client key file. |
3.4.1.2. Example remote write authentication settings Copiar enlaceEnlace copiado en el portapapeles!
The following samples show different authentication settings you can use to connect to a remote write endpoint. Each sample also shows how to configure a corresponding Secret object that contains authentication credentials and other relevant settings. Each sample configures authentication for use with monitoring for user-defined projects in the openshift-user-workload-monitoring namespace.
3.4.1.2.1. Sample YAML for AWS Signature Version 4 authentication Copiar enlaceEnlace copiado en el portapapeles!
The following shows the settings for a sigv4 secret named sigv4-credentials in the openshift-user-workload-monitoring namespace.
The following shows sample AWS Signature Version 4 remote write authentication settings that use a Secret object named sigv4-credentials in the openshift-user-workload-monitoring namespace:
- 1
- The AWS region.
- 2 4
- The name of the
Secretobject containing the AWS API access credentials. - 3
- The key that contains the AWS API access key in the specified
Secretobject. - 5
- The key that contains the AWS API secret key in the specified
Secretobject. - 6
- The name of the AWS profile that is being used to authenticate.
- 7
- The unique identifier for the Amazon Resource Name (ARN) assigned to your role.
3.4.1.2.2. Sample YAML for Basic authentication Copiar enlaceEnlace copiado en el portapapeles!
The following shows sample Basic authentication settings for a Secret object named rw-basic-auth in the openshift-user-workload-monitoring namespace:
The following sample shows a basicAuth remote write configuration that uses a Secret object named rw-basic-auth in the openshift-user-workload-monitoring namespace. It assumes that you have already set up authentication credentials for the endpoint.
3.4.1.2.3. Sample YAML for authentication with a bearer token using a Secret Object Copiar enlaceEnlace copiado en el portapapeles!
The following shows bearer token settings for a Secret object named rw-bearer-auth in the openshift-user-workload-monitoring namespace:
- 1
- The authentication token.
The following shows sample bearer token config map settings that use a Secret object named rw-bearer-auth in the openshift-user-workload-monitoring namespace:
3.4.1.2.4. Sample YAML for OAuth 2.0 authentication Copiar enlaceEnlace copiado en el portapapeles!
The following shows sample OAuth 2.0 settings for a Secret object named oauth2-credentials in the openshift-user-workload-monitoring namespace:
The following shows an oauth2 remote write authentication sample configuration that uses a Secret object named oauth2-credentials in the openshift-user-workload-monitoring namespace:
- 1 3
- The name of the corresponding
Secretobject. Note thatClientIdcan alternatively refer to aConfigMapobject, althoughclientSecretmust refer to aSecretobject. - 2 4
- The key that contains the OAuth 2.0 credentials in the specified
Secretobject. - 5
- The URL used to fetch a token with the specified
clientIdandclientSecret. - 6
- The OAuth 2.0 scopes for the authorization request. These scopes limit what data the tokens can access.
- 7
- The OAuth 2.0 authorization request parameters required for the authorization server.
3.4.1.2.5. Sample YAML for TLS client authentication Copiar enlaceEnlace copiado en el portapapeles!
The following shows sample TLS client settings for a tls Secret object named mtls-bundle in the openshift-user-workload-monitoring namespace.
The following sample shows a tlsConfig remote write authentication configuration that uses a TLS Secret object named mtls-bundle.
- 1 3 5
- The name of the corresponding
Secretobject that contains the TLS authentication credentials. Note thatcaandcertcan alternatively refer to aConfigMapobject, thoughkeySecretmust refer to aSecretobject. - 2
- The key in the specified
Secretobject that contains the CA certificate for the endpoint. - 4
- The key in the specified
Secretobject that contains the client certificate for the endpoint. - 6
- The key in the specified
Secretobject that contains the client key secret.
3.4.1.3. Example remote write queue configuration Copiar enlaceEnlace copiado en el portapapeles!
You can use the queueConfig object for remote write to tune the remote write queue parameters. The following example shows the queue parameters with their default values for monitoring for user-defined projects in the openshift-user-workload-monitoring namespace.
Example configuration of remote write parameters with default values
- 1
- The number of samples to buffer per shard before they are dropped from the queue.
- 2
- The minimum number of shards.
- 3
- The maximum number of shards.
- 4
- The maximum number of samples per send.
- 5
- The maximum time for a sample to wait in buffer.
- 6
- The initial time to wait before retrying a failed request. The time gets doubled for every retry up to the
maxbackofftime. - 7
- The maximum time to wait before retrying a failed request.
- 8
- Set this parameter to
trueto retry a request after receiving a 429 status code from the remote write storage. - 9
- The samples that are older than the
sampleAgeLimitlimit are dropped from the queue. If the value is undefined or set to0s, the parameter is ignored.
3.4.1.4. Table of remote write metrics Copiar enlaceEnlace copiado en el portapapeles!
The following table contains remote write and remote write-adjacent metrics with further description to help solve issues during remote write configuration.
| Metric | Description |
|---|---|
|
| Shows the newest timestamp that Prometheus stored in the write-ahead log (WAL) for any sample. |
|
| Shows the newest timestamp that the remote write queue successfully sent. |
|
| The number of samples that remote write failed to send and had to resend to remote storage. A steady high rate for this metric indicates problems with the network or remote storage endpoint. |
|
| Shows how many shards are currently running for each remote endpoint. |
|
| Shows the calculated needed number of shards based on the current write throughput and the rate of incoming versus sent samples. |
|
| Shows the maximum number of shards based on the current configuration. |
|
| Shows the minimum number of shards based on the current configuration. |
|
| The WAL segment file that Prometheus is currently writing new data to. |
|
| The WAL segment file that each remote write instance is currently reading from. |
3.4.2. Creating cluster ID labels for metrics Copiar enlaceEnlace copiado en el portapapeles!
You can create cluster ID labels for metrics by adding the write_relabel settings for remote write storage in the user-workload-monitoring-config config map in the openshift-user-workload-monitoring namespace.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMap object exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc). - You have configured remote write storage.
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the
writeRelabelConfigs:section underdata/config.yaml/prometheus/remoteWrite, add cluster ID relabel configuration values:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following sample shows how to forward a metric with the cluster ID label
cluster_id:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The system initially applies a temporary cluster ID source label named
__tmp_openshift_cluster_id__. This temporary label gets replaced by the cluster ID label name that you specify. - 2
- Specify the name of the cluster ID label for metrics sent to remote write storage. If you use a label name that already exists for a metric, that value is overwritten with the name of this cluster ID label. For the label name, do not use
__tmp_openshift_cluster_id__. The final relabeling step removes labels that use this name. - 3
- The
replacewrite relabel action replaces the temporary label with the target label for outgoing metrics. This action is the default and is applied if no action is specified.
- Save the file to apply the changes. The new configuration is applied automatically.
3.4.3. Setting up metrics collection for user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
You can create a ServiceMonitor resource to scrape metrics from a service endpoint in a user-defined project. This assumes that your application uses a Prometheus client library to expose metrics to the /metrics canonical name.
This section describes how to deploy a sample service in a user-defined project and then create a ServiceMonitor resource that defines how that service should be monitored.
3.4.3.1. Deploying a sample service Copiar enlaceEnlace copiado en el portapapeles!
To test monitoring of a service in a user-defined project, you can deploy a sample service.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admincluster role or as a user with administrative permissions for the namespace.
Procedure
-
Create a YAML file for the service configuration. In this example, it is called
prometheus-example-app.yaml. Add the following deployment and service configuration details to the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This configuration deploys a service named
prometheus-example-appin the user-definedns1project. This service exposes the customversionmetric.Apply the configuration to the cluster:
oc apply -f prometheus-example-app.yaml
$ oc apply -f prometheus-example-app.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow It takes some time to deploy the service.
You can check that the pod is running:
oc -n ns1 get pod
$ oc -n ns1 get podCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE prometheus-example-app-7857545cb7-sbgwq 1/1 Running 0 81m
NAME READY STATUS RESTARTS AGE prometheus-example-app-7857545cb7-sbgwq 1/1 Running 0 81mCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4.3.2. Specifying how a service is monitored Copiar enlaceEnlace copiado en el portapapeles!
To use the metrics exposed by your service, you must configure OpenShift Dedicated monitoring to scrape metrics from the /metrics endpoint. You can do this using a ServiceMonitor custom resource definition (CRD) that specifies how a service should be monitored, or a PodMonitor CRD that specifies how a pod should be monitored. The former requires a Service object, while the latter does not, allowing Prometheus to directly scrape metrics from the metrics endpoint exposed by a pod.
This procedure shows you how to create a ServiceMonitor resource for a service in a user-defined project.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole or themonitoring-editrole. For this example, you have deployed the
prometheus-example-appsample service in thens1project.NoteThe
prometheus-example-appsample service does not support TLS authentication.
Procedure
-
Create a new YAML configuration file named
example-app-service-monitor.yaml. Add a
ServiceMonitorresource to the YAML file. The following example creates a service monitor namedprometheus-example-monitorto scrape metrics exposed by theprometheus-example-appservice in thens1namespace:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteA
ServiceMonitorresource in a user-defined namespace can only discover services in the same namespace. That is, thenamespaceSelectorfield of theServiceMonitorresource is always ignored.Apply the configuration to the cluster:
oc apply -f example-app-service-monitor.yaml
$ oc apply -f example-app-service-monitor.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow It takes some time to deploy the
ServiceMonitorresource.Verify that the
ServiceMonitorresource is running:oc -n <namespace> get servicemonitor
$ oc -n <namespace> get servicemonitorCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE prometheus-example-monitor 81m
NAME AGE prometheus-example-monitor 81mCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4.3.3. Example service endpoint authentication settings Copiar enlaceEnlace copiado en el portapapeles!
You can configure authentication for service endpoints for user-defined project monitoring by using ServiceMonitor and PodMonitor custom resource definitions (CRDs).
The following samples show different authentication settings for a ServiceMonitor resource. Each sample shows how to configure a corresponding Secret object that contains authentication credentials and other relevant settings.
3.4.3.3.1. Sample YAML authentication with a bearer token Copiar enlaceEnlace copiado en el portapapeles!
The following sample shows bearer token settings for a Secret object named example-bearer-auth in the ns1 namespace:
Example bearer token secret
- 1
- Specify an authentication token.
The following sample shows bearer token authentication settings for a ServiceMonitor CRD. The example uses a Secret object named example-bearer-auth:
Example bearer token authentication settings
Do not use bearerTokenFile to configure bearer token. If you use the bearerTokenFile configuration, the ServiceMonitor resource is rejected.
3.4.3.3.2. Sample YAML for Basic authentication Copiar enlaceEnlace copiado en el portapapeles!
The following sample shows Basic authentication settings for a Secret object named example-basic-auth in the ns1 namespace:
Example Basic authentication secret
The following sample shows Basic authentication settings for a ServiceMonitor CRD. The example uses a Secret object named example-basic-auth:
Example Basic authentication settings
3.4.3.3.3. Sample YAML authentication with OAuth 2.0 Copiar enlaceEnlace copiado en el portapapeles!
The following sample shows OAuth 2.0 settings for a Secret object named example-oauth2 in the ns1 namespace:
Example OAuth 2.0 secret
The following sample shows OAuth 2.0 authentication settings for a ServiceMonitor CRD. The example uses a Secret object named example-oauth2:
Example OAuth 2.0 authentication settings
- 1
- The key that contains the OAuth 2.0 ID in the specified
Secretobject. - 2 4
- The name of the
Secretobject that contains the OAuth 2.0 credentials. - 3
- The key that contains the OAuth 2.0 secret in the specified
Secretobject. - 5
- The URL used to fetch a token with the specified
clientIdandclientSecret.
3.5. Configuring alerts and notifications for user workload monitoring Copiar enlaceEnlace copiado en el portapapeles!
You can configure a local or external Alertmanager instance to route alerts from Prometheus to endpoint receivers. You can also attach custom labels to all time series and alerts to add useful metadata information.
3.5.1. Configuring external Alertmanager instances Copiar enlaceEnlace copiado en el portapapeles!
The OpenShift Dedicated monitoring stack includes a local Alertmanager instance that routes alerts from Prometheus.
You can add external Alertmanager instances to route alerts for user-defined projects.
If you add the same external Alertmanager configuration for multiple clusters and disable the local instance for each cluster, you can then manage alert routing for multiple clusters by using a single external Alertmanager instance.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add an
additionalAlertmanagerConfigssection with configuration details underdata/config.yaml/<component>:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 2
- Substitute
<alertmanager_specification>with authentication and other configuration details for additional Alertmanager instances. Currently supported authentication methods are bearer token (bearerToken) and client TLS (tlsConfig). - 1
- Substitute
<component>for one of two supported external Alertmanager components:prometheusorthanosRuler.
The following sample config map configures an additional Alertmanager for Thanos Ruler by using a bearer token with client TLS authentication:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.5.2. Configuring secrets for Alertmanager Copiar enlaceEnlace copiado en el portapapeles!
The OpenShift Dedicated monitoring stack includes Alertmanager, which routes alerts from Prometheus to endpoint receivers. If you need to authenticate with a receiver so that Alertmanager can send alerts to it, you can configure Alertmanager to use a secret that contains authentication credentials for the receiver.
For example, you can configure Alertmanager to use a secret to authenticate with an endpoint receiver that requires a certificate issued by a private Certificate Authority (CA). You can also configure Alertmanager to use a secret to authenticate with a receiver that requires a password file for Basic HTTP authentication. In either case, authentication details are contained in the Secret object rather than in the ConfigMap object.
3.5.2.1. Adding a secret to the Alertmanager configuration Copiar enlaceEnlace copiado en el portapapeles!
You can add secrets to the Alertmanager configuration by editing the user-workload-monitoring-config config map in the openshift-user-workload-monitoring project.
After you add a secret to the config map, the secret is mounted as a volume at /etc/alertmanager/secrets/<secret_name> within the alertmanager container for the Alertmanager pods.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have created the secret to be configured in Alertmanager in the
openshift-user-workload-monitoringproject. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a
secrets:section underdata/config.yaml/alertmanagerwith the following configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- This section contains the secrets to be mounted into Alertmanager. The secrets must be located within the same namespace as the Alertmanager object.
- 2
- The name of the
Secretobject that contains authentication credentials for the receiver. If you add multiple secrets, place each one on a new line.
The following sample config map settings configure Alertmanager to use two
Secretobjects namedtest-secret-basic-authandtest-secret-api-token:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The new configuration is applied automatically.
3.5.3. Attaching additional labels to your time series and alerts Copiar enlaceEnlace copiado en el portapapeles!
You can attach custom labels to all time series and alerts leaving Prometheus by using the external labels feature of Prometheus.
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
The
user-workload-monitoring-configConfigMapobject exists. This object is created by default when the cluster is created. -
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
user-workload-monitoring-configconfig map in theopenshift-user-workload-monitoringproject:oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define labels you want to add for every metric under
data/config.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Substitute
<key>: <value>with key-value pairs where<key>is a unique name for the new label and<value>is its value.
Warning-
Do not use
prometheusorprometheus_replicaas key names, because they are reserved and will be overwritten. -
Do not use
clusteras a key name. Using it can cause issues where you are unable to see data in the developer dashboards.
NoteIn the
openshift-user-workload-monitoringproject, Prometheus handles metrics and Thanos Ruler handles alerting and recording rules. SettingexternalLabelsforprometheusin theuser-workload-monitoring-configConfigMapobject will only configure external labels for metrics and not for any rules.For example, to add metadata about the region and environment to all time series and alerts, use the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file to apply the changes. The pods affected by the new configuration are automatically redeployed.
3.5.4. Configuring alert notifications Copiar enlaceEnlace copiado en el portapapeles!
In OpenShift Dedicated, the dedicated-admin user can enable alert routing for user-defined projects by using a separate Alertmanager instance for user-defined projects.
Developers and other users with the alert-routing-edit cluster role can configure custom alert notifications for their user-defined projects by configuring alert receivers.
Review the following limitations of alert routing for user-defined projects:
-
User-defined alert routing is scoped to the namespace in which the resource is defined. For example, a routing configuration in namespace
ns1only applies toPrometheusRulesresources in the same namespace. -
When a namespace is excluded from user-defined monitoring,
AlertmanagerConfigresources in the namespace cease to be part of the Alertmanager configuration.
3.5.4.1. Configuring alert routing for user-defined projects Copiar enlaceEnlace copiado en el portapapeles!
If you are a non-administrator user who has been given the alert-routing-edit cluster role, you can create or edit alert routing for user-defined projects.
Prerequisites
- Alert routing has been enabled for user-defined projects.
-
You are logged in as a user that has the
alert-routing-editcluster role for the project for which you want to create alert routing. -
You have installed the OpenShift CLI (
oc).
Procedure
-
Create a YAML file for alert routing. The example in this procedure uses a file called
example-app-alert-routing.yaml. Add an
AlertmanagerConfigYAML definition to the file. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file.
Apply the resource to the cluster:
oc apply -f example-app-alert-routing.yaml
$ oc apply -f example-app-alert-routing.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The configuration is automatically applied to the Alertmanager pods.
3.5.4.2. Configuring alert routing for user-defined projects with the Alertmanager secret Copiar enlaceEnlace copiado en el portapapeles!
If you have enabled a separate instance of Alertmanager that is dedicated to user-defined alert routing, you can customize where and how the instance sends notifications by editing the alertmanager-user-workload secret in the openshift-user-workload-monitoring namespace.
All features of a supported version of upstream Alertmanager are also supported in an OpenShift Dedicated Alertmanager configuration. To check all the configuration options of a supported version of upstream Alertmanager, see Alertmanager configuration (Prometheus documentation).
Prerequisites
-
You have access to the cluster as a user with the
dedicated-adminrole. -
You have installed the OpenShift CLI (
oc).
Procedure
Print the currently active Alertmanager configuration into the file
alertmanager.yaml:oc -n openshift-user-workload-monitoring get secret alertmanager-user-workload --template='{{ index .data "alertmanager.yaml" }}' | base64 --decode > alertmanager.yaml$ oc -n openshift-user-workload-monitoring get secret alertmanager-user-workload --template='{{ index .data "alertmanager.yaml" }}' | base64 --decode > alertmanager.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the configuration in
alertmanager.yaml:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- If you configured an HTTP cluster-wide proxy, set the
proxy_from_environmentparameter totrueto enable proxying for all alert receivers. - 2
- Specify labels to match your alerts. This example targets all alerts that have the
service="prometheus-example-monitor"label. - 3
- Specify the name of the receiver to use for the alerts group.
- 4
- Specify the receiver configuration.
Apply the new configuration in the file:
oc -n openshift-user-workload-monitoring create secret generic alertmanager-user-workload --from-file=alertmanager.yaml --dry-run=client -o=yaml | oc -n openshift-user-workload-monitoring replace secret --filename=-
$ oc -n openshift-user-workload-monitoring create secret generic alertmanager-user-workload --from-file=alertmanager.yaml --dry-run=client -o=yaml | oc -n openshift-user-workload-monitoring replace secret --filename=-Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.5.4.3. Configuring different alert receivers for default platform alerts and user-defined alerts Copiar enlaceEnlace copiado en el portapapeles!
You can configure different alert receivers for default platform alerts and user-defined alerts to ensure the following results:
- All default platform alerts are sent to a receiver owned by the team in charge of these alerts.
- All user-defined alerts are sent to another receiver so that the team can focus only on platform alerts.
You can achieve this by using the openshift_io_alert_source="platform" label that is added by the Cluster Monitoring Operator to all platform alerts:
-
Use the
openshift_io_alert_source="platform"matcher to match default platform alerts. -
Use the
openshift_io_alert_source!="platform"or'openshift_io_alert_source=""'matcher to match user-defined alerts.
This configuration does not apply if you have enabled a separate instance of Alertmanager dedicated to user-defined alerts.