Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery: Docker & regexp not working as documented #1935

Open
das-peter opened this issue Oct 16, 2024 · 1 comment
Open

Discovery: Docker & regexp not working as documented #1935

das-peter opened this issue Oct 16, 2024 · 1 comment
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@das-peter
Copy link

das-peter commented Oct 16, 2024

Description

According to https://docs.newrelic.com/docs/infrastructure/host-integrations/installation/container-auto-discovery-host-integrations/#define-discover it should be possible to use regular expressions for the discovery:

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.

And there's also code to handle that in the agent:

if metaRegexp.MatchString(str) {

However, I couldn't get regular expressions to work with discovery.

Maybe related - I can't remember: #1753

Steps to Reproduce

The attached debug.zip provides a docker setup which can be used to reproduce the issue.

The docker-compose.yaml defines two redis services:

  redis:
    container_name: debug-newrelic-redis
    image: redis:latest
    ports:
      - "6379"

  redis2:
    container_name: debug-newrelic-redis2
    image: redis:latest
    ports:
      - "6379"

There are two infra configs for redis:

  1. Exact matching
integration_name: com.newrelic.redis
discovery:
  docker:
    match:
      image: redis:latest
  1. Regexp
integration_name: com.newrelic.redis
discovery:
  docker:
    match:
      image: /redis.*/

If I understand the regexp matching correctly both configs should find both redis services from the docker-compose.yaml.
But only the exact matching one works - the other config throws an error.

Success - Exact:

----------
Integration Name: nri-redis
Integration Output: {"name":"com.newrelic.redis","protocol_version":"3","integration_version":"1.11.8",.........}
----------
----------
Integration Name: nri-redis
Integration Output: {"name":"com.newrelic.redis","protocol_version":"3","integration_version":"1.11.8",.........}
----------
time="2024-10-16T12:46:51Z" level=info msg="Integration health check finished with success" component=integrations.runner.Runner integration_name=nri-redis role="${discovery.name}" runner_uid=ae8cd154af

Error - Regexp:

time="2024-10-16T12:46:05Z" level=error msg="can't start integration" component=integrations.runner.Runner error="value not found: discovery.ip" integration_name=nri-redis role="${discovery.name}" runner_uid=ae8cd154af

How to use provided docker env:

NEWRELIC_KEY=REDACTED docker compose up -d --build

docker exec -ti debug-newrelic-agent newrelic-infra -dry_run -integration_config_path /etc/newrelic-infra/integrations.d/redis-exact-config.yml

docker exec -ti debug-newrelic-agent newrelic-infra -dry_run -integration_config_path /etc/newrelic-infra/integrations.d/redis-regexp-config.yml

For Maintainers Only or Hero Triaging this bug

Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):

@das-peter das-peter added the bug Categorizes issue or PR as related to a bug. label Oct 16, 2024
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant