Created
August 8, 2025 20:50
-
-
Save jjo/aba7f53052c8961dbaf574c12d3039d6 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
# Transform a map of | |
# { <wave1>: [<cluster1>, ... <clusterN>], ... } | |
# to entries as | |
# absent(__foo{cluster="cluster1", wave="wave1"}) or | |
# absent(__foo{cluster="cluster2", wave="wave1"}) | |
# which are join-able via promQL against cluster- labeled timeseries | |
$ ./scripts/monitoring/rightsizing/clusters-by-wave.sh karpenter | jq -r '. as $r | |
| ["ops","prod0","prod1","prod2","prod3","prod4"] as $wave | |
| reduce $wave[] as $w ([]; . + (( $r[$w] // [] ) | |
| map({wave:$w, cluster:.}))) | |
| to_entries | |
| .[] | "absent(__foo{cluster=\"\(.value.cluster)\", wave=\"\(.value.wave)\"}) or"' \ | |
| sed '$s/or$//' # remove last "or" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment