• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

Monitor services running on Amazon ECS

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:

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:

  1. Enable Amazon EC2 to install our infrastructure agent on your ECS clusters.
  2. 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):

  1. Open the Amazon EC2 console.

  2. On the navigation pane, under Auto scaling, choose Launch configurations.

  3. On the next page, select the launch configuration you want to update.

  4. Right click and select Copy launch configuration.

  5. On the Launch configuration details tab, click Edit details.

  6. Replace user data with one of the following snippets:

  7. Choose Skip to review.

  8. Choose Create launch configuration.

Next, update the auto scaling group:

  1. Open the Amazon EC2 console.
  2. On the navigation pane, under Auto scaling, choose Auto scaling groups.
  3. Select the auto scaling group you want to update.
  4. From the Actions menu, choose Edit.
  5. In the drop-down menu for Launch configuration, select the new launch configuration created.
  6. 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:

  1. 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.
  2. Check to see that data from the service is being reported to New Relic.
  3. 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.
  4. In the runcmd section, add the yum command to install the integration to the appropriate launch configuration.

Here's a detailed example of doing the above procedure for NGINX:

  1. 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.

  2. Via the command line, change the directory to the integrations configuration folder:

    bash
    $
    cd /etc/newrelic-infra/integrations.d
  3. Create a file called nginx-config.yml and add the following snippet:

    ---
    discovery:
    docker:
    match:
    image: /nginx/
    integrations:
    - name: nri-nginx
    env:
    STATUS_URL: http://${discovery.ip}:${discovery.port}/status
    REMOTE_MONITORING: true
    METRICS: 1

    This 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 the discovery.ip snippet works, see auto-discovery. For details on general NGINX configuration, see the NGINX integration.

  4. 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).

  5. If the configuration works, place it in the EC2 launch configuration:

    1. Open the Amazon EC2 console.

    2. On the navigation pane, under Auto scaling, choose Launch configurations.

    3. On the next page, select the launch configuration you want to update.

    4. Right click and select Copy launch configuration.

    5. On the Launch configuration details tab, click Edit details.

    6. In the User data section, edit the write_files section (in the part marked text/cloud-config).

    7. Add a new file/content entry:

      - content: |
      ---
      discovery:
      docker:
      match:
      image: /nginx/
      integrations:
      - name: nri-nginx
      env:
      STATUS_URL: http://${discovery.ip}:${discovery.port}/status
      REMOTE_MONITORING: true
      METRICS: 1
      path: /etc/newrelic-infra/integrations.d/nginx-config.yml
    8. Also edit the runcmd section to include the yum command to install nri-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 ]
  6. Choose Skip to review.

  7. Choose Create launch configuration.

  8. Next, update the auto scaling group:

    1. Open the Amazon EC2 console.
    2. On the navigation pane, under Auto scaling, choose Auto scaling groups.
    3. Select the auto scaling group you want to update.
    4. From the Actions menu, choose Edit.
    5. In the drop down menu for Launch configuration, select the new launch configuration created.
    6. Click Save.

When an EC2 instance is terminated, it's replaced with a new one that automatically looks for new NGINX containers.

¿Te ha ayudado este documento con la instalación?

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.