Set up the Dynatrace GCP function in a Kubernetes container (GKE)

To ingest metrics and/or logs from Google Cloud Platform, you need to deploy a container on GKE (it also works on Google Autopilot). After it's deployed, you get metrics for services defined in the configmap, preset dashboards, and predefined alerts.

Note: For complete observability of your workloads, be sure to set up generic log ingestion before installation. This requires additional configuration and a second container to forward the logs.

Review the requirements for this integration, and then complete the following steps to finish your setup.

Install

1. Download the helm deployment package in Google Cloud Shell

wget -q https://github.com/dynatrace-oss/dynatrace-gcp-function/releases/latest/download/helm-deployment-package.tar; tar -xvf helm-deployment-package.tar; chmod +x helm-deployment-package/deploy-helm.sh

2. 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>
  • For ActiveGate (if you choose to use an existing ActiveGate to ingest logs): https://<your-active-gate-IP-or-hostname>:9999/e/<your-environment-id>

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

3. Configure parameter values

The values.yaml file located in helm-deployment-package/dynatrace-gcp-function allows you to set the required and optional parameter values. See the complete list of parameters available for this integration.

4. Connect your Kubernetes cluster

  • If you want to have a new GKE Autopilot cluster created by the deployment script, add --create-autopilot-cluster to the script. No connection is needed in this case, because the deployment script will connect to the new cluster automatically.
  • If you run the deployment on an existing GKE standard cluster or an existing GKE Autopilot cluster, you can connect to your cluster from the GCP console or via terminal. Follow the instructions below.
  1. In your GCP console, go to your Kubernetes Engine.
  2. Select Clusters, and then select Connect.
  3. Select Run in Cloud Shell.

5. Run the script

  • If you run the deployment on an existing GKE standard cluster or an existing GKE Autopilot cluster, the script will create an IAM service account with the necessary roles and deploy dynatrace-gcp-function to your Kubernetes cluster.
  • If you run the deployment with the --create-autopilot-cluster option, the script will automatically create the new GKE Autopilot cluster and deploy dynatrace-gcp-function to it.

To run the script, follow the instructions below.

You have two options:

  • Run the script without parameters if you want to use the default values provided (dynatrace-gcp-function-sa for the IAM service account name and dynatrace_function for the IAM role name prefix):
cd helm-deployment-package
./deploy-helm.sh
  • Run the script with parameters if you want to set your own values (be sure to replace the placeholders with your desired values):
cd helm-deployment-package
./deploy-helm.sh [--service-account <service-account-to-be-created/updated>] [--role-name <role-to-be-created/updated>]

Verify installation

To check whether installation was successful

  1. Check if the container is running.

    Note: After the installation, it may take couple of minutes until the container is up and running.

    kubectl -n dynatrace get pods
    
  2. Check the container logs for errors or exceptions. You have two options:

  • For deployments of type 'metrics', run:

    kubectl -n dynatrace logs -l app=dynatrace-gcp-function -c dynatrace-gcp-function-metrics
    
  • For deployments of type 'logs', run:

    kubectl -n dynatrace logs -l app=dynatrace-gcp-function -c dynatrace-gcp-function-logs
    
  • For deployments of type 'all', run:

    kubectl -n dynatrace logs -l app=dynatrace-gcp-function -c dynatrace-gcp-function-metrics
    kubectl -n dynatrace logs -l app=dynatrace-gcp-function -c dynatrace-gcp-function-logs
    
  1. Check if dashboards are imported (for deployments of type 'metrics' or 'all').

    In the Dynatrace menu, go to Dashboards and filter by Tag for Google Cloud. A number of dashboards for Google Cloud Services should be available.

View metrics and/or logs

After deploying the integration, depending on your deployment type, you can:

  • See metrics from monitored services: in the Dynatrace menu, go to Metrics.
  • View and analyze GCP logs: in the Dynatrace menu, go to Logs and, to look for GCP logs, filter by cloud.provider: gcp.

log-gcp

Troubleshoot

To investigate potential deployment and connectivity issues, see Troubleshoot Google Cloud Platform monitoring setup.

Update deployment

To change the deployment type, see Update deployment type.

You can update your configuration (for example, add services to Dynatrace monitoring) by editing values.yaml. After editing the file and saving your changes, you need to upgrade your helm release.

Upgrade helm

To upgrade your helm release

  1. Find out what release version you're using.

    helm ls -n dynatrace
    
  2. Run the command below, making sure to replace <your-helm-release> with your helm release version.

    helm upgrade <your-helm-release> dynatrace-gcp-function -n dynatrace
    

For details, see Helm upgrade.

Update deployment type

To change the deployment type

  1. Find out what release version you're using.

    helm ls -n dynatrace
    
  2. Uninstall the release.

    Note: Be sure to replace <release-name> with the release name from the previous output.

    helm uninstall <release-name> -n dynatrace
    
  3. Edit deploymentType in values.yaml with the new value.

  4. Save your configuration.

  5. Run the deployment command again. For details, see Run the script.