InTouch Hub · Blue Isle Software

New Relic

Run NRQL queries and manage alerts via the New Relic NerdGraph GraphQL API.

new-relicnrqlmonitoringalerting

New Relic

Run NRQL queries and manage alerts via the New Relic NerdGraph GraphQL API.

Operations

Operation Description
run_nrql Execute a NRQL query against an account and return results
search_entities Search monitored entities (apps, hosts, services) by name or domain type
list_alert_policies List all alert policies for an account
create_nrql_condition Create an alert policy and a NRQL static condition on it

API Key Setup

  1. Log into New Relic and go to Profile > API keys (top-right avatar menu).
  2. Create a key of type User — this is the key accepted by NerdGraph.
  3. Copy the key value; pass it as apiKey in every tool invocation.

Note: Ingest (license) keys do NOT work with NerdGraph.

Parameters

Parameter Required for Description
apiKey all New Relic User API key
operation all One of the four operations above
accountId run_nrql, list_alert_policies, create_nrql_condition Numeric NR account ID
region all us (default) or eu
nrql run_nrql NRQL query string
entityQuery search_entities Entity search query string
policyName create_nrql_condition Name for the new alert policy
conditionName create_nrql_condition Name for the new NRQL alert condition
conditionNrql create_nrql_condition NRQL query the condition evaluates
threshold create_nrql_condition Numeric threshold value (default: 10)
thresholdDuration create_nrql_condition Duration in seconds (multiple of 60, default: 300)

Examples

Run a NRQL query

- name: count-transactions
  type: tool
  toolName: new-relic
  input:
    apiKey: "{{credential.nrApiKey}}"
    operation: run_nrql
    accountId: "1234567"
    nrql: "SELECT count(*) FROM Transaction SINCE 1 HOUR AGO"

Search for APM application entities

- name: find-app
  type: tool
  toolName: new-relic
  input:
    apiKey: "{{credential.nrApiKey}}"
    operation: search_entities
    entityQuery: "name LIKE 'checkout' AND domainType IN ('APM-APPLICATION')"

List alert policies

- name: list-policies
  type: tool
  toolName: new-relic
  input:
    apiKey: "{{credential.nrApiKey}}"
    operation: list_alert_policies
    accountId: "1234567"

Create an alert policy and NRQL condition

- name: create-error-alert
  type: tool
  toolName: new-relic
  input:
    apiKey: "{{credential.nrApiKey}}"
    operation: create_nrql_condition
    accountId: "1234567"
    policyName: "High Error Rate Policy"
    conditionName: "Transaction errors exceed threshold"
    conditionNrql: "SELECT count(*) FROM TransactionError SINCE 5 MINUTES AGO"
    threshold: "50"
    thresholdDuration: "300"

Output

All operations publish: