Google Cloud Run
Overview
Google Cloud Run is a fully managed serverless platform for deploying and scaling container-based applications. Datadog provides monitoring and log collection for Cloud Run through the GCP integration. Datadog also provides a solution, now in public beta, for instrumenting your Cloud Run applications with a purpose-built Agent to enable tracing, custom metrics, and direct log collection.
This feature is in public beta. You can provide feedback through a
feedback form, or through your standard support channels. During the beta period, Cloud Run monitoring and APM tracing are available without a direct cost. Existing APM customers may incur increased span ingestion and volume costs.
Tracing and custom metrics
Build your container
If you are using a Dockerfile to build your application, complete the following:
Instrument your application with a supported Datadog tracing library
Use the COPY
instruction to copy the Datadog serverless-init
binary into your Docker image.
Use the ENTRYPOINT
instruction to run the serverless-init
binary as your Docker container is initiated.
Use the CMD
instruction to run your existing application and other required commands as arguments.
The following are examples of how to complete these three steps. You may need to adjust these examples depending on your existing Dockerfile setup.
Troubleshooting
This integration depends on your runtime having a full SSL implementation. If you are using a slim image for Node, you may need to add the following command to your Dockerfile to include certificates.
RUN apt-get update && apt-get install -y ca-certificates
Build with the Datadog buildpack
Use pack
to build your application by running the following:
pack build --builder=gcr.io/buildpacks/builder \
--buildpack from=builder \
--buildpack datadog/serverless-buildpack:beta4 \
gcr.io/YOUR_PROJECT/YOUR_APP_NAME
Note: Not compatible with Alpine.
Push your image to GCP:
docker push gcr.io/YOUR_PROJECT/YOUR_APP_NAME
Deploy to Cloud Run
Below are instructions for deploying a Cloud Run service using standard GCP tools. If you have other systems in place for managing container images, secrets, or deployments, you may use those instead.
Run this command to submit your build to GCP.
gcloud builds submit --tag gcr.io/YOUR_PROJECT/YOUR_APP_NAME
Create a secret from your Datadog API key.
Go to Secret Manager in your GCP console and click on Create secret.
Set a name (for example, datadog-api-key
) in the Name field. Then, paste your Datadog API key in the Secret value field.
Deploy your service.
Go to Cloud Run in your GCP console. and click on Create service.
Select Deploy one revision from an existing container image. Choose your previously built image.
Select your authentication method.
Reference your previously created secret. Go to the Container, Variables & Secrets, Connections, Security section and select the Variables & Secrets tab.
Under Secrets, click on Reference a secret and choose the secret you created from your Datadog API key. You may need to grant your user access to the secret.
Under Reference method, select Exposed as environment variable.
Under the Environment variables section, ensure that the name is set to DD_API_KEY
.
Custom metrics
You can submit custom metrics using a DogStatsd client.
Note: Only DISTRIBUTION
metrics should be used.
Advanced options and configurations
Environment variables
Log collection
You can use the GCP integration to collect logs. Alternatively, you can set the DD_LOGS_ENABLED
environment variable to true to capture application logs through the Agent.
Further reading
Additional helpful documentation, links, and articles: