Infrastructure Integrations SDK

Report custom data from your hosts and services.

New Relic Infrastructure includes numerous integrations for popular services, including AWS services, Azure services, Apache, Redis, and Kubernetes. But if you want to instrument a technology that’s not currently in our integration library, Infrastructure includes an Integrations SDK for building your own on-host infrastructure reporting.

You can use the SDK to generate three types of data—metric, event, and inventory—that target a specific entity.

1. Metric data are numeric measurements or samples.

Here’s an example metric payload:

[ 
    {
         "event_type":"MyorgNginxSample",
         "net.connectionsActive": 54,  # metric data (a key/value pair)
         "net.requestsPerSecond": 21,  # metric data (a key/value pair)
         "net.reading": 23,   # metric data (a key/value pair)
    }
]

2. Event data captures significant system events.

Here’s an example event payload:

[
   {
      "summary":"More than 10 request errors logged in the last 5 minutes",
      "category": "notifications"
   }
]

3. Inventory data tracks the current state of your environment.

Here’s an example inventory payload:

{
    "events/worker_connections": {
        "value": 1024
    },
    "http/gzip" : {
        "value": "on"
    }
}

Each type of data can be inserted through simple methods exposed in the Infrastructure SDK.

Here's a sample method: 

func main() {
  // Create Integration
  i, err := integration.New(integrationName, integrationVersion, integration.Args(&args))
  if err != nil {
    log.Error(err.Error())
    os.Exit(1)
  }
  entity := i.LocalEntity()
  // Add an event
  if args.All() || args.Events {
    err = entity.AddEvent(event.New("restart", "status"))
    if err != nil {
      log.Error(err.Error())
    }
 }
 // Add Inventory item
 if args.All() || args.Inventory {
   err = entity.SetInventoryItem("customInventory", "version", "3.0.1")
   if err != nil {
     log.Error(err.Error())
   }
 }
 // Add Metric
 if args.All() || args.Metrics {
   m := entity.NewMetricSet("CustomSample")
   err = m.SetMetric("myMetric", 1337, metric.GAUGE)
   if err != nil {
     log.Error(err.Error())
   }
 }
 if err = i.Publish(); err != nil {
   log.Error(err.Error())
 }
}

For more about the Integrations SDK, see our docs.

Learn more and start building

Group 7 Created with Sketch.

Documentation

To get started building your integration, see Introduction to the integrations SDK

Group 9 Created with Sketch.

NRU Tutorials

Check out the latest tutorial on the Infrastructure SDK: Building a Custom Integration with Infrastructure.

Group 8 Created with Sketch.

Community Forum

Connect with other developers in the New Relic Explorers Hub

GitHub

For examples of integrations and other technologies, see our GitHub repo.