How to export and import google cloud monitoring dashboards between projects using script or API?
Asked Answered
D

2

5

I have exported the dashboards using gcloud alpha monitoring dashboards list --format=json, but using gcloud dashboard create using file is not working, basically I want to export the dashboards from one project and import that in other project.

Doone answered 4/5, 2020 at 13:6 Comment(1)
what error do you see when using gcloud dashboard create with file ?Dace
T
13

The output of the list sub command probably (didn't test this) has too many dashboards for the create command. Also, you should remove two fields (name and etag). No need to export as json, yaml will also work and is easier to edit anyway.

I did the following:

  • gcloud monitoring dashboards list and find the dashboard I was looking for
  • Note it's name property and get the id from the last part in the name property (a large decimal number or guid)
  • gcloud monitoring dashboards describe $DASHBOARD_ID > dashboard-$DASHBOARD_ID.yaml the dashboard
  • Edit the file to remove the etag and name field (the name is usually located at the end of the file)
  • gcloud monitoring dashboards create --config-from-file dashboard-$DASHBOARD_ID.yaml
Trounce answered 15/7, 2020 at 19:55 Comment(1)
Can confirm. Appreciate the answer.Sillimanite
B
1

You can also copy dashboards using the console by opening the JSON editor of the source project dashboard copying the whole source text, creating a new dashboard in the other project, opening the JSON editor and pasting the text from the clipboard.

Bischoff answered 18/4, 2023 at 19:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.