How to hit the New Relic API

New Relic's main API is NerdGraph, GraphQL at https://api.newrelic.com/graphql (api.eu.newrelic.com for EU accounts). NRQL queries run inside it.

Authentication

Create a User key under API keys and send it as the API-Key header. In the examples it's written {{NEW_RELIC_API_KEY}}.

Full reference: https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph/

Current user

curl -X POST https://api.newrelic.com/graphql \
  -H "API-Key: {{NEW_RELIC_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ actor { user { name email } } }"}'
Run in PostTaco

Run an NRQL query

curl -X POST https://api.newrelic.com/graphql \
  -H "API-Key: {{NEW_RELIC_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ actor { account(id: {{ACCOUNT_ID}}) { nrql(query: \"SELECT count(*) FROM Transaction SINCE 1 hour ago\") { results } } } }"}'
Run in PostTaco