Monitor multiple GCP projects
You can push metrics to Dynatrace from multiple GCP projects. For example, you can run dynatrace-gcp-monitor
in a project dedicated to monitoring, and get metrics from production, stage, or development projects.
There are two methods for monitoring multiple GCP projects, depending on the size of the environment you want to monitor:
Standard environments (up to 50 projects)
Large environments (50+ projects)
Standard environments
There are two ways you can set up the standard monitoring: using the gcloud CLI or in the GCP console. See below for instructions.
- deploy Dynatrace integration as a GCP function or in a Kubernetes container.
Set up monitoring using the gcloud CLI
To add projects to monitoring using the gcloud CLI
Create IAM roles.
Be sure to replace <your-desired-project-ID>
with the ID of your desired project.
1wget https://raw.githubusercontent.com/dynatrace-oss/dynatrace-gcp-monitor/master/gcp_iam_roles/dynatrace-gcp-monitor-metrics-role.yaml2gcloud iam roles create dynatrace_monitor.metrics --project=<your-desired-project-ID> --file=dynatrace-gcp-monitor-metrics-role.yaml
Grant required IAM policies to the IAM service account for your desired projects.
Be sure to replace <your-desired-project-ID>
with the ID of your desired project, and <your-GCP-project-ID>
with the ID of the project where the IAM service account was created.
-
Repeat step 1 for all the other projects you want to monitor.
-
Enable permission for service usage booking. optional
If you want to set up service usage booking, you need to enable the serviceusage.services.use permission for your IAM service account.
For details about configuring serviceUsageBooking
see Parameters.
It takes about a minute for the metrics from the newly configured projects to appear in the Dynatrace web UI.
For GKE deployment, you must restart your Kubernetes container after adding projects to monitoring.
Set up monitoring in the GCP console
Alternatively, you can grant access for all desired projects in the GCP console.
To add projects to monitoring in the GCP console
- On your GCP console, go to IAM & Admin.
Select a project you want to monitor, and add permissions for the IAM service account attached to the function.
Repeat step 2 for all the other projects you want to monitor.
For GKE deployment, you must restart your Kubernetes container after adding projects to monitoring.
Large environments
To monitor large environments, you can make use of Google's metrics scope feature. You need to select the main scoping project (where the GCP integration will be deployed) and configure the rest of the projects as monitored projects. See below for instructions.
To modify a metrics scope, you need to have the Monitoring Admin (roles/monitoring.admin) role's permissions for all projects involved.
In your GCP console, select the main scoping project and go to the Monitoring service.
- Select Metrics Scope settings from the left menu.
- Select Add Cloud projects to metrics scope.
Select all the desired projects to be monitored by the main scoping project and add them.
Basically, you extend the metrics visibility from the main scoping project to all the monitored projects from your GCP console. For details, see Viewing metrics for multiple projects.
The next step is to deploy the GCP Monitor integration with the parameter scopingProjectSupportEnabled
set to true
in your configuration file. See Main deployment or Alternative deployment scenarios.
This approach should work up to roughly 375 moderately sized projects. If you want to monitor more projects, you will have to set up multiple GCP Monitor integrations in different main scoping projects, assigning each monitored project to one of them.