If you have services that run on Docker containers in Amazon ECS, and are supported, you can enable those integrations via our ECS integration. This reports data from your monitored services, from the host, and from the containers.
Requirements
To monitor services running on ECS, you must meet these requirements:
- A supported service running on ECS that meets our requirements. Supported services include:
- An auto-scaling ECS cluster running Amazon Linux, CentOS, or RHEL that meets the infrastructure agent compatibility and requirements.
- ECS tasks must have network mode set to
none
orbridge
(awsvpc
andhost
not supported).
Limitations:
- For this install method, our RabbitMQ and Apache integrations do not report inventory data.
- AWS Fargate is not supported.
How to enable
Before explaining how to enable monitoring of services running in ECS, here's an overview of the process:
- Enable Amazon EC2 to install our infrastructure agent on your ECS clusters.
- Enable monitoring of services using a service-specific configuration file.
Step 1: Enable EC2 to install the infrastructure agent
First, you must enable Amazon EC2 to install our infrastructure agent on ECS clusters. To do this, you'll first need to update your user data to install the infrastructure agent on launch.
Here are instructions for changing EC2 launch configuration (taken from Amazon EC2 documentation):
Open the Amazon EC2 console.
On the navigation pane, under Auto scaling, choose Launch configurations.
On the next page, select the launch configuration you want to update.
Right click and select Copy launch configuration.
On the Launch configuration details tab, click Edit details.
Replace user data with one of the following snippets:
Choose Skip to review.
Choose Create launch configuration.
Next, update the auto scaling group:
- Open the Amazon EC2 console.
- On the navigation pane, under Auto scaling, choose Auto scaling groups.
- Select the auto scaling group you want to update.
- From the Actions menu, choose Edit.
- In the drop-down menu for Launch configuration, select the new launch configuration created.
- Click Save.
To test if the agent is automatically detecting instances, terminate an EC2 instance in the auto scaling group: the replacement instance will now be launched with the new user data. After five minutes, you should see data from the new host on the Hosts page.
Next, move on to enabling the monitoring of services.
Step 2: Enable monitoring of services
Once you've enabled EC2 to run the infrastructure agent, the agent starts monitoring the containers running on that host.
Next, we'll explain how to monitor services deployed on ECS. For example, you can monitor an ECS task containing an NGINX instance that sits in front of your application server.
Here's a brief overview of how you'd monitor a supported service deployed on ECS:
- Create a YAML configuration file for the service you want to monitor. This will eventually be placed in the EC2 user data section via the AWS console. But before doing that, you can test that the config is working by placing that file in the infrastructure agent folder (
etc/newrelic-infra/integrations.d
) in EC2. That config file must use our container auto-discovery format, which allows it to automatically find containers. The exact config options will depend on the specific integration. - Check to see that data from the service is being reported to New Relic.
- If you are satisfied with the data you see, you can then use the EC2 console to add that configuration to the appropriate launch configuration, in the
write_files
section, and then update the auto scaling group. - In the
runcmd
section, add theyum
command to install the integration to the appropriate launch configuration.
Here's a detailed example of doing the above procedure for NGINX:
Ensure you have SSH access to the server or access to AWS Systems Manager Session Manager. Log in to the host running the infrastructure agent.
Via the command line, change the directory to the integrations configuration folder:
bash$cd /etc/newrelic-infra/integrations.dCreate a file called
nginx-config.yml
and add the following snippet:---discovery:docker:match:image: /nginx/integrations:- name: nri-nginxenv:STATUS_URL: http://${discovery.ip}:${discovery.port}/statusREMOTE_MONITORING: trueMETRICS: 1This configuration causes the infrastructure agent to look for containers in ECS that contain
nginx
. Once a container matches, it then connects to the NGINX status page. For details on how thediscovery.ip
snippet works, see auto-discovery. For details on general NGINX configuration, see the NGINX integration.If your NGINX status page is set to serve requests from the
STATUS_URL
on port 80, the infrastructure agent starts monitoring it. After five minutes, verify that NGINX data is appearing in our infrastructure UI (either: one.newrelic.com > All capabilities > Infrastructure > Third party services, or one.newrelic.com > All capabilities > Infrastructure > Third-party services).If the configuration works, place it in the EC2 launch configuration:
Open the Amazon EC2 console.
On the navigation pane, under Auto scaling, choose Launch configurations.
On the next page, select the launch configuration you want to update.
Right click and select Copy launch configuration.
On the Launch configuration details tab, click Edit details.
In the User data section, edit the
write_files
section (in the part markedtext/cloud-config
).Add a new file/content entry:
- content: |---discovery:docker:match:image: /nginx/integrations:- name: nri-nginxenv:STATUS_URL: http://${discovery.ip}:${discovery.port}/statusREMOTE_MONITORING: trueMETRICS: 1path: /etc/newrelic-infra/integrations.d/nginx-config.ymlAlso edit the
runcmd
section to include theyum
command to installnri-nginx
:runcmd:- [ yum, install, newrelic-infra, -y ]- [ yum, install, nri-nginx, -y ]- [ systemctl, daemon-reload ]- [ systemctl, enable, newrelic-infra.service ]- [ systemctl, start, --no-block, newrelic-infra.service ]
Choose Skip to review.
Choose Create launch configuration.
Next, update the auto scaling group:
- Open the Amazon EC2 console.
- On the navigation pane, under Auto scaling, choose Auto scaling groups.
- Select the auto scaling group you want to update.
- From the Actions menu, choose Edit.
- In the drop down menu for Launch configuration, select the new launch configuration created.
- Click Save.
When an EC2 instance is terminated, it's replaced with a new one that automatically looks for new NGINX containers.