1. NerdGraph and the CLI #
New Relic's GraphQL API.
NerdGraph #
NerdGraph (https://api.newrelic.com/graphql, api.eu.newrelic.com in the EU) exposes almost everything: NRQL queries, entities and tags, dashboards, alerts, service levels, drop rules, users. The built-in explorer (NerdGraph API explorer) generates queries and documents the schema.
mutation {
changeTrackingCreateDeployment(deployment: {
entityGuid: "<application GUID>"
version: "2026.11.23-1"
user: "ci"
description: "New checkout page"
}) { deploymentId }
}The newrelic CLI #
newrelic profile add --profile prod --apiKey $NEW_RELIC_API_KEY --accountId $NEW_RELIC_ACCOUNT_ID --region EU
newrelic entity search --name boutique
newrelic nrql query --query "SELECT count(*) FROM Transaction SINCE 1 hour ago"
newrelic install -n infrastructure-agent-installer,logs-integration2. Terraform #
Observability as code.
A full example #
terraform {
required_providers {
newrelic = { source = "newrelic/newrelic", version = "~> 3.102" }
}
}
provider "newrelic" {} # NEW_RELIC_API_KEY, NEW_RELIC_ACCOUNT_ID, NEW_RELIC_REGION
resource "newrelic_alert_policy" "boutique" {
name = "Boutique - production"
incident_preference = "PER_CONDITION_AND_TARGET"
}
resource "newrelic_one_dashboard" "boutique" {
name = "Boutique - overview"
permissions = "public_read_only"
page {
name = "Service"
widget_billboard {
title = "Apdex"
row = 1
column = 1
nrql_query { query = "SELECT apdex(duration, t: 0.5) FROM Transaction WHERE appName = 'boutique'" }
}
}
}- Main resources:
newrelic_alert_policy,newrelic_nrql_alert_condition,newrelic_workflow,newrelic_notification_destination,newrelic_service_level,newrelic_one_dashboard,newrelic_synthetics_*,newrelic_nrql_drop_rule. - The
newrelic_entitydata source looks up an application GUID by name. - One module per service (policy, conditions, SLO, dashboard) gives every team the same baseline.
Best practice : Create alerts and SLOs in Terraform, and keep the UI for exploration: what runs in production must be reviewed and versioned.
3. Controlling costs #
Measure, then reduce.
Measuring #
-- Ingest per data type over 30 days
SELECT sum(GigabytesIngested) FROM NrConsumption WHERE productLine = 'DataPlatform' FACET usageMetric SINCE 30 days ago
-- Estimated log volume per service
SELECT bytecountestimate() / 10e8 AS 'GB' FROM Log FACET service SINCE 1 day ago
-- Billable users
SELECT latest(userType) FROM NrUsage WHERE productLine = 'FullStackObservability' FACET userEmail SINCE 30 days agoReducing #
| Lever | Effect |
|---|---|
| NRQL drop rules | drop DEBUG logs, health checks, bulky attributes |
| Filtering at source | pattern in logging.d, OpenTelemetry Collector processors |
| Trace sampling | agent settings, Infinite Tracing with retention rules |
| Events to metrics | keep long trends without every event |
| Process samples | only enable useful processes |
| Users | Basic by default, Core or Full platform only when needed |
Watch out : A single application logging at DEBUG in production can multiply the bill: set an alert on daily consumption.
Commands to know #
Commands to know
newrelic nrql query --query "…": run NRQL from the command linenewrelic entity search --name boutique: find an entity and its GUIDterraform plan && terraform apply: apply the New Relic configurationSELECT bytecountestimate() FROM Log FACET service: log volume per service
Sources #
Checked in November 2026: New Relic evolves its platform continuously (UI, plans, limits); check the documentation before relying on a detail.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Alerts, service levels and incidents in New Relic
Setting up useful alerting in New Relic: policies and NRQL conditions, static and anomaly thresho...
Digital experience: Browser, mobile and Synthetics
Measuring what users experience with New Relic: browser agent (page load, Core Web Vitals, AJAX, ...
Automating Cribl: REST API, Packs, Git and Terraform
Managing Cribl as code: REST API (authentication, group paths, commit and deploy), reusable Packs...
Datadog costs and governance: usage, attribution, RBAC and tag policies
Control the bill and govern Datadog: tracking usage and estimates, cost attribution per team, usa...
Operating Google Cloud: observability, security, infrastructure as code and costs
Operate Google Cloud: Cloud Monitoring, Cloud Logging and Cloud Trace (Google Cloud Observability...
Conversion funnels in RUM: measuring where users drop off
Building and reading a conversion funnel with RUM data: steps, rates, order, pitfalls, and implem...
Visualizing and automating Zabbix: dashboards, Grafana and API
Build dashboards and maps in Zabbix, use Grafana's Zabbix plugin, and automate configuration with...
Monitors, SLOs, dashboards and Datadog as code
Create effective monitors (metrics, logs, APM, composites, anomalies), SLOs, dashboards, and mana...
SLOs in Dynatrace: objectives, error budget and burn rate
SLI, SLO and SLA, error budget and burn rate: defining an availability or performance SLO in Dyna...