This document explains how to add New Relic to your GAE flex app by configuring a custom runtime, and gives an example of deploying a Tomcat app with Docker.

The New Relic Java 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.

GAE flex example with Tomcat

This example describes how to add New Relic to your GAE flex app by installing the New Relic Java agent, building a custom runtime, and deploying an application WAR to Tomcat. Be sure to install the Java agent as necessary for your specific app server.

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

env: flex
runtime: custom

4. Configure the Dockerfile

The Dockerfile defines the Docker image to be built and is required for a GAE flexible environment app. In the following Dockerfile example code, the newrelic.yml and catalina.sh files have been configured locally, to replace those already copied to the Docker image. (You can add your New Relic license key directly to your Dockerfile, or use an environment variable in your docker run command.)

To build a Docker image that runs Tomcat with the New Relic Java agent monitoring your deployed application WAR, 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 -f Dockerfile -t newrelic-tomcat .

After running this command, verify that you have a Docker image named newrelic-tomcat.

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 New Relic APM.