You can install New Relic application monitoring (APM) agents on your Amazon ECS environment. When you instrument your environment with Docker, you can collect and send APM data and metrics to the New Relic platform.
Install the agent into your Docker container
To add the agent into your Docker container, follow the installation steps specific to the language agent you are using:
Set up the agent in your ECS task definition
In order to get the agent running in your ECS environment, you need to modify your task defintion file. This file lets you specify parameters you want your app to run with. For agent set-up, you need to define the following environment variables:
Set up the infra agent as a sidecar
You can set up the infrastructure agent as a sidecar container to your APM agents, giving you more visibility into your environment. When you set up a sidecar to your APM agent, you establish relationship between application and infrastructure monitoring so the data is correlated. This surfaces data to various New Relic mapping features, like service maps.
This service map includes data surfaced from an APM agent with an infra agent sidecar in a Fargate environment.
Example Task Definition File
To set up the language agent and infrastructure agent sidecar, update your full task definition file. For example:
{ "family": "nrExampleFargateDef", "containerDefinitions": [ { "name": "fargate-test", "image": "nrExample/fargate-test:latest", "cpu": 256, "memoryReservation": 1024, "portMappings": [ { "name": "fargate-test-80-tcp", "containerPort": 80, "hostPort": 80, "protocol": "tcp", "appProtocol": "http" } ], "essential": true, "environment": [ { "name": "NEW_RELIC_HOST", "value": "collector.newrelic.com" }, { "name": "NEW_RELIC_APP_NAME", "value": "Fargate Demo (AWS)" }, { "name": "NEW_RELIC_LICENSE_KEY", "value": "your-license-key" } ], "mountPoints": [], "volumesFrom": [], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/nrExampleFargateDef", "awslogs-create-group": "true", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs" } }, "systemControls": [] }, { "name": "newrelic-infra", "image": "newrelic/nri-ecs:1.11.10", "cpu": 256, "memoryReservation": 512, "portMappings": [], "essential": true, "environment": [ { "name": "NRIA_IS_FORWARD_ONLY", "value": "true" }, { "name": "NRIA_LICENSE_KEY", "value": "your-license-key" }, { "name": "NRIA_VERBOSE", "value": "1" }, { "name": "NRIA_PASSTHROUGH_ENVIRONMENT", "value": "ECS_CONTAINER_METADATA_URI,ECS_CONTAINER_METADATA_URI_V4,FARGATE" }, { "name": "FARGATE", "value": "true" }, { "name": "NRIA_CUSTOM_ATTRIBUTES", "value": "{\"nrDeployMethod\":\"downloadPage\"}" } ], "mountPoints": [], "volumesFrom": [], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/newrelic-infra/ecs", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "verbose" } }, "systemControls": [] } ], "taskRoleArn": "arn:aws:iam::111111111111:role/ecsTaskExecutionRole", "executionRoleArn": "arn:aws:iam::111111111111:role/ecsTaskExecutionRole", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "1024", "memory": "3072", "runtimePlatform": { "cpuArchitecture": "X86_64", "operatingSystemFamily": "LINUX" }}
Once you've modified your task file, trigger some data in your environment, wait a few minutes, then look for your data in the UI.
What's next?
After you've setup your agents:
- We recommend installing our ECS cloud integration, which surfaces other ECS data, like data about clusters and services.
- Review our doc on alert conditions.
- If you want to make additional configurations to your APM agents, check out their configuration docs: