Configuring metrics collection for cert-manager Operator for Red Hat OpenShift operands by using a ServiceMonitor
You can configure metrics collection for the cert-manager Operator for Red Hat OpenShift operands by creating a ServiceMonitor custom resource (CR).
The cert-manager Operator for Red Hat OpenShift operands expose metrics by default on port 9402 at the /metrics service endpoint. The ServiceMonitor CR enables Prometheus Operator to collect custom 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 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 Red Hat 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.