Aperçu
Nous travaillons toujours sur cette fonctionnalité, mais nous aimerions que vous l'essayiez !
Cette fonctionnalité est actuellement fournie dans le cadre d'un programme d'aperçu conformément à nos politiques de pré-sortie.
With New Relic, you can enhance New Relic AI agents with Retrieval Augmented Generation (RAG) by associating your documentation, runbooks, incident retros, and even source code with your services. This process gives New Relic AI better insight into issues with your system. The tutorial outlines how to obtain your organization ID, create a RAG tool, and add your documents to the platform using the Blob API.
After adding your documents, you will create a relationship to associate them with the RAG tool. You can then verify your configuration by querying the relationships between the RAG documents and the RAG tool. The final step is to query the RAG tool itself to retrieve relevant, indexed information.
To learn more about the knowledge connector, refer to New Relic AI Knowledge connector.
Important
Before performing the following steps, ensure that you have "Org Product Admin" permissions.
Pour commencer à indexer votre contenu et bénéficier du connecteur de connaissances avec New Relic AI, suivez les étapes mentionnées :
Task 1: Create your RAG tool
Organization ID uniquely identifies your account and ensures that any RAG tool you create, documents you upload, or relationships you establish are associated with your organization in New Relic.
Organization ID is required to perform mutations and queries in NerdGraph when setting up and managing RAG tools and documents. Run the following query and keep the organization ID handy for later steps.
Exemple de requête
{ actor { organization { id } }}
A RAG tool acts as a specialized container for organizing related documents and resources in New Relic. A clear name and accurate description for your RAG tools helps the LLM select the right tool for each prompt, ensuring relevant and context-aware responses.
To create a new RAG tool in your New Relic account, run the following entityManagementCreateRagTool
mutation:
Make sure to replace
${ORGANIZATION_ID}
with your actual organization ID obtained in the previous step.If successful, you'll receive an
id
for your RAG tool.Paramètres d'entrée
Parameter Name
Type de données
Est-ce obligatoire ?
Description
ragToolEntity
Objet
Oui
The input object that contains the configuration for the new RAG tool.
description
Chaîne
Oui
A clear and accurate description of the RAG tool's purpose.
name
Chaîne
Oui
The unique name for your RAG tool.
scope
Objet
Oui
An object defining the context in which the tool will be created.
scope.id
Chaîne
Oui
The unique ID of your organization (
${ORGANIZATION_ID}
).
scope.type
Chaîne
Oui
The type of the scope, which must be
ORGANIZATION
.
Mutation d'échantillon
mutation {entityManagementCreateRagTool(ragToolEntity: {description: "Runbooks for resolving incidents with APIs",name: "API Runbooks",scope: {id: `${ORGANIZATION_ID}`, type: ORGANIZATION}}) {entity {id}}}You should save the
id
returned as you'll need it in later steps to link documents to the tool, verify relationships, and query the tool for relevant information in New Relic.
Task 2: Index your documents
Important
All indexed documents are visible to all users within your organization. Make sure the documents you index comply with your internal policies, and do not upload sensitive or private data.
The Blob API and its purpose
The Blob API is a New Relic service designed for uploading files, such as documentation and runbooks, to your account. NerdGraph is optimized for structured data queries and mutations and not for efficient transfer of files, so the Blob API is required for uploading documents.
Authentication requirements
You need a valid New Relic API key with permissions to upload documents. To get the API key for uploading a document to New Relic using the Blob API:
Log in to your New Relic account.
Create and manage your API keys from the API keys UI page.
Click Create a key, and fill the required details (or use an existing one with the required permissions).
Click Create a key and copy the generated key (it'll look like NRAK-XXXXXXXXXX).
Here's an example of how to upload a document using a
curl
bash
command:Paramètres d'entrée
Parameter Name
Type de données
Est-ce obligatoire ?
Description
Api-Key
Chaîne
Oui
Your New Relic API key for authentication.
NewRelic-Entity
JSON Object
Oui
Metadata about the document, such as its name.
Content-Type
Chaîne
Oui
The format of the file being uploaded (e.g.,
application/json
).
payload
(
@incidents.json
)
Déposer
Oui
The document file you are uploading, specified by its file path.
Exemple de requête
bash$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.jsonExemple de réponse
Réponse
Type de données
Description
entityGuid
Chaîne
The unique identifier for the uploaded RAG document.
blobVersionEntity
Objet
Represents the version of the uploaded blob.
{"entityGuid": "MTIyODU0NTN8TkdFUHxSQUdfRE9DVU1FTlR8MDE5NGUyOTgtYmQzMS03NzA4LWI3NzItYzQ4MTZlYjNhYThk","blobVersionEntity": null}Prochaines étapes
After uploading your document, it is indexed and becomes available for New Relic AI to search and retrieve. You must save the
entityGuid
from the response to create a relationship with your RAG tool or to query the document in NerdGraph.
After a document is uploaded via the Blob API, running this query confirms that the upload was successful and that the document has been properly registered as a RAG document entity with its own unique identifier and properties.
Paramètres d'entrée
Parameter Name | Type de données | Est-ce obligatoire ? | Description |
---|---|---|---|
| Chaîne | Oui | The unique GUID of the RAG document to be retrieved. |
Exemple de requête
In the query below, replace the ${RAG_DOCUMENT_GUID}
placeholder with the entityGuid
you received in the previous step.
{ actor { entityManagement { entity( id: `${RAG_DOCUMENT_GUID}` ) { ... on EntityManagementRagDocumentEntity { id name blob { url } type } } } }}
This query will return the following details about your RAG document:
id
: The unique ID of the RAG document.name
: The name of the RAG document.blob { url }
: The URL to access the uploaded document.type
: The type of the entity, which in this case isEntityManagementRagDocumentEntity
.
Now that you've created a RAG tool, uploaded your document, and verified that the upload was successful, the next step is to associate the RAG tool and the RAG document thereby making your document searchable and usable by New Relic AI. To do this, run the entityManagementCreateRelationship
mutation:
Replace
${RAG_DOCUMENT_GUID}
with theentityGuid
from the response of the document upload via the Blob API.Replace
${RAG_TOOL_GUID}
with theid
from the response of the RAG tool creation mutation.Paramètres d'entrée
Parameter Name
Type de données
Est-ce obligatoire ?
Description
relationship
Objet
Oui
The input object that contains the details for the relationship.
source
Objet
Oui
The source entity of the relationship, which is the RAG document.
source.scope
Chaîne
Oui
The scope of the source entity, which must be
ORGANIZATION
.
source.id
Chaîne
Oui
The unique GUID of the RAG document (
${RAG_DOCUMENT_GUID}
).
target
Objet
Oui
The target entity of the relationship, which is the RAG tool.
target.scope
Chaîne
Oui
The scope of the target entity, which must be
ORGANIZATION
.
target.id
Chaîne
Oui
The unique GUID of the RAG tool (
${RAG_TOOL_GUID}
).
type
Chaîne
Oui
The type of the relationship, which must be
"INDEXED_FOR"
.
Mutation d'échantillon
mutation {entityManagementCreateRelationship(relationship: {source: {scope: ORGANIZATION,id: `${RAG_DOCUMENT_GUID}`},target: {scope: ORGANIZATION,id: `${RAG_TOOL_GUID}`},type: "INDEXED_FOR"}) {relationship {typetarget {idtype}source {idtype}}}}
Task 3: Retrieve relevant information
After creating a relationship between your RAG document and RAG tool, you can verify the association by querying relationships in NerdGraph. This helps ensure your document is properly linked and available for New Relic AI to use.
Replace
${RAG_DOCUMENT_ID}
with theentityGuid
of your uploaded document.Paramètres d'entrée
Parameter Name
Type de données
Est-ce obligatoire ?
Description
relationships
Qequête
Oui
The query to retrieve relationships between entities.
filter
Objet
Non
An object used to filter the relationships based on attributes.
filter.sourceId
Objet
Non
An object to filter by the source entity's unique identifier.
filter.sourceId.eq
Chaîne
Non
The unique GUID of the RAG document to match.
Exemple de requête
{actor {entityManagement {relationships(filter: {sourceId: {eq: `${RAG_DOCUMENT_ID}`}}) {items {typetarget {idtype}}}}}}
After you've set up your RAG tool and indexed documents, you can query the RAG tool to retrieve relevant information based on your prompt. This allows New Relic AI to surface context-aware answers using your organization's documentation.
Paramètres d'entrée
Parameter Name | Type de données | Est-ce obligatoire ? | Description |
---|---|---|---|
| Chaîne | Oui | The natural language query you want the RAG tool to process. |
| Chaîne | Oui | The unique GUID of the RAG tool to be queried. |
Exemple de requête
{ actor { machineLearning { ragQueryData( prompt: "tell me about the incident", toolId: `${RAG_TOOL_GUID}` ) { blobId chunk documentId score toolId } } }}
The response will include chunked matches from your indexed documents, which you can use directly or summarize with New Relic AI.