New Relic EMEA Partner Enablement
Deprecated content! Please see the new Partner Enablement site Go

Lab 6: New Relic API

APIs are essential in the connected modern world we now live in. New Relic has an extensive set of APIs to automate your business around New Relic including not only sending and updating items in New Relic, but taking the data out of New Relic and applying it in your business.

New Relic offers a variety of APIs that allow you to:

  • Retrieve data from the New Relic platform
  • Insert data into the platform
  • Adjust settings

In this lab we will use the New Relic API to create a new synthetic test in New Relic, setup a new alert, and to send a deployment marker event on the Lab 4 instance. For this lab, it is recommended to use Postman You could alternatively use cURL or the API Explorer.

Step 1: Using the API Explorer

The New Relic API Explorer provides interactive access to the API, including the example calls, responses, and possibilities. Explore further on the docs.

Step 2: Authenticating against the API

API calls will be using Postman variables displayed as such {{variableName}}. Learn more about that here. You will also need an API key, learn more about that here.

You can authenticate against the New Relic API using the header: X-Api-Key {{apiKey}}

Step 3: GET a monitor

HTTP verb GET method allows the retrieval of data. To retrieve the HTTP monitors associated with our account, execute:

Postman:
https://synthetics.newrelic.com/synthetics/api/v3/monitors
Host: synthetics.newrelic.com
X-Api-Key: {{apiKey}}

cURL:
GET /synthetics/api/v3/monitors HTTP/1.1
Header: X-Api-Key {{apiKey}}

POST a monitor

HTTP verb POST is used to submit an entity. To create a HTTP monitor, you can execute:

Postman:

cURL:

The payload sent to the New Relic API is in JSON format. You can see the various options to configure the test. Not only can we provide the basics such as a name, type, frequency and locations, we can also send validation criteria and select options such as redirect and SSL handling.

Step 4: Setting a deployment marker

You can use New Relic Deployment Markers to inform New Relic of a deployment having taken place in your environment. This can be used for before/after reporting of events, and to keep everybody informed of changes in the environment. There are different mechanisms for sending a deployment marker, and this lab will focus on using the Java agents Command Line Interface

  1. SSH into your Lab 4 instance
  2. Run the command
    echo "Change #1234 deployed" | java -jar /usr/share/tomcat8/bin/newrelic/newrelic.jar deployment DEPLOYMENT_OPTIONS --user=email@example.com
  3. Test further deployments with the different command line options to see how they appear in New Relic
  4. Observe the changes in your APM screen. Can you find the comparison report? Can you see use cases for this?

Step 5: Retrieving data from key transactions

Find the key transactions -> list option in the API Explorer here . This paginated list view can show the alerting status for key transactions against their own Apdex threshold value. You can also use the show call to retrieve the value for an individual key transaction.

Updates

New lab for Kubernetes and Prometheus 1 Nov

There is a new lab for Kubernetes and Prometheus integration - Lab 11. Be sure to check it out to learn about installing Kubernetes locally, integrating with New Relic, integrating New Relic and Prometheus, and deploying a demo application to scrape metrics from.

Updated Synthetics Labs  28 Oct

Lab 3 has been updated to include scripted API tests. It includes a topical build your own test too! (With some help added too).

Go to self assessment