mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
chore(grafana): operate on an aws-managed grafana instance
This commit is contained in:
@@ -135,12 +135,15 @@ yq -e '(.backend.url|test("^file://")?)|not' 'Pulumi.yaml'
|
||||
|
||||
## Further readings
|
||||
|
||||
- [Website]
|
||||
- [Codebase]
|
||||
- [JQ recipes]
|
||||
|
||||
[jq recipes]: https://remysharp.com/drafts/jq-recipes
|
||||
|
||||
### Sources
|
||||
|
||||
- [Documentation]
|
||||
- [Filter objects list with regex]
|
||||
- [Select multiple conditions]
|
||||
- [Change multiple values at once]
|
||||
@@ -155,6 +158,11 @@ yq -e '(.backend.url|test("^file://")?)|not' 'Pulumi.yaml'
|
||||
═╬═Time══
|
||||
-->
|
||||
|
||||
<!-- Upstream -->
|
||||
[codebase]: https://github.com/jqlang/jq
|
||||
[documentation]: https://jqlang.org/manual/
|
||||
[website]: https://jqlang.org/
|
||||
|
||||
<!-- Others -->
|
||||
[an introduction to jq]: https://earthly.dev/blog/jq-select/
|
||||
[change multiple values at once]: https://stackoverflow.com/questions/47355901/jq-change-multiple-values#47357956
|
||||
|
||||
@@ -1,13 +1,34 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# List dashboards
|
||||
curl -sS 'http://grafana:3000/api/search' -H 'Authorization: Basic YWRtaW46YWRtaW4='
|
||||
curl -sS 'https://g-0123456789.grafana-workspace.eu-west-1.amazonaws.com/api/dashboards/uid/abcdefghijklmn' \
|
||||
-H 'Authorization: Bearer glsa_0123456789AbcdEfghIjklMnopQrstUv_0123abcd'
|
||||
|
||||
# Get dashboards' json definition
|
||||
curl -sS 'https://g-0123456789.grafana-workspace.eu-west-1.amazonaws.com/api/dashboards/uid/abcdefghijklmn' \
|
||||
-H 'Authorization: Bearer glsa_0123456789AbcdEfghIjklMnopQrstUv_0123abcd'
|
||||
|
||||
# Export all existing dashboards by ID
|
||||
curl -sS \
|
||||
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
|
||||
'http://grafana:3000/api/search' \
|
||||
curl -sS 'http://grafana:3000/api/search' -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
|
||||
| jq -r '.[].uid' - \
|
||||
| parallel " \
|
||||
curl -sS \
|
||||
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
|
||||
'http://grafana:3000/api/dashboards/uid/{}' \
|
||||
curl -sS 'http://grafana:3000/api/dashboards/uid/{}' -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
|
||||
> '{}.json' \
|
||||
"
|
||||
|
||||
# Get the UID of all dashboards using specific data sources
|
||||
curl -Ss 'https://g-0123456789.grafana-workspace.eu-west-1.amazonaws.com/api/search' \
|
||||
-H 'Authorization: Bearer glsa_0123456789AbcdEfghIjklMnopQrstUv_0123abcd' \
|
||||
| jq -r '.[].uid' \
|
||||
| parallel " \
|
||||
curl -Ss 'https://g-0123456789.grafana-workspace.eu-west-1.amazonaws.com/api/dashboards/uid/{}' \
|
||||
-H 'Authorization: Bearer glsa_0123456789AbcdEfghIjklMnopQrstUv_0123abcd' \
|
||||
" \
|
||||
| jq -rs '
|
||||
.[].dashboard
|
||||
| select(
|
||||
(.panels[]? | if .datasource|type == "string" then .datasource else .datasource?.uid end) == "abcdefghi"
|
||||
).uid
|
||||
' - \
|
||||
| sort -u
|
||||
|
||||
Reference in New Issue
Block a user