Monitor multiple Google Cloud projects

You can push metrics to Dynatrace from multiple Google Cloud 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 Google Cloud projects, depending on the size of the environment you want to monitor:

  • Large environments—suggested multiproject method
  • Standard environments—alternative method

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 Google Cloud 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.

  1. In your Google Cloud console, select the main scoping project and go to the Monitoring service.
  2. Select Metrics Scope settings from the left menu.
  3. Select Add Cloud projects to metrics scope.
  4. 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 Google Cloud console. For details, see Viewing metrics for multiple projects.

The next step is to deploy the Google Cloud 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'll have to set up multiple Google Cloud Monitor integrations in different main scoping projects, assigning each monitored project to one of them.

Standard environments

There are two ways you can set up the standard monitoring: using the gcloud CLI or in the Google Cloud console. See below for instructions.

Prerequisites

Deploy Dynatrace integration in a Kubernetes container.

Set up monitoring using the gcloud CLI

To add projects to monitoring using the gcloud CLI

  1. Create IAM roles.

Be sure to replace <your-desired-project-ID> with the ID of your desired project.

wget https://raw.githubusercontent.com/dynatrace-oss/dynatrace-gcp-monitor/master/gcp_iam_roles/dynatrace-gcp-monitor-metrics-role.yaml
gcloud iam roles create dynatrace_monitor.metrics --project=<your-desired-project-ID> --file=dynatrace-gcp-monitor-metrics-role.yaml
  1. 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.

  1. Repeat step 1 and 2 for all the other projects you want to monitor.

  2. 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 Dynatrace.

For GKE deployment, you must restart your Kubernetes container after adding projects to monitoring.

Set up monitoring in the Google Cloud console

Alternatively, you can grant access for all desired projects in the Google Cloud console.

To add projects to monitoring in the Google Cloud console

  1. On your Google Cloud console, go to IAM & Admin.
  2. Select a project you want to monitor, and add permissions for the IAM service account attached to the function.
  3. 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.