The Flex integration tool: Build your own integration

The New Relic Flex integration is an application-agnostic, all-in-one tool that allows you to collect metric data from a wide variety of services. You can instrument any app that exposes metrics over a standard protocol (HTTP, file, shell) in a standard format (for example, JSON or plain text): you create a YAML config file, start the Infrastructure agent, and your data is reported to New Relic.

What is the Flex integration?

New Relic provides integrations for many popular services and frameworks. If you need to report data from a service we don't have an integration for, or if you want to supplement the data we report, you can use the Flex integration, which comes bundled with the New Relic Infrastructure agent.

Flex can send event and metric data to New Relic from a wide range of sources. Using a simple YAML config file, you can run HTTP/HTTPS requests, run shell commands, and parse file content. You can also use standard regex expressions to customize and control the data gathered from those inputs. See an example config.

After collecting and cleaning up the data, you can then query Flex data in New Relic, create custom charts for it, and use that data in your dashboards.


The Flex integration comes bundled with our Infrastructure agent. To use the Flex integration, you'll need:

How does the Flex integration work?

The Flex integration uses the Infrastructure agent to execute commands that generate the data you want to report. Here's a brief overview of how the Flex integration works to report data:

  1. You define the data you want to report in a YAML configuration file, located in the Infrastructure agent package. See an example configuration:
    Example config

    The following is an example of a Flex integration configuration for monitoring the uptime of a Linux server. This configuration is placed in a file named flex-uptime.yml. This would be placed in the Infrastructure agent's integration configuration section, located at /etc/newrelic-infra/integrations.d/flex-uptime.yml.

      - name: nri-flex    
          name: linuxUptimeIntegration
            - name: Uptime
                - run: 'cat /proc/uptime'
                  split: horizontal
                  split_by: \s+
                  set_header: [uptimeSeconds,idletimeSeconds]

    Some notes on what this configuration does:

    • run defines the command to execute.
    • The name indicated by name: Uptime is appended with Sample to generate an event called UptimeSample.
    • The split_by: \s+ splits the fields based on the space character.
    • The command generates attributes attached to the UptimeSample event. The attributes are named uptimeSeconds and idletimeSeconds.
  2. The Infrastructure agent runs the Flex integration at a frequency based on its own configuration (default: every 30 seconds) and sends the data to New Relic.
  3. You can then query your data, create custom charts with it, and add it to dashboards.

Learn more

The Flex integration comes bundled with the Infrastructure agent. Learn more about requirements.

To learn more, see our complete documentation on GitHub:

For more help

Recommendations for learning more: