Created
September 2, 2022 23:31
-
-
Save dmc5179/b132138d42c5c9de9864fa0ce06e6779 to your computer and use it in GitHub Desktop.
OpenShift 4 Prometheus time series query
This file contains 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
QUERY="kube_pod_status_phase{phase='Running'}" | |
HEADER="Authorization: Bearer sha256~....." | |
API="https://prometheus-k8s-openshift-monitoring.apps.ocp4.something.io/api/v1/query_range?query" | |
START="2022-09-02T19:10:30.781Z" | |
END="2022-09-02T19:11:30.781Z" | |
STEP="15s" | |
rawurlencode_vladr() { | |
local LANG=C | |
local IFS= | |
while read -n1 -r -d "$(echo -n "\000")" c | |
do | |
case "$c" in | |
[-_.~a-zA-Z0-9]) | |
echo -n "$c" | |
;; | |
*) | |
printf '%%%02x' "'$c" | |
;; | |
esac | |
done | |
} | |
ENC_QUERY=$(echo -n "${QUERY}" | rawurlencode_vladr) | |
curl -k -H "${HEADER}" "${API}=${ENC_QUERY}&start=${START}&end=${END}&step=${STEP}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment