From d65847ac05c4d10deefcfaaa5fe36c74c2698e6c Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 19 May 2026 11:38:47 +0200 Subject: [PATCH 1/2] feat: Manage prometheus resources Signed-off-by: Anatolii Bazko --- ...ollecting-che-metrics-with-prometheus.adoc | 96 +------------------ ...pace-operator-metrics-with-prometheus.adoc | 52 +--------- 2 files changed, 4 insertions(+), 144 deletions(-) diff --git a/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc b/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc index b86014256a..ea7b1e62c8 100644 --- a/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc +++ b/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc @@ -3,100 +3,8 @@ [id="collecting-{prod-id-short}-metrics-with-prometheus"] = Collecting {prod-short} Server metrics with Prometheus -To use the in-cluster Prometheus instance to collect, store, and query JVM metrics for {prod-short} Server: - -.Prerequisites - -* Your organization's instance of {prod-short} is installed and running in Red Hat OpenShift. - -* An active `oc` session with administrative permissions to the destination OpenShift cluster. See link:https://docs.openshift.com/container-platform/{ocp4-ver}/cli_reference/openshift_cli/getting-started-cli.html[Getting started with the CLI]. - -* {prod-short} is exposing metrics on port `8087`. See xref:enabling-and-exposing-{prod-id-short}-metrics[Enabling and exposing {prod-short} server JVM metrics]. - -.Procedure - -. Create the ServiceMonitor for detecting the {prod-short} JVM metrics Service. -+ -.ServiceMonitor -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: che-host - namespace: {prod-namespace} <1> -spec: - endpoints: - - interval: 10s <2> - port: metrics - scheme: http - namespaceSelector: - matchNames: - - {prod-namespace} <1> - selector: - matchLabels: - app.kubernetes.io/name: {prod-deployment} ----- -<1> The {prod-short} namespace. The default is `{prod-namespace}`. -<2> The rate at which a target is scraped. -==== - -. Create a Role and RoleBinding to allow Prometheus to view the metrics. - -+ -.Role -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: prometheus-k8s - namespace: {prod-namespace} <1> -rules: - - verbs: - - get - - list - - watch - apiGroups: - - '' - resources: - - services - - endpoints - - pods ----- -<1> The {prod-short} namespace. The default is `{prod-namespace}`. -==== - -+ -.RoleBinding -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: view-{prod-id-short}-openshift-monitoring-prometheus-k8s - namespace: {prod-namespace} <1> -subjects: - - kind: ServiceAccount - name: prometheus-k8s - namespace: openshift-monitoring -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: prometheus-k8s ----- -<1> The {prod-short} namespace. The default is `{prod-namespace}`. -==== - -. Allow the in-cluster Prometheus instance to detect the ServiceMonitor in the {prod-short} namespace. The default {prod-short} namespace is `{prod-namespace}`. -+ -[source,terminal,subs="+attributes,quotes"] ----- -$ oc label namespace {prod-namespace} openshift.io/cluster-monitoring=true ----- +The {prod-operator} automatically creates the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring {prod-short} Server JVM metrics. +No manual configuration is required. The operator reconciles these resources automatically. .Verification diff --git a/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc b/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc index b198f24bd1..00f130d42e 100644 --- a/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc +++ b/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc @@ -2,56 +2,8 @@ = Collecting {devworkspace} Operator metrics [role="_abstract"] -To use the in-cluster Prometheus instance to collect, store, and query metrics about the {devworkspace} Operator: - -.Prerequisites - -* Your organization's instance of {prod-short} is installed and running in Red Hat OpenShift. - -* An active `oc` session with administrative permissions to the destination OpenShift cluster. See link:https://docs.openshift.com/container-platform/{ocp4-ver}/cli_reference/openshift_cli/getting-started-cli.html[Getting started with the CLI]. - -* The `devworkspace-controller-metrics` Service is exposing metrics on port `8443`. This is preconfigured by default. - -.Procedure - -. Create the ServiceMonitor for detecting the Dev Workspace Operator metrics Service. -+ -.ServiceMonitor -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: devworkspace-controller - namespace: {prod-namespace} <1> -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 10s <2> - port: metrics - scheme: https - tlsConfig: - insecureSkipVerify: true - namespaceSelector: - matchNames: - - openshift-operators - selector: - matchLabels: - app.kubernetes.io/name: devworkspace-controller ----- -<1> The {prod-short} namespace. The default is `{prod-namespace}`. -<2> The rate at which a target is scraped. -==== - -include::example$snip_{project-context}-create-a-role-and-rolebinding-for-prometheus-to-view-metrics.adoc[] - -. Allow the in-cluster Prometheus instance to detect the ServiceMonitor in the {prod-short} namespace. The default {prod-short} namespace is `{prod-namespace}`. -+ -[source,subs="+attributes"] ----- -$ oc label namespace {prod-namespace} openshift.io/cluster-monitoring=true ----- +The {prod-operator} automatically creates the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring the {devworkspace} Operator. +No manual configuration is required. The operator reconciles these resources automatically. .Verification From 9a6973344e1986c34a31c99a6465ef10e83f5770 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 20 May 2026 10:03:02 +0200 Subject: [PATCH 2/2] address remarks Signed-off-by: Anatolii Bazko --- ...inding-for-prometheus-to-view-metrics.adoc | 46 ------------------- .../pages/monitoring-che.adoc | 2 +- ...monitoring-the-dev-workspace-operator.adoc | 2 +- ...llecting-che-metrics-with-prometheus.adoc} | 12 +++-- ...ace-operator-metrics-with-prometheus.adoc} | 15 +++--- ...perator-metrics-on-grafana-dashboards.adoc | 2 +- 6 files changed, 18 insertions(+), 61 deletions(-) delete mode 100644 modules/administration-guide/examples/snip_che-create-a-role-and-rolebinding-for-prometheus-to-view-metrics.adoc rename modules/administration-guide/partials/{proc_collecting-che-metrics-with-prometheus.adoc => con_collecting-che-metrics-with-prometheus.adoc} (69%) rename modules/administration-guide/partials/{proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc => con_collecting-dev-workspace-operator-metrics-with-prometheus.adoc} (67%) diff --git a/modules/administration-guide/examples/snip_che-create-a-role-and-rolebinding-for-prometheus-to-view-metrics.adoc b/modules/administration-guide/examples/snip_che-create-a-role-and-rolebinding-for-prometheus-to-view-metrics.adoc deleted file mode 100644 index 48f6543aa3..0000000000 --- a/modules/administration-guide/examples/snip_che-create-a-role-and-rolebinding-for-prometheus-to-view-metrics.adoc +++ /dev/null @@ -1,46 +0,0 @@ -. Create a Role and RoleBinding to allow Prometheus to view the metrics. - -+ -.Role -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: prometheus-k8s - namespace: openshift-operators -rules: - - verbs: - - get - - list - - watch - apiGroups: - - '' - resources: - - services - - endpoints - - pods ----- -==== - -+ -.RoleBinding -==== -[source,yaml,subs="+quotes,+attributes,+macros"] ----- -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: view-che-openshift-monitoring-prometheus-k8s - namespace: openshift-operators -subjects: - - kind: ServiceAccount - name: prometheus-k8s - namespace: openshift-monitoring -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: prometheus-k8s ----- -==== diff --git a/modules/administration-guide/pages/monitoring-che.adoc b/modules/administration-guide/pages/monitoring-che.adoc index bb2e75effb..1c702e7d88 100644 --- a/modules/administration-guide/pages/monitoring-che.adoc +++ b/modules/administration-guide/pages/monitoring-che.adoc @@ -11,6 +11,6 @@ You can configure {prod-short} to expose JVM metrics such as JVM memory and clas include::partial$proc_enabling-and-exposing-che-metrics.adoc[leveloffset=+1] -include::partial$proc_collecting-che-metrics-with-prometheus.adoc[leveloffset=+1] +include::partial$con_collecting-che-metrics-with-prometheus.adoc[leveloffset=+1] include::partial$proc_viewing-che-metrics-on-grafana-dashboards.adoc[leveloffset=+1] diff --git a/modules/administration-guide/pages/monitoring-the-dev-workspace-operator.adoc b/modules/administration-guide/pages/monitoring-the-dev-workspace-operator.adoc index ca14505223..8a57469f90 100644 --- a/modules/administration-guide/pages/monitoring-the-dev-workspace-operator.adoc +++ b/modules/administration-guide/pages/monitoring-the-dev-workspace-operator.adoc @@ -10,7 +10,7 @@ You can configure the OpenShift in-cluster monitoring stack to scrape metrics exposed by the {devworkspace} Operator. -include::partial$proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc[leveloffset=+1] +include::partial$con_collecting-dev-workspace-operator-metrics-with-prometheus.adoc[leveloffset=+1] include::partial$ref_devworkspace-specific-metrics.adoc[leveloffset=+1] diff --git a/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc b/modules/administration-guide/partials/con_collecting-che-metrics-with-prometheus.adoc similarity index 69% rename from modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc rename to modules/administration-guide/partials/con_collecting-che-metrics-with-prometheus.adoc index ea7b1e62c8..2293ac1e95 100644 --- a/modules/administration-guide/partials/proc_collecting-che-metrics-with-prometheus.adoc +++ b/modules/administration-guide/partials/con_collecting-che-metrics-with-prometheus.adoc @@ -1,10 +1,12 @@ // monitoring-{prod-id-short} +:page-aliases: .:proc_collecting-che-metrics-with-prometheus.adoc [id="collecting-{prod-id-short}-metrics-with-prometheus"] -= Collecting {prod-short} Server metrics with Prometheus += Verifying {prod-short} Server metrics collection with Prometheus -The {prod-operator} automatically creates the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring {prod-short} Server JVM metrics. -No manual configuration is required. The operator reconciles these resources automatically. +[role="_abstract"] +The {prod-operator} automatically creates and reconciles the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring {prod-short} Server JVM metrics. +No manual configuration is required. .Verification @@ -19,14 +21,14 @@ To troubleshoot missing metrics, view the Prometheus container logs for possible . Get the name of the Prometheus pod: + -[source,yaml,subs="+quotes"] +[source,terminal,subs="+quotes"] ---- $ oc get pods -l app.kubernetes.io/name=prometheus -n openshift-monitoring -o=jsonpath='{.items[*].metadata.name}' ---- . Print the last 20 lines of the Prometheus container logs from the Prometheus pod from the previous step: + -[source,yaml,subs="+quotes"] +[source,terminal,subs="+quotes"] ---- $ oc logs --tail=20 ____ -c prometheus -n openshift-monitoring ---- diff --git a/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc b/modules/administration-guide/partials/con_collecting-dev-workspace-operator-metrics-with-prometheus.adoc similarity index 67% rename from modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc rename to modules/administration-guide/partials/con_collecting-dev-workspace-operator-metrics-with-prometheus.adoc index 00f130d42e..d7d4e3080f 100644 --- a/modules/administration-guide/partials/proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc +++ b/modules/administration-guide/partials/con_collecting-dev-workspace-operator-metrics-with-prometheus.adoc @@ -1,9 +1,11 @@ -[id="proc_collecting-dev-workspace-operator-metrics-with-prometheus"] -= Collecting {devworkspace} Operator metrics +:page-aliases: .:proc_collecting-dev-workspace-operator-metrics-with-prometheus.adoc + +[id="collecting-dev-workspace-operator-metrics-with-prometheus"] += Verifying {devworkspace} Operator metrics collection with Prometheus [role="_abstract"] -The {prod-operator} automatically creates the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring the {devworkspace} Operator. -No manual configuration is required. The operator reconciles these resources automatically. +The {prod-operator} automatically creates and reconciles the required Prometheus resources (ServiceMonitor, Role, and RoleBinding) and configures {orch-namespace} labeling for monitoring the {devworkspace} Operator. +No manual configuration is required. .Verification @@ -22,14 +24,14 @@ To troubleshoot missing metrics, view the Prometheus container logs for possible . Get the name of the Prometheus pod: + -[source,yaml,subs="+quotes"] +[source,terminal,subs="+quotes"] ---- $ oc get pods -l app.kubernetes.io/name=prometheus -n openshift-monitoring -o=jsonpath='{.items[*].metadata.name}' ---- . Print the last 20 lines of the Prometheus container logs from the Prometheus pod from the previous step: + -[source,yaml,subs="+quotes"] +[source,terminal,subs="+quotes"] ---- $ oc logs --tail=20 ____ -c prometheus -n openshift-monitoring ---- @@ -39,4 +41,3 @@ $ oc logs --tail=20 ____ -c prometheus -n openshift-monitor .Additional resources * link:https://prometheus.io/docs/prometheus/latest/querying/basics/[Querying Prometheus] * link:https://prometheus.io/docs/concepts/metric_types/[Prometheus metric types] - diff --git a/modules/administration-guide/partials/proc_viewing-dev-workspace-operator-metrics-on-grafana-dashboards.adoc b/modules/administration-guide/partials/proc_viewing-dev-workspace-operator-metrics-on-grafana-dashboards.adoc index d6fa309b81..6486f5fe1e 100644 --- a/modules/administration-guide/partials/proc_viewing-dev-workspace-operator-metrics-on-grafana-dashboards.adoc +++ b/modules/administration-guide/partials/proc_viewing-dev-workspace-operator-metrics-on-grafana-dashboards.adoc @@ -9,7 +9,7 @@ After configuring the in-cluster Prometheus instance to collect {devworkspace} O * An active `oc` session with administrative permissions to the destination OpenShift cluster. See link:https://docs.openshift.com/container-platform/{ocp4-ver}/cli_reference/openshift_cli/getting-started-cli.html[Getting started with the CLI]. -* The in-cluster Prometheus instance is collecting metrics. See xref:proc_collecting-dev-workspace-operator-metrics-with-prometheus[]. +* The in-cluster Prometheus instance is collecting metrics. See xref:collecting-dev-workspace-operator-metrics-with-prometheus[]. .Procedure