From 510f55a48bc02ec583633dcf5687cf7ab6198a48 Mon Sep 17 00:00:00 2001 From: Steven Fitzpatrick Date: Fri, 20 Mar 2020 15:05:04 -0500 Subject: [PATCH] Update gather-prom-metrics service selection This change updates how the gather-prom-metrics playbook role chooses which services and ports to scrape when gathering metrics at the end of a zuul build. We can hit more metric endpoints by finding services with a "metrics" port, as not all applications have a service labeled "component=exporter" Change-Id: Ib8db7ea2e7034063eefadad74828d0396407275b --- roles/gather-prom-metrics/tasks/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/gather-prom-metrics/tasks/main.yaml b/roles/gather-prom-metrics/tasks/main.yaml index 769454d710..a5ba9a1b4f 100644 --- a/roles/gather-prom-metrics/tasks/main.yaml +++ b/roles/gather-prom-metrics/tasks/main.yaml @@ -20,9 +20,9 @@ set -e NAMESPACES=$(kubectl get namespaces -o json | jq -r '.items[].metadata.name') for NS in $NAMESPACES; do - SERVICES=$(kubectl get svc -l component=metrics -n $NS -o json | jq -r '.items[].metadata.name') + SERVICES=$(kubectl get svc -n $NS -o json | jq -r '.items[] | select(.spec.ports[].name=="metrics") | .metadata.name') for SVC in $SERVICES; do - PORT=$(kubectl get svc $SVC -n $NS -o json | jq -r '.spec.ports[].port') + PORT=$(kubectl get svc $SVC -n $NS -o json | jq -r '.spec.ports[] | select(.name=="metrics") | .port') curl "$SVC.$NS:$PORT/metrics" >> "{{ logs_dir }}"/prometheus/$NS-$SVC.txt || true done done