RousselTMLEARNING

Article · New Relic: from discovery to expertise

Automating and controlling costs

1. NerdGraph and the CLI #

New Relic's GraphQL API.

NerdGraph #

New Relic as code

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-integration

2. 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_entity data 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 volume
-- 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 ago

Reducing #

LeverEffect
NRQL drop rulesdrop DEBUG logs, health checks, bulky attributes
Filtering at sourcepattern in logging.d, OpenTelemetry Collector processors
Trace samplingagent settings, Infinite Tracing with retention rules
Events to metricskeep long trends without every event
Process samplesonly enable useful processes
UsersBasic 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 line
  • newrelic entity search --name boutique : find an entity and its GUID
  • terraform plan && terraform apply : apply the New Relic configuration
  • SELECT 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.

📄 Automating New Relic and controlling costs →

My progress

  • ⏱ Estimated time : ≈ 8 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

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...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!