From de1fef4ae53d6417b4875cf745563ec04cd6e6f5 Mon Sep 17 00:00:00 2001 From: Ishwar Kanse Date: Tue, 22 Oct 2024 19:00:19 +0530 Subject: [PATCH] Test operator metrics can be scraped by OpenShift Monitoring --- .../monitoring/chainsaw-test.yaml | 26 ++++++++++++++++++- .../e2e-openshift/monitoring/check_metrics.sh | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/e2e-openshift/monitoring/chainsaw-test.yaml b/tests/e2e-openshift/monitoring/chainsaw-test.yaml index 0cf36e93f0..4752e8ccb3 100755 --- a/tests/e2e-openshift/monitoring/chainsaw-test.yaml +++ b/tests/e2e-openshift/monitoring/chainsaw-test.yaml @@ -1,4 +1,3 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: @@ -14,6 +13,31 @@ spec: file: 00-workload-monitoring.yaml - assert: file: 00-assert.yaml + - name: Enable OpenShift platform monitoring on the OpenTelemetry operator namespace + try: + - command: + entrypoint: oc + args: + - get + - pods + - -A + - -l control-plane=controller-manager + - -l app.kubernetes.io/name=opentelemetry-operator + - -o + - jsonpath={.items[0].metadata.namespace} + outputs: + - name: OTEL_NAMESPACE + value: ($stdout) + - command: + env: + - name: otelnamespace + value: ($OTEL_NAMESPACE) + entrypoint: oc + args: + - label + - namespace + - $otelnamespace + - openshift.io/cluster-monitoring=true - name: step-01 try: - apply: diff --git a/tests/e2e-openshift/monitoring/check_metrics.sh b/tests/e2e-openshift/monitoring/check_metrics.sh index e92a1649e4..8dd65fc4e0 100755 --- a/tests/e2e-openshift/monitoring/check_metrics.sh +++ b/tests/e2e-openshift/monitoring/check_metrics.sh @@ -4,7 +4,7 @@ TOKEN=$(oc create token prometheus-user-workload -n openshift-user-workload-moni THANOS_QUERIER_HOST=$(oc get route thanos-querier -n openshift-monitoring -o json | jq -r '.spec.host') #Check metrics for OpenTelemetry collector instance. -metrics="otelcol_process_uptime otelcol_process_runtime_total_sys_memory_bytes otelcol_process_memory_rss otelcol_exporter_sent_spans otelcol_process_cpu_seconds otelcol_process_memory_rss otelcol_process_runtime_heap_alloc_bytes otelcol_process_runtime_total_alloc_bytes otelcol_process_runtime_total_sys_memory_bytes otelcol_process_uptime otelcol_receiver_accepted_spans otelcol_receiver_refused_spans" +metrics="otelcol_process_uptime otelcol_process_runtime_total_sys_memory_bytes otelcol_process_memory_rss otelcol_exporter_sent_spans otelcol_process_cpu_seconds otelcol_process_memory_rss otelcol_process_runtime_heap_alloc_bytes otelcol_process_runtime_total_alloc_bytes otelcol_process_runtime_total_sys_memory_bytes otelcol_process_uptime otelcol_receiver_accepted_spans otelcol_receiver_refused_spans opentelemetry_collector_info opentelemetry_collector_exporters opentelemetry_collector_receivers" for metric in $metrics; do query="$metric"