-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downloading grafana dashboards from grafana central repo
- Loading branch information
Showing
19 changed files
with
99 additions
and
17,848 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# dashboards to download | ||
# DASHBOARDS="<dashboard_id>:<revision> ..." | ||
DASHBOARDS="16119:10 16115:7" | ||
|
||
TARGET_DIR="/mnt/data" | ||
mkdir -p "$TARGET_DIR" | ||
|
||
for DASHBOARD in $DASHBOARDS; do | ||
delimiter=':' | ||
|
||
# Count the number of occurrences of the delimiter | ||
count=$(echo "$DASHBOARD" | awk -F"$delimiter" '{print NF-1}') | ||
|
||
if [ "$count" -eq 1 ]; then | ||
# Split the string into two parts | ||
ID=$(echo "$DASHBOARD" | cut -d"$delimiter" -f1) | ||
REVISION=$(echo "$DASHBOARD" | cut -d"$delimiter" -f2) | ||
|
||
URL=https://grafana.com/api/dashboards/$ID/revisions/$REVISION/download | ||
FILENAME=$ID-"rev"$REVISION.json | ||
curl -o "$TARGET_DIR/$FILENAME" "$URL" | ||
else | ||
echo "Error: The string must contain exactly one delimiter." | ||
fi | ||
done | ||
|
||
echo "Downloaded files:" | ||
ls -l "$TARGET_DIR" |
Oops, something went wrong.