Last active
November 7, 2019 20:22
-
-
Save pryorda/cba432e94ac7006caff1af69b20d53ad to your computer and use it in GitHub Desktop.
Get Count of Prometheus values by Day
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
#!/bin/bash | |
startdate=2019-10-01 | |
enddate=$(date -I) | |
d="$startdate" | |
while [ "$d" != "$enddate" ]; do | |
current=$d | |
d=$(date -I -d "$d + 1 day") | |
data=$(curl -s 'http://prometheus/api/v1/query_range?query=probe_http_status_code\{job="kubernetes-services",instance=~".*conversion.*"\}&start='$current'T00:00:00.000Z&end='$d'T00:00:00.000Z&step=15s') | |
count=$(echo ${data}|jq '.data.result[0].values[] | select( .[1] != "200")' 2>&1 |grep -c \"0\") | |
echo ${current}:${count} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment