Skip to content

Instantly share code, notes, and snippets.

@zhongfu
Created June 20, 2021 13:03
Show Gist options
  • Save zhongfu/07452f51b33118a65f5b24f4a8461402 to your computer and use it in GitHub Desktop.
Save zhongfu/07452f51b33118a65f5b24f4a8461402 to your computer and use it in GitHub Desktop.
jq script to add a tag filter to every single panel (used for geth dashboard); assumes each panel already has at least one tag filter
# '.panels[1].targets[0].tags |= map(select(.key == "chain" | not)) | .panels[1].targets[0].tags += ["swag"]'
def update_tags:
.tags |= map(select(.key == "chain" | not)) | .tags += [{"condition": "AND", "key": "chain", "operator": "=~", "value": "/^$chain$/"}];
def update_targets:
.targets |= map(if has("tags") then (. | update_tags) else . end);
.panels |= map(if has("targets") then (. | update_targets) else . end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment