-
-
Save okgolove/55bae23ffc6c2823f1767dcadc186093 to your computer and use it in GitHub Desktop.
Prepares exported Grafana JSON to be loaded by Prometheus Operator -> Grafana Watcher
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
| # !/bin/bash | |
| # | |
| # Usage: | |
| # 1. Copy the JSON from Grafana -> Export as JSON -> Clipboard | |
| # 2. ./prepare_dashboard.sh new_dashboard_xxx | |
| # - This will create new_dashboard_xxx-dashboard.json | |
| # | |
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| if [ "$#" -ne 1 ]; then | |
| echo "Usage: ./prepare_dashboard.sh <name_of_dashboard>" | |
| exit | |
| fi | |
| # Prepare json for Grafana Watcher | |
| pbpaste | \ | |
| jq '.id = null | del(.__requires) | del(.uid) | { dashboard: . , inputs: .__inputs, overwrite: true }' | \ | |
| jq '.inputs[0].value=.inputs[0].pluginId' | \ | |
| tee "$DIR/$1-dashboard.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment