#!/usr/bin/env bash # T31: envoy_http_downstream_rq_active is NOT exposed on /stats/prometheus by default; # it appears only after proxyStatsMatcher.inclusionRegexps is added via the # proxy.istio.io/config pod annotation (which requires pod recreation to take effect). set -euo pipefail NS="istio-vt-t31" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" MANIFEST="${SCRIPT_DIR}/manifest.yaml" cleanup() { kubectl delete namespace "$NS" --wait=false --ignore-not-found } trap cleanup EXIT kubectl create namespace "$NS" kubectl label namespace "$NS" istio-injection=enabled kubectl apply -f "$MANIFEST" kubectl -n "$NS" wait --for=condition=Ready pod/client --timeout=90s kubectl -n "$NS" rollout status deploy/echo --timeout=120s echo ">>> BEFORE annotation: expect 0" kubectl -n "$NS" exec client -c istio-proxy -- curl -s localhost:15000/stats/prometheus \ | grep -c 'envoy_http_downstream_rq_active' || true kubectl -n "$NS" annotate pod client \ 'proxy.istio.io/config={"proxyStatsMatcher":{"inclusionRegexps":[".*downstream_rq_active.*"]}}' \ --overwrite # Annotating a live bare Pod does NOT reconfigure the already-injected sidecar; # the pod must be deleted/recreated so the injection webhook re-reads the annotation. # manifest.yaml already has the annotation baked into the client Pod spec. kubectl -n "$NS" delete pod client --wait=true kubectl apply -f "$MANIFEST" kubectl -n "$NS" wait --for=condition=Ready pod/client --timeout=90s echo ">>> AFTER annotation + pod recreation: expect >0" kubectl -n "$NS" exec client -c istio-proxy -- curl -s localhost:15000/stats/prometheus \ | grep -c 'envoy_http_downstream_rq_active' || true