New Relic
📚 Learning Resources
📖 Essential Documentation
- New Relic Documentation - Official comprehensive documentation
- APM Guide - Application performance monitoring setup
- NRQL Reference - Query language documentation
- Infrastructure Monitoring - Server and container monitoring
📝 Specialized Guides
- New Relic Alerts - Alerting and AI-powered insights
- Kubernetes Monitoring - Container and orchestration monitoring
- Distributed Tracing - End-to-end request tracking
- Synthetic Monitoring - Proactive application monitoring
🎥 Video Tutorials
- New Relic Full Stack Observability - Platform overview (30 min)
- APM Setup and Configuration - Getting started with APM (25 min)
- NRQL Query Tutorial - Advanced querying techniques (40 min)
🎓 Professional Courses
- New Relic University - Free training and certification resources
- Observability Fundamentals - Paid comprehensive course
- APM Best Practices - Paid advanced techniques
📚 Books
- "Observability Engineering" by Charity Majors - Purchase on Amazon
- "Site Reliability Engineering" by Google - Free PDF | Purchase
- "The Art of Monitoring" by James Turnbull - Purchase on Amazon
🛠️ Interactive Tools
- New Relic One - Unified observability platform
- New Relic Playground - Free trial environment
- NRQL Query Builder - Visual query interface
🚀 Ecosystem Tools
- New Relic CLI - Command-line interface for automation
- Terraform Provider - Infrastructure as code integration
- Kubernetes Operator - K8s-native deployment
- Open Telemetry - Vendor-neutral observability
🌐 Community & Support
- New Relic Community - User community and support
- New Relic Explorers Hub - Technical discussions and best practices
- New Relic Developer - APIs and integration guides
Understanding New Relic: Full Stack Observability Platform
New Relic is a comprehensive observability platform that provides real-time insights into application performance, infrastructure monitoring, and digital experience. It helps platform engineers monitor, debug, and optimize their systems across the entire stack.
How New Relic Works
New Relic collects telemetry data from applications, infrastructure, and user interactions through lightweight agents and integrations. The platform ingests metrics, events, logs, and traces, storing them in a unified data platform that enables correlation across different data types.
The system uses machine learning to automatically detect anomalies, predict issues, and provide intelligent alerts. New Relic's query language (NRQL) allows users to explore data interactively, create custom dashboards, and build sophisticated alerting rules based on complex conditions.
The New Relic Ecosystem
New Relic's ecosystem spans application monitoring (APM), infrastructure monitoring, browser monitoring, mobile monitoring, and synthetic monitoring. The platform integrates with cloud providers, container orchestrators, and popular development tools to provide comprehensive visibility.
Advanced features include distributed tracing for microservices, log management with automatic correlation, and AI-powered incident detection. The ecosystem extends through APIs, webhooks, and integrations with incident management, deployment, and collaboration tools.
Why New Relic Leads Observability
New Relic has become a leader in observability by focusing on correlation and context across different data types. Unlike point solutions that monitor individual components, New Relic provides a unified view that helps teams understand how application performance relates to infrastructure health and user experience.
The platform's strength lies in its ability to connect the dots between different signals, enabling faster problem resolution and proactive optimization. Its software-first approach means it scales naturally with cloud native architectures.
Mental Model for Success
Think of New Relic as a comprehensive monitoring dashboard for your entire digital operation, like mission control for a space program. Instead of having separate screens for different systems, everything is integrated into a single view where you can see how each component affects the others.
When something goes wrong, you don't need to check multiple tools - New Relic shows you the complete story from user impact to root cause, like having x-ray vision into your entire technology stack.
Where to Start Your Journey
- Start with APM - Install an agent for your main application to see immediate value
- Add infrastructure monitoring - Get visibility into servers and containers
- Set up basic alerts - Create notifications for key performance indicators
- Explore NRQL queries - Learn to ask questions of your data
- Build custom dashboards - Create views tailored to your team's needs
- Implement distributed tracing - Understand request flows across services
Key Concepts to Master
- Agent deployment - Installing and configuring monitoring agents
- NRQL querying - Writing queries to explore and analyze data
- Dashboard design - Creating effective visualizations for different audiences
- Alert configuration - Setting up intelligent notifications
- Distributed tracing - Understanding request flows across services
- Custom instrumentation - Adding business-specific monitoring
- Data correlation - Connecting different signals for faster troubleshooting
- Performance optimization - Using insights to improve system performance
Begin with out-of-the-box monitoring for your key applications and infrastructure, then gradually customize and extend based on your specific needs and use cases.
Key Features
- Application Performance Monitoring (APM): Deep application insights and distributed tracing
- Infrastructure Monitoring: Server, container, and cloud infrastructure visibility
- Browser Monitoring: Real user monitoring and frontend performance
- Synthetic Monitoring: Proactive monitoring with automated tests
- AI-Powered Alerts: Intelligent anomaly detection and alerting
Getting Started
Agent Installation
# Install Infrastructure Agent (Linux)
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash
sudo NEW_RELIC_API_KEY=YOUR_API_KEY NEW_RELIC_ACCOUNT_ID=YOUR_ACCOUNT_ID /usr/local/bin/newrelic install
# Docker Infrastructure Agent
docker run \
-d \
--name newrelic-infra \
--network=host \
--cap-add=SYS_PTRACE \
--privileged \
--pid=host \
-v "/:/host:ro" \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-e NRIA_LICENSE_KEY=YOUR_LICENSE_KEY \
newrelic/infrastructure:latest
Kubernetes Deployment
apiVersion: v1
kind: Namespace
metadata:
name: newrelic
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: newrelic-infra
namespace: newrelic
spec:
selector:
matchLabels:
name: newrelic-infra
template:
metadata:
labels:
name: newrelic-infra
spec:
serviceAccountName: newrelic-infra
hostNetwork: true
hostPID: true
hostIPC: true
containers:
- name: newrelic-infra
image: newrelic/infrastructure-k8s:latest
env:
- name: NRIA_LICENSE_KEY
valueFrom:
secretKeyRef:
name: newrelic-secret
key: license-key
- name: NRIA_CLUSTER_NAME
value: "my-cluster"
- name: NRIA_VERBOSE
value: "1"
resources:
limits:
memory: 300Mi
cpu: 100m
requests:
memory: 150Mi
cpu: 100m
volumeMounts:
- name: host-volume
mountPath: /host
readOnly: true
- name: dev-dir
mountPath: /dev
readOnly: true
- name: proc-dir
mountPath: /host/proc
readOnly: true
- name: sys-dir
mountPath: /host/sys
readOnly: true
volumes:
- name: host-volume
hostPath:
path: /
- name: dev-dir
hostPath:
path: /dev
- name: proc-dir
hostPath:
path: /proc
- name: sys-dir
hostPath:
path: /sys
tolerations:
- operator: Exists
effect: NoSchedule
- operator: Exists
effect: NoExecute
Application Monitoring
Python APM Integration
import newrelic.agent
# Initialize agent
newrelic.agent.initialize('/path/to/newrelic.ini')
# Decorator for function monitoring
@newrelic.agent.function_trace()
def critical_function():
# Your business logic
pass
# Custom metrics
@newrelic.agent.background_task()
def process_queue():
queue_size = get_queue_size()
newrelic.agent.record_custom_metric('Custom/Queue/Size', queue_size)
# Record custom events
newrelic.agent.record_custom_event('QueueProcessed', {
'queue_size': queue_size,
'processing_time': get_processing_time(),
'environment': 'production'
})
# Error tracking
def risky_operation():
try:
# Potentially failing operation
return perform_operation()
except Exception as e:
newrelic.agent.record_exception()
raise
# Database query monitoring
@newrelic.agent.database_trace('PostgreSQL', 'SELECT')
def get_user_data(user_id):
return db.query("SELECT * FROM users WHERE id = %s", user_id)
# External service calls
@newrelic.agent.external_trace('httpbin.org', 'POST')
def call_external_api():
return requests.post('https://httpbin.org/post', json={'data': 'value'})
Node.js APM Integration
// Must be first require
require('newrelic');
const express = require('express');
const newrelic = require('newrelic');
const app = express();
app.get('/api/users/:id', async (req, res) => {
// Custom attributes
newrelic.addCustomAttribute('user.id', req.params.id);
newrelic.addCustomAttribute('endpoint', 'get_user');
try {
const user = await getUserById(req.params.id);
// Record custom metrics
newrelic.recordMetric('Custom/Users/Retrieved', 1);
// Record custom events
newrelic.recordCustomEvent('UserAccess', {
userId: req.params.id,
timestamp: Date.now(),
success: true
});
res.json(user);
} catch (error) {
// Error tracking
newrelic.noticeError(error);
newrelic.recordCustomEvent('UserAccess', {
userId: req.params.id,
timestamp: Date.now(),
success: false,
error: error.message
});
res.status(500).json({ error: 'Internal server error' });
}
});
// Background job monitoring
newrelic.startBackgroundTransaction('processQueue', 'job', () => {
processQueueItems();
newrelic.endTransaction();
});
app.listen(3000);
Go APM Integration
package main
import (
"fmt"
"net/http"
"github.com/newrelic/go-agent/v3/newrelic"
)
func main() {
app, err := newrelic.NewApplication(
newrelic.ConfigAppName("My Go App"),
newrelic.ConfigLicense("YOUR_LICENSE_KEY"),
)
if err != nil {
fmt.Println("Error creating New Relic application:", err)
}
http.HandleFunc(newrelic.WrapHandleFunc(app, "/users", usersHandler))
http.ListenAndServe(":8080", nil)
}
func usersHandler(w http.ResponseWriter, r *http.Request) {
// Get transaction from context
txn := newrelic.FromContext(r.Context())
// Add custom attributes
txn.AddAttribute("user.role", "admin")
txn.AddAttribute("request.path", r.URL.Path)
// Custom segment for database call
segment := txn.StartSegment("database.query")
users := getUsersFromDB()
segment.End()
// Record custom metrics
txn.Application().RecordCustomMetric("Custom/Users/Count", float64(len(users)))
// Record custom events
txn.Application().RecordCustomEvent("UserRequest", map[string]interface{}{
"endpoint": "/users",
"method": r.Method,
"count": len(users),
})
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{"users": %d}`, len(users))
}
func getUsersFromDB() []User {
// Database logic
return []User{}
}
Custom Dashboards
Infrastructure Dashboard
{
"name": "Infrastructure Overview",
"description": "System metrics and health",
"pages": [
{
"name": "System Health",
"widgets": [
{
"title": "CPU Utilization",
"visualization": {
"id": "viz.line"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT average(cpuPercent) FROM SystemSample TIMESERIES",
"accountId": YOUR_ACCOUNT_ID
}
]
}
},
{
"title": "Memory Usage",
"visualization": {
"id": "viz.billboard"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT average(memoryUsedPercent) FROM SystemSample",
"accountId": YOUR_ACCOUNT_ID
}
]
}
},
{
"title": "Disk I/O",
"visualization": {
"id": "viz.area"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT average(diskReadBytesPerSecond), average(diskWriteBytesPerSecond) FROM StorageSample TIMESERIES",
"accountId": YOUR_ACCOUNT_ID
}
]
}
}
]
}
]
}
Application Performance Dashboard
{
"name": "Application Performance",
"pages": [
{
"name": "Response Times",
"widgets": [
{
"title": "Average Response Time",
"visualization": {
"id": "viz.line"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT average(duration) FROM Transaction WHERE appName = 'My App' TIMESERIES",
"accountId": YOUR_ACCOUNT_ID
}
]
}
},
{
"title": "Throughput",
"visualization": {
"id": "viz.billboard"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT rate(count(*), 1 minute) FROM Transaction WHERE appName = 'My App'",
"accountId": YOUR_ACCOUNT_ID
}
]
}
},
{
"title": "Error Rate",
"visualization": {
"id": "viz.line"
},
"rawConfiguration": {
"nrqlQueries": [
{
"query": "SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = 'My App' TIMESERIES",
"accountId": YOUR_ACCOUNT_ID
}
]
}
}
]
}
]
}
Alerts and Notifications
NRQL Alert Conditions
{
"name": "High Error Rate",
"type": "static",
"nrql": {
"query": "SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = 'My App'"
},
"condition": {
"threshold": 5.0,
"thresholdOccurrences": "at_least_once",
"thresholdDuration": 300,
"operator": "above"
},
"description": "Alert when error rate exceeds 5%"
}
Infrastructure Alert Conditions
{
"name": "High CPU Usage",
"type": "static",
"nrql": {
"query": "SELECT average(cpuPercent) FROM SystemSample WHERE hostname LIKE 'web-%'"
},
"condition": {
"threshold": 80.0,
"thresholdOccurrences": "at_least_once",
"thresholdDuration": 300,
"operator": "above"
},
"description": "Alert when CPU usage exceeds 80%"
}
Synthetic Monitoring
API Monitor
// Simple monitor script
const assert = require('assert');
$http.get('https://api.myapp.com/health', {
headers: {
'Authorization': 'Bearer ' + $secure.API_TOKEN
}
}, function(err, response, body) {
assert.equal(response.statusCode, 200, 'Expected 200 status code');
const data = JSON.parse(body);
assert.equal(data.status, 'healthy', 'Expected healthy status');
assert.ok(data.timestamp, 'Expected timestamp field');
console.log('Health check passed');
});
Browser Monitor
// Scripted browser monitor
$browser.get('https://myapp.com/login')
.then(() => {
return $browser.findElement($driver.By.id('username')).sendKeys($secure.USERNAME);
})
.then(() => {
return $browser.findElement($driver.By.id('password')).sendKeys($secure.PASSWORD);
})
.then(() => {
return $browser.findElement($driver.By.css('button[type="submit"]')).click();
})
.then(() => {
return $browser.wait($driver.until.elementLocated($driver.By.id('dashboard')), 10000);
})
.then(() => {
console.log('Login flow completed successfully');
});
NRQL Queries
Application Performance Queries
-- Average response time by endpoint
SELECT average(duration) FROM Transaction
WHERE appName = 'My App'
FACET name
SINCE 1 hour ago
-- Error rate trend
SELECT percentage(count(*), WHERE error IS true)
FROM Transaction
WHERE appName = 'My App'
TIMESERIES SINCE 24 hours ago
-- Slowest transactions
SELECT percentile(duration, 95)
FROM Transaction
WHERE appName = 'My App'
FACET name
SINCE 1 hour ago
-- Database query performance
SELECT average(databaseDuration)
FROM Transaction
WHERE appName = 'My App'
AND databaseDuration IS NOT NULL
TIMESERIES SINCE 2 hours ago
Infrastructure Queries
-- CPU usage by host
SELECT average(cpuPercent)
FROM SystemSample
FACET hostname
SINCE 30 minutes ago
-- Memory usage trend
SELECT average(memoryUsedPercent)
FROM SystemSample
TIMESERIES SINCE 4 hours ago
-- Disk space usage
SELECT latest(diskUsedPercent)
FROM StorageSample
FACET device, hostname
WHERE mountPoint = '/'
-- Network traffic
SELECT average(receiveBytesPerSecond), average(transmitBytesPerSecond)
FROM NetworkSample
TIMESERIES SINCE 1 hour ago
Best Practices
- Use custom attributes for better filtering and grouping
- Implement proper error handling and exception tracking
- Set up meaningful alerts with appropriate thresholds
- Use custom events for business metrics tracking
- Implement distributed tracing for microservices
- Monitor both technical and business KPIs
- Regular review of alert policies and dashboard relevance
- Use synthetic monitoring for proactive issue detection
📡 Stay Updated
Release Notes: Platform Updates • Agent Releases • API Changes
Project News: New Relic Blog • Developer Blog • Product Updates
Community: Community Forum • New Relic University • Developer Hub