Created
September 3, 2020 18:51
-
-
Save hexfusion/362e4fbb20ebc32b2bb56aa25ab397e3 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!=\"\"}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment