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
New Relic best practices
Best practices to succeed with New Relic: adoption approach, account organization, naming and tag...
NRQL: querying all your New Relic data
Mastering NRQL, New Relic's query language: SELECT … FROM structure, filters, aggregation functio...
Workflows and AutomationEngine: automating notifications and remediation
Automating with Workflows (AutomationEngine) in Dynatrace: triggers, DQL, JavaScript and connecto...
Automating Grafana: HTTP API, Terraform and dashboard lifecycle
Industrializing Grafana: HTTP API (folders, dashboards, users, data sources), Terraform provider,...
New Relic: the observability platform at a glance
Discover New Relic: history, the unified platform and NRDB, MELT data types, entities and golden ...
Datadog best practices: tags, costs, alerts and governance
Checklist for using Datadog effectively: unified tagging, cost control (hosts, logs, custom metri...
New Relic APM: agents, OpenTelemetry and distributed traces
Instrumenting applications with New Relic: language agents, configuration, transactions and Apdex...
Infrastructure, logs and Kubernetes with New Relic
Monitoring servers, containers and Kubernetes with New Relic: infrastructure agent, on-host integ...
New Relic dashboards: building, sharing and analysing
Building useful dashboards in New Relic: NRQL widgets, chart choice, template variables, facet li...