nri-flex icon indicating copy to clipboard operation
nri-flex copied to clipboard

Getting Parse errors in case if docker discovery doesn't finds any suitable containers

Open tkant opened this issue 1 year ago • 0 comments

Un-necessary data is getting published to New Relic

Description

Getting Parse errors in case if docker discovery doesn't finds any suitable containers

As per this doc: https://docs.newrelic.com/docs/infrastructure/host-integrations/installation/container-auto-discovery-host-integrations/ 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. But we are seeing error like following on EC2s which doesn't matches even a single container with the image regex we are using:

time="2022-08-24T12:59:51Z" level=debug msg="Integration stderr (not parsed)." component=integrations.runner.Runner integration_name=nri-flex line="time=\"2022-08-24T12:59:51Z\" level=debug msg=\"http: error\" err=\"parse \\\"http://${discovery.ip}:${discovery.port}/api/7/http/requests\\\": invalid port \\\":${discovery.port}\\\" after host\"" runner_uid=d933e8cf21

Following is the snippet of configuration we are using:

---
discovery:
  docker:
    match:
      image: /cbr/
      label.metrics_scrapable: yes
integrations:
  # Following deals with /api Nginx+ endpoints
  - name: nri-flex
    config:
      name: nginxFlex
      global:
        base_url: http://${discovery.ip}:${discovery.port}/api/7

Wondering how can we say no to parse anything if there's zero matches found by discovery?

Expected Behavior

If discovery doesn't find any containers, the integration won't be executed and should ignore the ${discovery.*} placeholders

Failure Logs which are transmitted as events to New Relic

time="2022-08-24T12:59:51Z" level=debug msg="Integration stderr (not parsed)." component=integrations.runner.Runner integration_name=nri-flex line="time=\"2022-08-24T12:59:51Z\" level=debug msg=\"http: error\" err=\"parse \\\"http://${discovery.ip}:${discovery.port}/api/7/http/requests\\\": invalid port \\\":${discovery.port}\\\" after host\"" runner_uid=d933e8cf21

Steps to Reproduce

Use docker discovery in conjunction with placeholder usage, ex: ${discovery.ip}

Example:

---
discovery:
  docker:
    match:
      image: /cbr/
      label.metrics_scrapable: yes
integrations:
  # Following deals with /api Nginx+ endpoints
  - name: nri-flex
    config:
      name: nginxFlex
      global:
        base_url: http://${discovery.ip}:${discovery.port}/api/7

Your Environment

We are using nr-flex for collecting NGINX metrics, where flex is running on EC2 machines having docker containers running on top.

tkant avatar Aug 29 '22 12:08 tkant