• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

NerdGraph tutorial: Configure RAG Tools and Documents

preview

We're still working on this feature, but we'd love for you to try it out!

This feature is currently provided as part of a preview program pursuant to our pre-release policies.

With New Relic, you can enhance NRAI agents with RAG. This means that you can associate documentation, runbooks, incident retros and even source code with your services, giving NRAI better insight into issues with your system.

Get Started with RAG

Obtain your organization ID

{
actor {
organization {
id
}
}
}

Create a RAG Tool

It should be noted - the name and description of your RAG Tool are extremely important! The LLM will choose to leverage a tool when responding to a prompt based on the accuracy of a tool's name and description.

mutation {
entityManagementCreateRagTool(
ragToolEntity: {
description: "Runbooks for resolving incidents with APIs",
name: "API Runbooks",
scope: {id: `${ORGANIZATION_ID}`, type: ORGANIZATION}}
) {
entity {
id
}
}
}

Upload a document to the Blob API

  • Note that this specific step is not through NerdGraph. This is because NerdGraph does support file uploads through it's APIs.
curl -X POST https://blob-api.one-service.newrelic.com/v1/e/organizations/$ORGANIZATION_ID/RagDocuments \
-H 'Api-Key: NRAK-XXXXXXXXXX' \
-H 'NewRelic-Entity: {"name": "Runbooks for API service" }' \
-H 'Content-Type: application/json' \
-d @incidents.json

The response will look like this:

{
"{entityGuid}": "MTIyODU0NTN8TkdFUHxSQUdfRE9DVU1FTlR8MDE5NGUyOTgtYmQzMS03NzA4LWI3NzItYzQ4MTZlYjNhYThk",
"blobVersionEntity": null
}

View the RAG Document entity represented in NerdGraph

{
actor {
entityManagement {
entity(
id: `${RAG_DOCUMENT_GUID}`
) {
... on EntityManagementRagDocumentEntity {
id
name
blob {
url
}
type
}
}
}
}
}

Now that we have a RAG Tool and a RAG Document, we need to associate them with each other. This is done via the Entity Management APIs in NerdGraph.

Create a relationship between the RAG Document and the RAG Tool

mutation {
entityManagementCreateRelationship(
relationship: {
source: {
scope: ORGANIZATION,
id: `${RAG_DOCUMENT_GUID}`
},
target: {
scope: ORGANIZATION,
id: `${RAG_TOOL_GUID}`
},
type: "INDEXED_FOR"}
) {
relationship {
type
target {
id
type
}
source {
id
type
}
}
}
}

Query to see relationships between RAG Documents and RAG Tools

{
actor {
entityManagement {
relationships(
filter: {sourceId: {eq: `${RAG_DOCUMENT_ID}`}}
) {
items {
type
target {
id
type
}
}
}
}
}
}

Query the RAG Tool

You can query your RAG Tool and receive chunked matches based on the documents indexed for a given tool. You may use NRAI to summarize the returned chunk matches, or you may use the NerdGraph APIs to retrieve the match and use your own AI on your own systems.

{
actor {
machineLearning {
ragQueryData(prompt: "tell me about the incident", toolId: `${RAG_TOOL_GUID}`) {
blobId
chunk
documentId
score
toolId
}
}
}
}
Copyright © 2025 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.