Created
February 19, 2025 13:41
-
-
Save pbertera/0340221c57ca6a1f589a655ca2220dfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function queue() { | |
local TARGET="${1}" | |
shift | |
local LIVE | |
LIVE="$(jobs | wc -l)" | |
while [[ "${LIVE}" -ge 45 ]]; do | |
sleep 1 | |
LIVE="$(jobs | wc -l)" | |
done | |
echo "${@}" | |
if [[ -n "${FILTER:-}" ]]; then | |
"${@}" | "${FILTER}" >"${TARGET}" & | |
else | |
"${@}" >"${TARGET}" & | |
fi | |
} | |
ARTIFACT_DIR=$PWD | |
mkdir -p $ARTIFACT_DIR/metrics | |
echo "Snapshotting prometheus (may take 15s) ..." | |
queue ${ARTIFACT_DIR}/metrics/prometheus.tar.gz oc --insecure-skip-tls-verify exec -n openshift-monitoring prometheus-k8s-0 -- tar cvzf - -C /prometheus . | |
FILTER=gzip queue ${ARTIFACT_DIR}/metrics/prometheus-target-metadata.json.gz oc --insecure-skip-tls-verify exec -n openshift-monitoring prometheus-k8s-0 -- /bin/bash -c "curl -G http://localhost:9090/api/v1/targets/metadata --data-urlencode 'match_target={instance!=\"\"}'" | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment