Deploy the Dynatrace Google Cloud metric integration in Google Cloud Functions

deprecated

Dynatrace version 1.230+

Dynatrace Google Cloud metric integration in Google Cloud Functions is not supported anymore.

If you're using this kind of deployment, you should switch to k8s-based Google Cloud integration as soon as possible. See Migrate from Google Cloud Functions 1.0 to Google Cloud k8s 1.0.

As an alternative to the main deployment, that provides Google Cloud monitoring for both metrics and logs, and where the deployment takes place in a GKE cluster, you can choose to set up monitoring for metrics only, in Google Cloud Cloud Function. Note that the Google Cloud Cloud Function deployment isn't recommended for large environments and doesn't support log forwarding. In this scenario, you will be able run the deployment script either in Google Cloud Shell or in bash. After installation, you'll get metrics, dashboards, and alerts for your configured services in Dynatrace.

For other deployment options, see Alternative deployment scenarios.

This page describes how to deploy version 1.0 of the Dynatrace Google Cloud integration in Google Cloud Cloud Function.

Prerequisites

Tools

You can deploy the Dynatrace Google Cloud integration in Google Cloud Shell or in bash.

If you use bash, you need to install:

Google Cloud permissions

Running the deployment script requires a list of permissions. You need to create a custom role and use it to deploy dynatrace-gcp-monitor.

To create a custom role

  1. Create a YAML file named dynatrace-gcp-monitor-cloud-function-deployment-role.yaml with the following content:

    title: Dynatrace GCP Monitor cloud function deployment role
    description: Role for Dynatrace GCP Monitor cloud function deployment
    stage: GA
    includedPermissions:
    - appengine.applications.get
    - appengine.applications.create
    - cloudfunctions.functions.create
    - cloudfunctions.functions.get
    - cloudfunctions.functions.list
    - cloudfunctions.functions.sourceCodeSet
    - cloudfunctions.functions.update
    - cloudfunctions.functions.getIamPolicy
    - cloudfunctions.operations.get
    - cloudfunctions.operations.list
    - cloudscheduler.locations.list
    - cloudscheduler.jobs.list
    - cloudscheduler.jobs.create
    - cloudscheduler.jobs.get
    - cloudscheduler.jobs.delete
    - pubsub.topics.list
    - pubsub.topics.create
    - pubsub.topics.update
    - secretmanager.secrets.list
    - secretmanager.versions.add
    - secretmanager.secrets.create
    - secretmanager.versions.list
    - secretmanager.secrets.getIamPolicy
    - secretmanager.secrets.setIamPolicy
    - resourcemanager.projects.get
    - resourcemanager.projects.getIamPolicy
    - resourcemanager.projects.setIamPolicy
    - serviceusage.services.enable
    - iam.serviceAccounts.actAs
    - iam.serviceAccounts.list
    - iam.serviceAccounts.create
    - iam.serviceAccounts.getIamPolicy
    - iam.serviceAccounts.setIamPolicy
    - iam.roles.list
    - iam.roles.create
    - iam.roles.update
    - monitoring.dashboards.list
    - monitoring.dashboards.create
  2. Run the command below, replacing <your_project_ID> with the project ID where you want to deploy the Dynatrace integration.

    gcloud iam roles create dynatrace_monitor.cloud_function_deployment --project=<your_project_ID> --file=dynatrace-gcp-monitor-cloud-function-deployment-role.yaml

Be sure to add this role to your Google Cloud user. For details, see Grant or revoke a single role.

Dynatrace permissions

Create an API token and enable the following permissions:

  • API v1:
    • Read configuration
    • Write configuration
  • API v2:
    • Ingest metrics
    • Read extensions
    • Write extensions
    • Read extension monitoring configurations
    • Write extension monitoring configurations
    • Read extension environment configurations
    • Write extension environment configurations

Dynatrace URL

Determine the URL for your environment.

  • For Dynatrace SaaS: https://<your-environment-id>.live.dynatrace.com/
  • For Dynatrace Managed: https://<your-domain>/e/<your-environment-id>/

To determine <your-environment-id>, see environment ID.

Install

You can deploy the Dynatrace Google Cloud integration in Google Cloud Shell or in bash. To set up integration, follow the instructions below.

For bash deployment, be sure to restart the console and initialize Cloud SDK before you start installation.

To initialize Cloud SDK, run

gcloud init

Step 1 Download the deployment package

wget -q "https://github.com/dynatrace-oss/dynatrace-gcp-monitor/releases/tag/release-1.1.8/download/function-deployment-package.zip" -O function-deployment-package.zip; unzip function-deployment-package.zip; chmod a+x *.sh

Step 2 Configure deployment

  1. Adjust the parameters in the activation-config.yaml file from the deployment package.

    You might want to store this file somewhere for future updates, since it will be needed in case of redeployments. Also, keep in mind that its schema can change. In such case, you should use the new file and only copy over the parameter values.

  2. Choose which services you want Dynatrace to monitor.

By default, the Google Cloud integration starts monitoring a series of selected services. Uncomment any additional services you want Dynatrace to monitor in the activation-config.yaml file.

For DDU consumption information, see Monitoring consumption.

Step 3 Run the deployment script

Version upgrade of extensions is done by default. To keep the versions of existing extensions, run the script with the --without-extensions-upgrade parameter.

./setup.sh

The script may ask you for confirmations during deployment. For CI/CD purposes, you can add the -d option to make the script noninteractive.

After deploying the integration, you can see metrics from monitored services. If you want to change the monitoring scope (services & featureSets) or update the Google Cloud integration, see Change deployment settings below.

Verify installation

To check whether installation was successful

  1. In your Google Cloud console, go to Cloud Functions and make sure that dynatrace-gcp-monitor is there.
  2. Select the newly deployed Google Cloud Monitor function and go to Logs to make sure there are no error messages.

Enable alerting

To activate alerting, you need to enable metric events for alerting in Dynatrace.

To enable custom events

  1. Go to Settings.
  2. In Anomaly detection, select Metric events.
  3. Filter for GCP alerts and turn on On/Off for the alerts you want to activate.

View enabled services

To find the list of currently enabled services, go to Cloud Function in your Google Cloud console, and check the ACTIVATION_CONFIG environment variable.

Update services

Adding, removing and updating versions of existing services is done by modyfing the corresponding list of services and redeploying.

  1. Apply your changes to activation-config.yaml by commenting or uncommenting configuration blocks corresponding to specific services. Terminology within the file includes:

    • service: represents Google Cloud service name you want to monitor. Services are grouped by extensions, but you can decide what you need to monitor on a lower level (featureSets)
    • featureSet: a set of metrics for a given service. default_metrics is a default featureSet with a recommended set of metrics to be monitored. In more specific use cases, you can consider monitoring such sets as istio featureSet for gae_instance service
    • filter_conditions: a service-level filter that enables you to narrow the monitoring scope. It is based on the Google Cloud Monitoring filters.
      Example:
      filter_conditions:
      resource.labels.location = "us-central1-c" AND resource.labels.namespace_name = "dynatrace"
  2. Update monitored services by running the script below.

    Version upgrade of extensions is done by default. To keep the versions of existing extensions, run the script with the --without-extensions-upgrade parameter.

    ./setup.sh
  3. If you removed services from monitoring, find the relevant extensions in Dynatrace Hub and delete them to remove service-specific assets (such as dashboards and alerts).

Example

In the following example

  • The gae_instance service is disabled.
  • For the gce_instance service, only two feature sets are enabled: default_metrics and istio.
# Google App Engine Instance
#- service: gae_instance
# featureSets:
# - default_metrics
# vars:
# filter_conditions: ""
# Google VM Instance
- service: gce_instance
featureSets:
- default_metrics
# - agent
# - firewallinsights
- istio
# - uptime_check
vars:
filter_conditions: ""

For a complete list of the Google Cloud supported services, see Google Cloud supported services.

Change deployment settings

To add or remove services, or to update parameters, you need to redeploy the integration.

  1. Apply your changes to activation-config.yaml.

    Be sure to use the same value for the FUNCTION_NAME parameter as before.

  2. Rerun the deployment script.

Verification

To investigate potential deployment and connectivity issues

  1. Verify installation
  2. Enable self-monitoring optional
  3. Check the dynatrace_gcp_<date_time>.log log file created during the installation process.
  • This file will be created each time the installation script runs.
  • The debug information won't contain sensitive data such as the Dynatrace access key.
  • If you are contacting a Dynatrace product expert via live chat:
    • Make sure to provide the dynatrace_gcp_<date_time>.log log file described in the previous step.
    • Provide version information.
      • For issues during installation, check the version.txt file.
      • For issues during runtime, check function logs.

Uninstall

  1. Go to your installation directory and run the command below.
./uninstall.sh
  1. To remove all monitoring assets (such as dashboards and alerts) from Dynatrace, you need to remove all Google Cloud extensions.

You can find and delete relevant extensions via Dynatrace Hub.

Monitoring consumption

All cloud services consume DDUs. The amount of DDU consumption per service instance depends on the number of monitored metrics and their dimensions (each metric dimension results in the ingestion of 1 data point; 1 data point consumes 0.001 DDUs). For details, see Extending Dynatrace (Davis data units).