Skip to content

Instantly share code, notes, and snippets.

@jjo
Created August 8, 2025 20:50
Show Gist options
  • Save jjo/aba7f53052c8961dbaf574c12d3039d6 to your computer and use it in GitHub Desktop.
Save jjo/aba7f53052c8961dbaf574c12d3039d6 to your computer and use it in GitHub Desktop.
# 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