Overview
The New Relic API offers a comprehensive set of interfaces for interacting with the New Relic observability platform. Designed for developers and technical buyers, these APIs facilitate programmatic control over data ingestion, querying, and platform configuration. Organizations utilize the New Relic API to extend their monitoring capabilities, embed observability into their software development lifecycle, and automate operational tasks. The platform's core products, including Application Performance Monitoring (APM), Infrastructure Monitoring, Browser Monitoring, and Distributed Tracing, are all accessible and manageable through its API endpoints.
New Relic's API is particularly well-suited for teams focused on full-stack observability, aiming to correlate performance data across various layers of their technology stack. By providing access to metrics, events, logs, and traces (MELT data), the API enables proactive issue detection and performance optimization. For instance, developers can use the API to automatically instrument new services, retrieve specific performance metrics for custom dashboards, or trigger alerts based on defined thresholds. This level of programmatic access supports a shift-left approach to observability, allowing issues to be identified and addressed earlier in the development process.
The API caters to DevOps teams seeking to integrate monitoring into their CI/CD pipelines. This integration allows for automated performance testing, validation of deployments, and rapid rollback if performance regressions are detected. New Relic's extensive documentation provides clear examples and use cases for various API endpoints, supporting developers in programmatically integrating monitoring into their workflows and automating responses to performance issues. The platform's commitment to developer experience is evident in its provision of SDKs for multiple programming languages, simplifying interaction with the API for common tasks.
New Relic's API capabilities extend to security monitoring through New Relic Vulnerability Management, allowing teams to integrate security insights into their overall observability strategy. This enables a unified view of application health and security posture. As noted by industry analysts like Thoughtworks, a comprehensive observability strategy that integrates security and performance data is increasingly critical for modern distributed systems, making APIs like New Relic's central to achieving this goal. The platform's compliance certifications, including SOC 2 Type II, GDPR, ISO 27001, and HIPAA, address enterprise requirements for data security and regulatory adherence, positioning it for use in regulated industries.
Key features
- Data Ingestion APIs: Allows for sending custom metrics, events, logs, and traces from any source into New Relic, enabling comprehensive data aggregation.
- Query APIs (NerdGraph, NRQL): Provides GraphQL-based access (NerdGraph) and a SQL-like query language (NRQL) for retrieving and analyzing all ingested telemetry data, supporting custom reporting and dashboarding.
- Configuration APIs: Enables programmatic management of New Relic entities such as alerts, dashboards, synthetic monitors, and service levels, facilitating automation of platform setup and maintenance.
- Alerting and Notifications: Integrates with external systems to trigger custom actions or notifications based on alert conditions defined within New Relic.
- Distributed Tracing: Offers APIs to instrument and collect distributed traces, providing end-to-end visibility into requests across microservices.
- APM and Infrastructure Data Access: Provides endpoints to retrieve detailed performance metrics for applications and infrastructure components, including CPU usage, memory, and error rates.
- Browser and Mobile Monitoring: APIs to access real user monitoring (RUM) data and mobile application performance data for front-end and mobile experience analysis.
- Security Monitoring: Programmatic access to New Relic Vulnerability Management data, allowing integration of security findings with operational workflows.
Pricing
New Relic employs a usage-based pricing model, primarily driven by data ingest volume and user type. A free tier is available, offering a baseline for evaluation and small-scale use cases.
| Tier | Data Ingest | Users Included | Key Features | Monthly Cost |
|---|---|---|---|---|
| Free | Up to 100 GB | 1 Full User | Core observability platform, APM, Infrastructure, Browser, Mobile, Logs, Errors Inbox, Synthetics | $0 |
| Standard | 250 GB (starting) | 1 Core User | All Free features, 24/5 technical support | Starts at $99 |
| Pro | Custom | Custom | All Standard features, advanced security, HIPAA, FedRAMP, 24/7 technical support | Custom Quote |
| Enterprise | Custom | Custom | All Pro features, dedicated account management, advanced compliance, premium support | Custom Quote |
Additional details on pricing and user types are available on the New Relic pricing page.
Common integrations
- CI/CD Pipelines: Integrate with tools like Jenkins, GitLab CI, or GitHub Actions to automate performance testing and deployment validation using New Relic APIs.
- Alerting and Incident Management: Connect with PagerDuty, Opsgenie, or Slack to route New Relic alerts and facilitate incident response.
- Cloud Platforms: Monitor AWS, Google Cloud, and Azure services by ingesting metrics and logs, often using New Relic agents or API integrations.
- Custom Dashboards and Reporting: Export data to business intelligence tools or custom applications using NRQL and NerdGraph APIs for specialized analytics.
- Serverless Functions: Instrument AWS Lambda, Azure Functions, or Google Cloud Functions to collect performance data and traces.
- Container Orchestration: Integrate with Kubernetes and Docker to monitor containerized applications and infrastructure.
Alternatives
- Datadog: Offers a broad observability platform with extensive integrations for infrastructure, application, and log monitoring.
- Dynatrace: Provides AI-powered full-stack observability with automated root-cause analysis and business impact insights.
- Splunk: Known for its data platform for security, observability, and operational intelligence, with strong log management capabilities.
- AWS CloudWatch: Amazon's native monitoring and observability service for AWS resources and applications.
- Google Cloud Monitoring: Google Cloud's integrated monitoring solution for applications and infrastructure running on Google Cloud.
Getting started
To begin interacting with the New Relic API, you'll typically need an API key. The following Python example demonstrates how to use the New Relic NerdGraph API to fetch a list of your New Relic accounts. This requires a personal API key, which can be generated within the New Relic UI.
import requests
import json
NEW_RELIC_API_KEY = "YOUR_NEW_RELIC_PERSONAL_API_KEY" # Replace with your actual API key
NEW_RELIC_REGION = "US" # Or "EU" depending on your account region
def get_new_relic_accounts():
if NEW_RELIC_REGION == "EU":
graphql_endpoint = "https://api.eu.newrelic.com/graphql"
else:
graphql_endpoint = "https://api.newrelic.com/graphql"
headers = {
"Api-Key": NEW_RELIC_API_KEY,
"Content-Type": "application/json"
}
query = """
{
actor {
accounts {
name
id
}
}
}
"""
try:
response = requests.post(graphql_endpoint, headers=headers, json={"query": query})
response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
data = response.json()
if "errors" in data:
print("API Errors:")
for error in data["errors"]:
print(f" - {error['message']}")
return None
accounts = data["data"]["actor"]["accounts"]
print("New Relic Accounts:")
for account in accounts:
print(f" Name: {account['name']}, ID: {account['id']}")
return accounts
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err} - {response.text}")
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An error occurred: {req_err}")
except json.JSONDecodeError:
print(f"Failed to decode JSON from response: {response.text}")
return None
if __name__ == "__main__":
if NEW_RELIC_API_KEY == "YOUR_NEW_RELIC_PERSONAL_API_KEY":
print("Please replace 'YOUR_NEW_RELIC_PERSONAL_API_KEY' with your actual New Relic API key.")
print("You can find instructions on generating API keys at: https://docs.newrelic.com/docs/apis/get-started/introduction-new-relic-apis/#authentication")
else:
get_new_relic_accounts()
This Python script uses the requests library to send a GraphQL query to the New Relic NerdGraph API. It fetches the names and IDs of all accounts associated with the provided API key. Ensure you replace YOUR_NEW_RELIC_PERSONAL_API_KEY with your actual key and set the correct NEW_RELIC_REGION. For more detailed API documentation and authentication methods, refer to the New Relic API reference.