Skip to content

Commit 850e4a1

Browse files
authored
Metrics Follow-Ups (#2105)
Adding comment for traceability to prometheus alert rules. Move prometheus installation to new script to clean up makefile. Signed-off-by: Daniel Franz <dfranz@redhat.com>
1 parent 7c12644 commit 850e4a1

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,22 +282,13 @@ test-experimental-e2e: run image-registry prometheus experimental-e2e e2e e2e-me
282282
.PHONY: prometheus
283283
prometheus: PROMETHEUS_NAMESPACE := olmv1-system
284284
prometheus: PROMETHEUS_VERSION := v0.83.0
285-
prometheus: TMPDIR := $(shell mktemp -d)
286285
prometheus: #EXHELP Deploy Prometheus into specified namespace
287-
trap 'echo "Cleaning up $(TMPDIR)"; rm -rf "$(TMPDIR)"' EXIT; \
288-
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/$(PROMETHEUS_VERSION)/kustomization.yaml" > "$(TMPDIR)/kustomization.yaml"; \
289-
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/$(PROMETHEUS_VERSION)/bundle.yaml" > "$(TMPDIR)/bundle.yaml"; \
290-
(cd $(TMPDIR) && $(KUSTOMIZE) edit set namespace $(PROMETHEUS_NAMESPACE)) && kubectl create -k "$(TMPDIR)"
291-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) -l app.kubernetes.io/name=prometheus-operator
292-
$(KUSTOMIZE) build config/overlays/prometheus | sed "s/cert-git-version/cert-$(VERSION)/g" | kubectl apply -f -
293-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) -l app.kubernetes.io/name=prometheus-operator --timeout=60s
294-
kubectl wait --for=create pods -n $(PROMETHEUS_NAMESPACE) prometheus-prometheus-0 --timeout=60s
295-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) prometheus-prometheus-0 --timeout=120s
286+
./hack/test/install-prometheus.sh $(PROMETHEUS_NAMESPACE) $(PROMETHEUS_VERSION) $(KUSTOMIZE) $(VERSION)
296287

297288
# The output alerts.out file contains any alerts, pending or firing, collected during a test run in json format.
298289
.PHONY: e2e-metrics
299290
e2e-metrics: ALERTS_FILE_PATH := $(if $(ARTIFACT_PATH),$(ARTIFACT_PATH),.)/alerts.out
300-
e2e-metrics: #EXHELP Request metrics from prometheus; select only actively firing alerts; place in ARTIFACT_PATH if set
291+
e2e-metrics: #EXHELP Request metrics from prometheus; place in ARTIFACT_PATH if set
301292
curl -X GET http://localhost:30900/api/v1/alerts | jq 'if (.data.alerts | length) > 0 then .data.alerts.[] else empty end' > $(ALERTS_FILE_PATH)
302293

303294
.PHONY: extension-developer-e2e

config/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Overlay containing manifest files which enable prometheus scraping of the catalo
3333

3434
These manifests will not end up in the `manifests/` folder, as they must be applied in two distinct steps to avoid issues with applying prometheus CRDs and CRs simultaneously.
3535

36+
Performance alert settings can be found in: `config/overlays/prometheus/prometheus_rule.yaml`
37+
3638
## config/overlays/experimental
3739

3840
This provides additional configuration used to support experimental features, including CRDs. This configuration requires cert-manager.

hack/test/install-prometheus.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
help="install-prometheus.sh is used to set up prometheus monitoring for e2e testing.
6+
Usage:
7+
install-prometheus.sh [PROMETHEUS_NAMESPACE] [PROMETHEUS_VERSION] [KUSTOMIZE] [GIT_VERSION]
8+
"
9+
10+
if [[ "$#" -ne 4 ]]; then
11+
echo "Illegal number of arguments passed"
12+
echo "${help}"
13+
exit 1
14+
fi
15+
16+
PROMETHEUS_NAMESPACE="$1"
17+
PROMETHEUS_VERSION="$2"
18+
KUSTOMIZE="$3"
19+
GIT_VERSION="$4"
20+
21+
TMPDIR="$(mktemp -d)"
22+
trap 'echo "Cleaning up $TMPDIR"; rm -rf "$TMPDIR"' EXIT
23+
24+
echo "Downloading Prometheus resources..."
25+
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/${PROMETHEUS_VERSION}/kustomization.yaml" > "${TMPDIR}/kustomization.yaml"
26+
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/${PROMETHEUS_VERSION}/bundle.yaml" > "${TMPDIR}/bundle.yaml"
27+
28+
echo "Patching namespace to ${PROMETHEUS_NAMESPACE}..."
29+
(cd "$TMPDIR" && $KUSTOMIZE edit set namespace "$PROMETHEUS_NAMESPACE")
30+
31+
echo "Applying Prometheus base..."
32+
kubectl apply -k "$TMPDIR" --server-side
33+
34+
echo "Waiting for Prometheus Operator pod to become ready..."
35+
kubectl wait --for=condition=Ready pod -n "$PROMETHEUS_NAMESPACE" -l app.kubernetes.io/name=prometheus-operator
36+
37+
echo "Applying overlay config..."
38+
$KUSTOMIZE build config/overlays/prometheus | sed "s/cert-git-version/cert-${VERSION}/g" | kubectl apply -f -
39+
40+
echo "Waiting for metrics scraper to become ready..."
41+
kubectl wait --for=create pods -n "$PROMETHEUS_NAMESPACE" prometheus-prometheus-0 --timeout=60s
42+
kubectl wait --for=condition=Ready pods -n "$PROMETHEUS_NAMESPACE" prometheus-prometheus-0 --timeout=120s
43+
44+
echo "Prometheus deployment completed successfully."

0 commit comments

Comments
 (0)