newrelic/nri-flex

Problem with YAML validation on manual nri-flex executions

Closed this issue · 0 comments

Description

When passing YAML configurations to Flex, manual executions of the Flex binary fail during testing if the name element of the Integrations SDK portion of the config is not preceded with a hyphen. Automatic execution of Flex via the infrastructure agent still sends data to NRDB as expected.

This experience restricts the user's ability to manually test Flex config files that are generated via automation, namely Ansible scripts in this scenario.

Expected Behavior

Manual execution of the Flex binary during testing should replicate the same execution used by the infrastructure agent.

ref:

./nri-flex --verbose --pretty --config_path /etc/newrelic-infra/integrations.d/sampleConfig.yml

Troubleshooting or NR Diag results

manual execution currently results in the following error printed in terminal:

"config: flexConfig requires name"

Steps to Reproduce

Sample Config:

# Ansible managed
integrations:
- config:
    apis:
    - commands:
      - custom_attributes:
          host: "localhost"
          port: 80
        run: timeout 5 bash -c 'nc -zv localhost 80 > /tmp/.nri_flex_tcp_localhost_80 2>&1 && echo -e "status::open\nmessage::$(cat /tmp/.nri_flex_tcp_localhost_80)" || echo -e "status::open\nmessage::$(cat /tmp/.nri_flex_tcp_localhost_80)"' || echo -e 'status::closed\nmessage::Connection timed out'
        split_by: '::'
      name: TCPPortCheck
    name: TCPPortCheck
  name: nri-flex

Additional context

reference code: HERE identified by @Kav91 during troubleshooting.

if strings.Contains(ymlStr, "- name: nri-flex") { should be updated to remove the requirement of a hyphen.