Container auto-discovery

Discovery allows you to automatically configure an integration to monitor services that may run in multiple containers. Inside an integration configuration file, you can set containers' matching criteria, and New Relic's Infrastructure agent will execute the integration for each local container that matches the criteria.

An integration will be executed as many times as it finds discovery elements. If discovery doesn't find any containers, the integration won't be executed.

Currently the Infrastructure agent can discover your local Docker or Amazon Web Services (AWS) Fargate containers.

Add placeholders to config file

In your integration configuration, you need to write ${discovery.<property>} placeholders that will be automatically replaced by each container information.

The following example will configure an NGINX integration ​to monitor all the local containers with an image name containing nginx that are labeled as env=production. Each Nginx service will be available through different IPs and ports, so you need to set them as variables in the status_url property.

integration_name: com.newrelic.nginx
      image: /nginx/
      label.env: production
  - name: nginx-server-metrics
    command: metrics
      status_url: http://${discovery.ip}:${discovery.port}/status
      status_module: discover
      remote_monitoring: true
      env: ${discovery.label.env}
      role: ${discovery.label.role}

Add discovery properties

To configure discovery, set up a discovery entry in your integration configuration YAML using the following properties. A container will be matched when all the properties match the defined values.

Properties values will be matched with an exact string, unless the value to match is set between /.../. The contents within the slashes will be matched as regular expressions.

Discovery key name Description


Type: String

Time-To-Live of the cached discovery results, used to minimize the number of discovery processes. Define as a number followed by a time unit (s, m or h).

Examples: 30s, 10m, 1h, 0

Default: 1m




Type: YAML properties

Docker or Fargate containers matching definition. This consists of a match property containing a map where:

  • Each key is any of the following properties.
  • The value is the expected value of the given property for the returned containers.
  • A container matches if all the properties match (AND operation).

Available YAML keys include:

  • ip: Container external IP address, if any
  • private.ip: Container private IP address
  • port: Container external port number
  • private.port: Container private port number
  • image: Image name
  • name: Container name
  • label.<label name>: Any container label, accessible by its name

Discovery example

The following discovery section example will match all Docker containers whose image starts with httpd: (provided as a regular expression) and are labeled as scrapable=yes. We also want the results to be cached with a Time-To-Live of 5 minutes.

  ttl: 5m
      image: /^httpd:/
      label.scrapable: yes

Available container information

Discovery currently emits the following variables that can be used to configure your integrations. The Infrastructure agent will replace them with the corresponding values of the discovered containers.

Be sure to add the discovery. prefix.

Variable Description
${discovery.ip} Container public IP address, if any
${discovery.private.ip} Container private IP address
${discovery.port} Container public port number
${discovery.private.port} Container private port number
${discovery.image} Image name
${} Container name
${discovery.label.<label name>} Any container label, accessible by its name

For more help

Recommendations for learning more: