Monitoring {cert-manager-operator}
By default, the cert-manager Operator for Red Hat OpenShift exposes metrics for the three core components: controller, cainjector, and webhook. You can configure OpenShift Monitoring to collect these metrics by using the Prometheus Operator format.
Enabling user workload monitoring
To collect metrics from your specific applications, enable monitoring for user-defined projects. You can enable monitoring for user-defined projects by configuring user workload monitoring in the cluster. For more information, see "Setting up metrics collection for user-defined projects".
-
You have access to the cluster as a user with the
cluster-adminrole.
-
Create the
cluster-monitoring-config.yamlYAML file:apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true -
Apply the
ConfigMapby running the following command:$ oc apply -f cluster-monitoring-config.yaml
-
Verify that the monitoring components for user workloads are running in the
openshift-user-workload-monitoringnamespace by running the following command:$ oc -n openshift-user-workload-monitoring get podExample outputNAME READY STATUS RESTARTS AGE prometheus-operator-6cb6bd9588-dtzxq 2/2 Running 0 50s prometheus-user-workload-0 6/6 Running 0 48s prometheus-user-workload-1 6/6 Running 0 48s thanos-ruler-user-workload-0 4/4 Running 0 42s thanos-ruler-user-workload-1 4/4 Running 0 42sThe status of the pods such as
prometheus-operator,prometheus-user-workload, andthanos-ruler-user-workloadmust beRunning.
Configuring metrics collection for cert-manager Operator for Red Hat OpenShift operands by using a ServiceMonitor
The cert-manager Operator for Red Hat OpenShift operands expose metrics by default on port 9402 at the /metrics service endpoint. You can configure metrics collection for the cert-manager operands by creating a ServiceMonitor custom resource (CR) that enables Prometheus Operator to collect custom metrics. For more information, see "Configuring user workload monitoring".
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have installed the cert-manager Operator for Red Hat OpenShift.
-
You have enabled the user workload monitoring.
-
Create the
ServiceMonitorCR:-
Create the YAML file that defines the
ServiceMonitorCR:Exampleservicemonitor-cert-manager.yamlfileapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: app: cert-manager app.kubernetes.io/instance: cert-manager app.kubernetes.io/name: cert-manager name: cert-manager namespace: cert-manager spec: endpoints: - honorLabels: false interval: 60s path: /metrics scrapeTimeout: 30s targetPort: 9402 selector: matchExpressions: - key: app.kubernetes.io/name operator: In values: - cainjector - cert-manager - webhook - key: app.kubernetes.io/instance operator: In values: - cert-manager - key: app.kubernetes.io/component operator: In values: - cainjector - controller - webhook -
Create the
ServiceMonitorCR by running the following command:$ oc apply -f servicemonitor-cert-manager.yamlAfter the
ServiceMonitorCR is created, the user workload Prometheus instance begins metrics collection from the cert-manager Operator for Red Hat OpenShift operands. The collected metrics are labeled withjob="cert-manager",job="cert-manager-cainjector", andjob="cert-manager-webhook".
-
-
In the OpenShift Container Platform web console, navigate to Observe → Targets.
-
In the Label filter field, enter the following labels to filter the metrics targets for each operand:
$ service=cert-manager$ service=cert-manager-webhook$ service=cert-manager-cainjector -
Confirm that the Status column shows
Upfor thecert-manager,cert-manager-webhook, andcert-manager-cainjectorentries.
Querying metrics for the cert-manager Operator for Red Hat OpenShift operands
As a cluster administrator, or as a user with view access to all namespaces, you can query cert-manager Operator for Red Hat OpenShift operands metrics by using the OpenShift Container Platform web console or the command-line interface (CLI). For more information, see "Accessing metrics".
-
You have access to the cluster as a user with the
cluster-adminrole. -
You have installed the cert-manager Operator for Red Hat OpenShift.
-
You have enabled monitoring and metrics collection by creating
ServiceMonitorobject.
-
In the OpenShift Container Platform web console, navigate to Observe → Metrics.
-
In the query field, enter the following PromQL expressions to query the cert-manager Operator for Red Hat OpenShift operands metric for each operand:
{job="cert-manager"}{job="cert-manager-webhook"}{job="cert-manager-cainjector"}
Configuring metrics collection for the istio-csr operand
The istio-csr operand exposes metrics by default on port 9402 at the /metrics service endpoint. You can configure metrics collection for the operand by creating a ServiceMonitor custom resource (CR), which enables the Prometheus Operator to collect custom metrics. For more information, see "Configuring user workload monitoring".
-
You have access to the cluster with
cluster-adminprivileges. -
You have installed the cert-manager Operator for Red Hat OpenShift.
-
You have enabled user workload monitoring.
-
Create the
ServiceMonitorCR definition file:Exampleservicemonitor-istio-csr.yamlfileapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: app: cert-manager-istio-csr app.kubernetes.io/instance: cert-manager-istio-csr app.kubernetes.io/name: cert-manager-istio-csr name: cert-manager-istio-csr namespace: <istio_csr_project_name> spec: endpoints: - honorLabels: false interval: 60s path: /metrics scrapeTimeout: 30s targetPort: 9402 namespaceSelector: matchNames: - <istio_csr_project_name> selector: matchLabels: app: cert-manager-istio-csr app.kubernetes.io/instance: cert-manager-istio-csr app.kubernetes.io/name: cert-manager-istio-csrReplace
<istio_csr_project_name>with the namespace where you created theIstioCSRCR. -
Create the
ServiceMonitorCR by running the following command:$ oc apply -f servicemonitor-istio-csr.yamlAfter the
ServiceMonitorCR is created, the user workload Prometheus instance starts collecting metrics from the istio-csr operand. The collected metrics are labeled withjob="cert-manager-istio-csr".
-
Log in to the OpenShift Container Platform web console.
-
Click Observe → Targets.
-
In the Label filter field, enter the
service=cert-manager-istio-csrlabel to filter the metrics targets. -
Confirm that the Status column shows Up for the
cert-manager-istio-csrtarget.
Querying metrics for the istio-csr operand
Cluster administrators, or users with view access to all namespaces, can query metrics for the istio-csr operand by using the OpenShift Container Platform web console. For more information, see "Accessing metrics".
-
You have access to the cluster with
cluster-adminprivileges. -
You have installed the cert-manager Operator for Red Hat OpenShift.
-
You have enabled monitoring and metrics collection by creating the
ServiceMonitorobject for the istio-csr operand.
-
Log in to the OpenShift Container Platform web console.
-
Click Observe → Metrics.
-
In the query field, enter the
{job="cert-manager-istio-csr"}PromQL expression to query theistio-csroperand metrics. The results display metrics collected for the istio-csr operand, which can help you monitor its performance and behavior.