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
- Log into New Relic and go to Profile > API keys (top-right avatar menu).
- Create a key of type User — this is the key accepted by NerdGraph.
- Copy the key value; pass it as
apiKeyin 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:
result— raw JSON response body from NerdGraph (string)status— HTTP status code (string, normally "200")truncated— set to "true" if the response exceeded 5 MB and was capped
Publishes
The keys a later task may reference as {{taskName.key}}. Referencing anything not listed here resolves to nothing at run time.
errorresultstatustruncated
Input Properties
Every property this tool accepts, from its own tool.iml.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey |
string | yes | — | DEPRECATED — bind an API Key credential to the task with credentialName instead. A key pasted here is stored in the workflow definition in clear and appears in every export of it. Still honoured for workflows built before the change. |
operation |
string | yes | — | One of: run_nrql, search_entities, list_alert_policies, create_nrql_condition |
accountId |
string | no | — | New Relic account ID (numeric). Required for run_nrql, list_alert_policies, and create_nrql_condition. |
region |
string | no | us |
Data center region: 'us' (default, https://api.newrelic.com/graphql) or 'eu' (https://api.eu.newrelic.com/graphql). |
nrql |
string | no | — | NRQL query string to execute. Required for run_nrql. Example: SELECT count(*) FROM Transaction SINCE 1 HOUR AGO |
entityQuery |
string | no | — | Entity search query string for search_entities. Example: name LIKE 'my-app' AND domainType IN ('APM-APPLICATION') |
policyName |
string | no | — | Name for the new alert policy. Required for create_nrql_condition (a policy with this name is looked up or a new one created). |
conditionName |
string | no | — | Name for the new NRQL alert condition. Required for create_nrql_condition. |
conditionNrql |
string | no | — | NRQL query for the alert condition. Required for create_nrql_condition. Example: SELECT count(*) FROM TransactionError |
threshold |
string | no | 10 |
Numeric threshold value for the alert condition critical term. Required for create_nrql_condition. |
thresholdDuration |
string | no | 300 |
Duration in seconds over which the threshold must be met to trigger the alert (must be a multiple of 60, e.g. 300). Required for create_nrql_condition. |