Created
June 20, 2021 13:03
-
-
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
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
# '.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