Install the Go agent in GAE flexible environment

With our Go agent, you can monitor applications that reside in the Google App Engine (GAE) flexible environment. Adding New Relic to your GAE flex app gives you insight into the health and performance of your app and extends GAE with metrics you can view in APM and browser monitoring.

Here we explain how to add New Relic to your GAE flex app by configuring a custom runtime, and give an example of deploying a Go app with Docker.

The Go agent can run in a GAE flexible environment using a custom runtime. Due to limitations of other environments, do not use the GAE standard environment or Google App Engine's "native mode" installation.

Build a custom runtime using Docker

See Google's documentation for building custom runtimes. This example describes how to add New Relic to your GAE flex app by installing the Go agent, building a custom Go runtime for Docker, and deploying a golang application.

For more information about deploying and configuring your Go app in the GAE flexible environment, see:

1. Set up the GAE project and install dependencies
  1. Follow standard procedures to install the Go agent for your specific app server, including your license key.
  2. Follow Google App Engine procedures for Go to create a new Cloud Platform project, create an App Engine application, download and install git, and complete other prerequisites for the Google Cloud SDK.

The Google Cloud SDK provides the gcloud command line tool to manage and deploy GAE apps.

2. Configure your app.yaml

The app.yaml configuration file is required for a GAE flexible environment app with a custom runtime. At a minimum, make sure it contains:

runtime: custom
env: flex
3. Configure a Dockerfile

The Dockerfile defines the Docker image to be built and is required for a GAE flexible environment app. The following Dockerfile example code defines the golang version used.

FROM golang:1.8-onbuild
CMD go run main.go
4. Build a Docker image

To build the Docker image, run the following command. Be sure to include the period at the end of the code, to indicate the current directory contains the build files.

docker build --rm -t Docker-image-name .
5. Deploy Docker image to initialized GAE flexible environment
  1. To deploy your Docker image to your initialized GAE flexible environment, run the following command:

    gcloud --project go-app-name app deploy
  2. Wait until the deployment completes.
  3. To view your GAE flex app data in New Relic, go to the APM Summary page.

Recommendation: Disable health checks

Google App Engine sends periodic health check requests to confirm that an instance has been successfully deployed, and to check that a running instance maintains a healthy status. A health check is an HTTP request to the URL /_ah/health.

If you create a custom runtime, your app must be able to handle a large number of health check requests. Otherwise, your app data may not display correctly in APM.

Recommendation: Configure your app.yaml to disable health checks by adding:

health_check:
  enable_health_check: False

Get agent troubleshooting logs from GAE

Use these resources to troubleshoot your GAE flex environment app:

For more help

If you need more help, check out these support and learning resources: