• /
  • EnglishEspañolFrançais日本語한국어Português
  • Log inStart now

Create a baseline NRQL condition

|View as Markdown

The action identifier is newrelic.alerts.createBaselineNrqlCondition.

Creates a new baseline NRQL alert condition under an alert policy. A baseline condition dynamically predicts a signal's expected range from its historical behavior and opens a violation when the live signal deviates from that predicted baseline by more than the configured threshold.

At least one of terms or expiration (with openViolationOnExpiration: true) must be provided. Omitting both fails NerdGraph validation.

The following table describes all available input fields for this action.

Input

Type

Description

Example

accountId

Int

Required. The New Relic account in which to create the condition.

123456

policyId

String

Required. The ID of the alert policy to attach this condition to.

"2000002"

name

String

Required. The name of the condition.

"Anomalous throughput"

nrqlQuery

String

Required. The NRQL query to evaluate.

"SELECT count(*) FROM Transaction WHERE appName = 'MyApp'"

enabled

Boolean

Required. Whether the condition is active.

true

baselineDirection

String

Required. The direction of deviation that triggers a violation. One of UPPER_ONLY, LOWER_ONLY, or UPPER_AND_LOWER.

"UPPER_ONLY"

terms

List

Conditionally required. The condition's thresholds expressed as percentage deviation from the baseline. Required unless expiration is provided with openViolationOnExpiration: true. Each entry: priority (CRITICAL or WARNING), operator (ABOVE only — direction is controlled by baselineDirection), threshold (float, percent deviation), thresholdDuration (seconds), thresholdOccurrences (ALL or AT_LEAST_ONCE).

[{"priority": "CRITICAL", "operator": "ABOVE", "threshold": 20, "thresholdDuration": 300, "thresholdOccurrences": "ALL"}]

nrqlDataAccountId

Int

Optional. Account to run the NRQL query against if different from accountId.

123456

signalSeasonality

String

Optional. Seasonal pattern applied to the baseline's prediction model. One of NEW_RELIC_CALCULATION (default), HOURLY, DAILY, WEEKLY, or NONE.

"NEW_RELIC_CALCULATION"

description

String

Optional. Free-text description of the condition.

"Alerts when throughput deviates from its baseline."

runbookUrl

String

Optional. URL of a runbook to link from the condition.

"https://runbooks.example.com/anomalous-throughput"

titleTemplate

String

Optional. Handlebars-style template for the violation title.

"{{ conditionName }} on {{ entity.name }}"

violationTimeLimitSeconds

Int

Optional. Force-closes an open violation after this many seconds.

86400

signal

Map

Optional. Advanced signal and streaming settings. See createStaticNrqlCondition for field descriptions.

{"aggregationWindow": 60, "aggregationMethod": "EVENT_FLOW", "aggregationDelay": 120}

expiration

Map

Optional. Loss-of-signal settings. See createStaticNrqlCondition for field descriptions.

{"closeViolationsOnExpiration": true, "expirationDuration": 300, "openViolationOnExpiration": false}

selectors

List

Optional. JQ selectors to extract values from the response.

selectors:
- name: conditionId
expression: ".data.alertsNrqlConditionBaselineCreate.id"

The following table describes all output fields returned by this action.

Output

Type

Description

success

Boolean

true when the step executed without error.

errorMessage

String

Error message on failure, including NerdGraph errors. null on success.

data

Map

NerdGraph response. Use selectors to extract id, name, enabled, policyId, entityGuid, type, or baselineDirection from data.

{
"data": {
"alertsNrqlConditionBaselineCreate": {
"id": "7654322",
"name": "Anomalous throughput",
"enabled": true,
"policyId": "2000002",
"entityGuid": "MTE5MzMzNDd8TlIxfE5SUV9DT05EQVRJT058NzY1NDMyMg",
"type": "BASELINE",
"baselineDirection": "UPPER_ONLY"
}
}
}

The following example creates a baseline NRQL condition that alerts when throughput deviates above its expected range.

Workflow example

name: create_baseline_nrql_condition
description: Create a baseline NRQL alert condition
steps:
- name: createBaselineCondition
type: action
action: newrelic.alerts.createBaselineNrqlCondition
version: 1
inputs:
accountId: ${{ .workflowInputs.accountId }}
policyId: ${{ .workflowInputs.policyId }}
name: "Anomalous throughput"
nrqlQuery: "SELECT count(*) FROM Transaction WHERE appName = 'MyApp'"
enabled: true
baselineDirection: "UPPER_ONLY"
terms:
- priority: "WARNING"
operator: "ABOVE"
threshold: 20
thresholdDuration: 600
thresholdOccurrences: "ALL"
selectors:
- name: conditionId
expression: ".data.alertsNrqlConditionBaselineCreate.id"
next: end
Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.