Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Takeaways from creating a SDK On host integration


#1

While the Infrastructure product has a wide range of capabilities and valuable information, one of the more interesting features of the product is the On-host Integration SDK.

The SDK lets you write your own integration, which can send a metric, event or inventory value through the Infrastructure Agent up to Insights.

The Documentation site has a couple of example and also outlines the way the files are to be formed. Here is where that is located: https://docs.newrelic.com/docs/integrations/integrations-sdk/getting-started/introduction-infrastructure-integrations-sdk

The executable can be written in any language as long as the following is true:

  • Can be executed via the Infra agent process
  • Returns json in standard out.

The Json does have to include the following values to be valid:

{
"name":"com.Paul.NTP",
    "protocol_version":"1",
    "integration_version":"1.0.0",
    "metrics": [
        {
            "event_type":"SomethingSample",
            "provider":"com.Something"
            "provider.executableName": "Metric variable or actual value"
         }
      ]
}

With regards to the Definition and Configuration file, there are a couple of items to be aware of. I’ve created this screenshot to outline this.

A couple of items need to match in both the Config and the Definition files:

  • For the Config, Integration_name must match the name field in the definition file.
  • In definition, the name of the command under commands must match the command field in the config file.

The definition file also needs to build the executable. This is where you call the command (-python in this case) and then build in any paths or arguments.

To verify a SDK is running properly, it is important to check the logs of the Infrastructure Agent in verbose mode. The Infra Agent will log any problems it has executing the file, reading the config and definition files and determining if the JSON is valid. Here is how to generate verbose logs:

To Collect Verbose Debug logs for Infrastructure on Linux:

  1. Create a directory outside of the system logs to send the verbose logs:
sudo mkdir /var/log/newrelic
  1. In the newrelic-infra.yml file add the lines:
verbose: 1
log_file: /var/log/newrelic/newrelic-infra.log
  1. Restart the Infrastructure agent.
  2. Let it run for about 5 minutes.
  3. In the newrelic-infra.yml file set verbose= 0 to disable verbose logging mode. I would recommend leaving the new logging location.
  4. Restart the Infrastructure agent again.

To Collect Verbose Debug logs for Infrastructure on Windows:

  1. In the newrelic-infra.yml file add the lines:
  • verbose: 1
  • log_file: C:\Program Files\New Relic\ newrelic-infra\ newrelic-infra.log
  1. Restart the Infrastructure agent.
  2. Let it run for about 5 minutes.
  3. In the newrelic-infra.yml file remove the lines you just added, in order to return it to normal:
  • verbose: 0
  • log_file: C:\Program Files\New Relic\ newrelic-infra\ newrelic-infra.log
  1. Restart the Infrastructure agent again.

Some common error messages are:

  • level=debug msg="unknown instance command: for plugin <name of executable " . – This means that there is a mismatch between the command name on the config and definition files
  • level=debug msg="Getting the Sampling Path for plugin" data prefix=integration/com.xxxx="Plugin not registered: integration/com.xxxxt" plugin name=xxx pluginID=integration/xxx – This means there is a mismatch on the name/integration_name fields in the config and definition files.

Once everything is working properly, the data will be sent to Insights under the JSON “event type”. The data can then be displayed in dashboards, queried, and used in Alerts.