---
title: "Connect New Relic to AI Agents: Automate Ops and Infrastructure"
slug: connect-new-relic-to-ai-agents-automate-ops-and-infrastructure
date: 2026-06-09
author: Uday Gajavalli
categories: ["AI & Agents"]
excerpt: "A definitive engineering guide to connecting New Relic to AI agents. Learn how to fetch tools, bind them to LLMs, and automate DevOps and infrastructure workflows."
tldr: "Connect New Relic to AI agents to automate observability workflows. This guide covers overcoming New Relic API quirks, fetching tools via Truto, handling rate limits, and building multi-step DevOps agents."
canonical: https://truto.one/blog/connect-new-relic-to-ai-agents-automate-ops-and-infrastructure/
---

# Connect New Relic to AI Agents: Automate Ops and Infrastructure


You want to connect New Relic to an AI agent so your system can automatically triage alerts, provision dashboards, audit user access, and query infrastructure telemetry in real-time. Here is exactly how to do it using Truto's `/tools` endpoint and SDK, bypassing the need to build and maintain a custom New Relic API integration from scratch.

If your team uses ChatGPT, check out our [guide to connecting New Relic to ChatGPT](https://truto.one/connect-new-relic-to-chatgpt-manage-users-dashboards-and-alerts/), or if you are building on Anthropic's models, read our [guide to connecting New Relic to Claude](https://truto.one/connect-new-relic-to-claude-control-monitoring-and-team-access/). For developers building custom autonomous workflows across frameworks like LangChain, CrewAI, or the Vercel AI SDK, you need a programmatic way to fetch New Relic tools and bind them to your agent's reasoning loop. This is part of solving the broader [SaaS integration bottleneck](https://truto.one/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/) that often stalls production-grade agent development.

The industry is shifting from static observability dashboards to agentic AI - autonomous systems that work alongside DevOps and Site Reliability Engineers (SREs) to execute multi-step diagnostic workflows. Giving a Large Language Model (LLM) read and write access to your New Relic instance is a powerful concept, but an engineering headache in practice. You either spend weeks building, hosting, and maintaining a custom connector, or you use a [pass-through infrastructure layer](https://truto.one/zero-data-retention-for-ai-agents-why-pass-through-architecture-wins/) that handles the boilerplate for you.

This guide breaks down exactly how to fetch AI-ready tools for New Relic, bind them natively to an LLM, and execute complex infrastructure automation.

## The Engineering Reality of New Relic's API

Building AI agents is easy. Connecting them to external SaaS APIs is hard. 

Giving an LLM access to your observability stack sounds simple in a local prototype. You write a Node.js function that makes a `fetch` request to New Relic and wrap it in an `@tool` decorator. In production, this approach collapses. If you build a custom integration for New Relic AI Agents, you own the entire API lifecycle. You have to handle OAuth token refreshes, track schema changes, and manage context windows.

New Relic's API introduces specific integration challenges that break standard agentic assumptions:

**The NerdGraph and REST Divide**
New Relic is actively transitioning heavily toward NerdGraph, its GraphQL API. LLMs inherently struggle with raw GraphQL. An LLM cannot easily "guess" the correct mutation structure or introspection query required to fetch nested telemetry data without hallucinating fields. To make New Relic accessible to an AI agent, you must translate the underlying API behavior into flat, distinct, REST-like tools with strict JSON schemas that the LLM understands.

**Entity GUIDs vs Account IDs**
New Relic architecture relies heavily on cross-account visibility. An organization might have a master account and dozens of sub-accounts. Entities (like a specific application, host, or synthetic monitor) are tracked via global entity GUIDs, not simple integer IDs. If an AI agent wants to update a service level objective (SLO), it first needs to query the environment to map the human-readable service name to its exact entity GUID, and then pass that GUID into the subsequent API call. Your tool definitions must explicitly guide the LLM to perform this mapping step.

**NRQL Escaping and Syntax**
Creating dashboards or querying tags often requires New Relic Query Language (NRQL). While LLMs are surprisingly good at writing NRQL, passing raw NRQL strings through standard JSON payloads often results in escaping errors, especially when dealing with complex `WHERE` clauses containing nested quotes. The integration layer must cleanly handle these payload serialization issues.

**Strict Rate Limits and 429 Errors**
New Relic enforces strict rate limits based on your pricing tier and the specific endpoint. If your AI agent attempts to run a heavy script to audit all 5,000 workloads in your environment simultaneously, it will hit an `HTTP 429 Too Many Requests` error. 

*Crucial architectural note:* Truto does not retry, throttle, or apply automatic backoff on rate limit errors. When the upstream New Relic API returns an HTTP 429, Truto passes that exact error to the caller. However, Truto normalizes the upstream rate limit information into standardized headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`) per the IETF spec. As the developer of the AI agent, you are explicitly responsible for reading these headers and implementing retry or backoff logic in your agent's execution loop.

## Exposing New Relic to Agents via Truto Tools

To bridge the gap between New Relic's complex architecture and your agent framework, Truto abstracts the API into a standardized set of `Resources` and `Methods`. 

Every integration on Truto operates like a comprehensive, dynamically generated JSON object mapping the underlying product's capabilities into a REST-based CRUD API. We define endpoints like `workloads` or `dashboards` as Resources, and actions like `List`, `Get`, `Create`, or custom actions as Methods. For teams looking for standardized ways to expose these capabilities, see our [guide to building MCP servers for AI agents](https://truto.one/the-hands-on-guide-to-building-mcp-servers-for-ai-agents-2026/).

Truto provides a `/tools` endpoint (`GET https://api.truto.one/integrated-account/<id>/tools`) that automatically outputs these Methods alongside rich descriptions and strict query schemas optimized specifically for LLM consumption. Your agent framework simply ingests this payload, and Truto handles the underlying authentication and pagination when the tool is called.

### Hero Tools for New Relic Automation

When connecting New Relic to AI Agents, you do not want to overwhelm the LLM with generic endpoints. You want to expose high-leverage tools that unlock specific DevOps and SRE workflows. Here are 6 of the most impactful New Relic tools available via Truto.

#### list_all_new_relic_workload_status

Use this tool to retrieve the computed health status for one or more workloads. When an alert fires, the agent can use this tool to determine the current operational state of the associated workload before waking up an engineer.

> "Check the current workload status for the 'Payment Gateway API' workload and summarize any degraded states."

#### create_a_new_relic_dashboard

Use this tool to create a simple New Relic dashboard in a specific account using a single NRQL query. This is incredibly powerful for generative UI scenarios where a developer asks the agent to visualize a specific metric on the fly.

> "Create a new dashboard in our primary account titled 'Database Latency Spike Analysis' using the NRQL query provided in the incident ticket."

#### list_all_new_relic_alert_policies

Use this tool to list all alert policies configured for a New Relic account. Agents use this to audit monitoring coverage or verify how incidents are currently grouped and routed.

> "List all the alert policies currently active in the production environment. Identify any policies where the incident preference is set to open an incident per condition rather than per policy."

#### list_all_new_relic_golden_metrics

Use this tool to retrieve the golden metrics configuration for a specific New Relic entity using its entity GUID. This helps the agent understand what key health signals (like latency, error rate, throughput) are prioritized for a given service.

> "Fetch the golden metrics for the 'User Auth Service' and tell me what the baseline error rate threshold is."

#### create_a_new_relic_user

Use this tool to provision a new user in a manually managed New Relic authentication domain. This transforms your AI agent into an automated IT helpdesk, handling access requests dynamically.

> "Create a new user profile for Sarah in the engineering authentication domain. Use her corporate email and assign her to the FULL_USER_TIER."

#### create_a_new_relic_service_level

Use this tool to programmatically define new Service Level Objectives (SLOs) and Service Level Indicators (SLIs) for an entity. The LLM can write the NRQL for valid and good events and deploy the objective automatically.

> "Create a new service level for the checkout service targeting a 99.9% success rate over a 7-day rolling window. Use the NRQL queries we discussed for successful HTTP 200 responses."

To view the complete inventory of available New Relic resources, methods, and schemas, visit the [New Relic integration page](https://truto.one/integrations/detail/newrelic).

## Building Multi-Step Workflows

To connect New Relic to AI Agents, you need an execution loop. The agent must receive a prompt, analyze the available Truto tools, decide which tool to call, execute the API request, and feed the response back into its context window to decide the next step.

Here is how to build this natively using LangChain.js and the `@trutohq/truto-langchainjs-toolset` SDK. This architecture works universally across major frameworks.

### 1. Initialize the Tool Manager

First, authenticate with Truto and fetch the tools associated with your connected New Relic account ID.

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "@trutohq/truto-langchainjs-toolset";
import { HumanMessage } from "@langchain/core/messages";

// Initialize the LLM
const llm = new ChatOpenAI({
  modelName: "gpt-4o",
  temperature: 0,
});

// Initialize Truto's Tool Manager with your New Relic Account ID
const toolManager = new TrutoToolManager({
  trutoToken: process.env.TRUTO_API_KEY,
  integratedAccountId: "new_relic_account_12345",
});

async function runAgent() {
  // Fetch all available New Relic tools via the Truto API
  const tools = await toolManager.getTools();
  
  // Bind the New Relic tools directly to the LLM
  const llmWithTools = llm.bindTools(tools);
  
  console.log(`Loaded ${tools.length} New Relic tools for the agent.`);
  // ...
}
```

### 2. Implement the Agent Loop and Rate Limit Handling

When the agent runs, it may need to call multiple tools in sequence - for example, searching for a user ID, then searching for a role ID, and finally assigning that role. 

Because Truto passes New Relic's HTTP 429 rate limit errors directly back to your application, your tool execution logic must catch these errors, read the standardized `ratelimit-reset` header, and wait before retrying.

```typescript
  // ... continued from above
  const messages = [
    new HumanMessage("Find the workload named 'Inventory DB' and check its current health status.")
  ];

  // First pass: The LLM decides which tool to call
  const aiMessage = await llmWithTools.invoke(messages);
  messages.push(aiMessage);

  // Check if the LLM decided to use a New Relic tool
  if (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {
    for (const toolCall of aiMessage.tool_calls) {
      console.log(`Executing tool: ${toolCall.name}`);
      
      let success = false;
      let retries = 0;
      const maxRetries = 3;

      while (!success && retries < maxRetries) {
        try {
          // Find and execute the specific tool
          const tool = tools.find(t => t.name === toolCall.name);
          const result = await tool.invoke(toolCall.args);
          
          messages.push({
            role: "tool",
            tool_call_id: toolCall.id,
            name: toolCall.name,
            content: JSON.stringify(result)
          });
          
          success = true;

        } catch (error) {
          // Explicitly handle 429 Rate Limits passed through by Truto
          if (error.response && error.response.status === 429) {
            // Truto normalizes upstream headers to the IETF spec
            const resetTimeStr = error.response.headers.get('ratelimit-reset');
            const resetTimeMs = resetTimeStr ? parseInt(resetTimeStr, 10) * 1000 : 5000;
            
            console.warn(`Rate limited by New Relic. Waiting ${resetTimeMs}ms...`);
            await new Promise(resolve => setTimeout(resolve, resetTimeMs));
            retries++;
          } else {
            // Handle other API errors (400, 401, 500)
            throw error;
          }
        }
      }
    }
    
    // Second pass: LLM interprets the tool results and answers the user
    const finalResponse = await llmWithTools.invoke(messages);
    console.log("Agent Response:", finalResponse.content);
  }
}

runAgent();
```

## Workflows in Action

When you connect New Relic to AI Agents with comprehensive tool definitions, you move beyond simple chat interfaces into autonomous DevOps orchestration. Here is how specific engineering personas utilize these multi-step workflows in production.

### Use Case 1: Automated Incident Triage

When PagerDuty triggers a high-severity alert at 3:00 AM, the on-call SRE needs immediate context before opening their laptop. An AI agent hooked into Slack and New Relic can perform the initial investigation autonomously. This is a primary component of learning how to [orchestrate incident response across Datadog, PagerDuty, and Slack](https://truto.one/how-to-orchestrate-incident-response-across-datadog-pagerduty-slack/).

> "An alert just fired for the 'EU-Central-Kafka-Cluster'. Check its current workload status, list any related active alert policies, and grab the golden metrics to see if throughput has dropped."

**Step-by-step Execution:**
1. The agent calls `list_all_new_relic_workload_entities` to search for the specific Kafka cluster and retrieve its entity GUID.
2. It passes that GUID into `list_all_new_relic_workload_status` to determine if the computed health is currently DEGRADED or CRITICAL.
3. It calls `list_all_new_relic_alert_policies` to verify exactly which threshold rule triggered the alarm.
4. It calls `list_all_new_relic_golden_metrics` to extract the primary NRQL queries for that entity, summarizing the baseline throughput versus the current state.

**Result:** The SRE receives a concise Slack message detailing the exact failure point, the related policy, and the current metric deviation, saving 15 minutes of manual dashboard hunting.

### Use Case 2: Just-In-Time Observability Onboarding

Platform engineering teams spend hours manually provisioning access and custom views for new developers. An AI agent can automate IT service requests natively.

> "Provision a New Relic account for John Doe (john@company.com). Put him in the Core User Tier, add him to the 'Backend Services' team, and create a basic dashboard for him showing the HTTP 500 error rate over the last 24 hours."

**Step-by-step Execution:**
1. The agent calls `create_a_new_relic_user` passing John's email and specifying `CORE_USER_TIER`.
2. The agent calls `list_all_new_relic_teams` to find the internal ID for the "Backend Services" team.
3. The agent formulates a basic NRQL query (`SELECT count(*) FROM Transaction WHERE httpResponseCode >= '500' SINCE 24 HOURS AGO TIMESERIES`).
4. It calls `create_a_new_relic_dashboard` using the generated NRQL to instantly provision a localized view in John's environment.

**Result:** The developer is instantly fully provisioned with scoped access and a pre-configured dashboard tailored to their domain, entirely through natural language.

### Use Case 3: SLO and Compliance Auditing

Engineering managers need to ensure that all tier-1 services have proper monitoring coverage and that service level objectives are strictly enforced.

> "Audit the 'Checkout Service'. List its current service levels and tell me if any metric normalization rules are actively altering its telemetry data."

**Step-by-step Execution:**
1. The agent fetches the entity GUID for the Checkout Service.
2. It calls `list_all_new_relic_service_levels` using the GUID to pull the SLIs, checking if the rolling targets are set to acceptable enterprise standards.
3. It calls `list_all_new_relic_metric_normalization_rules` to audit the account, cross-referencing to see if any rules are unexpectedly mutating or dropping metrics related to the checkout flow.

**Result:** The engineering manager receives a compliance audit confirming that the SLOs are correctly tracked and that telemetry data is not being inadvertently altered by global normalization rules.

## The Strategic Value of Dynamic Tool Definitions

The bottleneck in building AI agents for DevOps is not the reasoning model; it is API integration layer maintenance. New Relic frequently updates its API schema, introduces new telemetry features, and deprecates legacy endpoints. If you hardcode API fetch requests in your agent's source code, your AI product will break silently and frequently.

By utilizing Truto's `/tools` endpoint, you decouple your agent's logic from New Relic's API infrastructure. The tools are generated dynamically. When New Relic adds a new query parameter to a dashboard endpoint, Truto updates the JSON schema automatically, and your LLM intuitively understands the new parameter on its next execution cycle.

Stop managing custom SaaS boilerplate and start building autonomous workflows that actually solve infrastructure problems.

:::cta{buttonText="Talk to us" buttonUrl="https://cal.com/truto/partner-with-truto"} 
Want to connect your AI agents to New Relic, Datadog, PagerDuty, and 200+ other enterprise tools without writing custom integrations? Book a call to see how Truto's Unified APIs and Agent Toolsets can accelerate your roadmap.
:::
