Getting started with the Elastic AI Assistant for Observability and Microsoft Azure OpenAI
![AI_hand.jpg](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc44abbb1226bfff5/660d59d2a1645457ab461a0d/AI_hand.jpg)
Recently, Elastic announced the AI Assistant for Observability is now generally available for all Elastic users. The AI Assistant enables a new tool for Elastic Observability providing large language model (LLM) connected chat and contextual insights to explain errors and suggest remediation. Similar to how Microsoft Copilot is an AI companion that introduces new capabilities and increases productivity for developers, the Elastic AI Assistant is an AI companion that can help you quickly gain additional value from your observability data.
This blog post presents a step-by-step guide on how to set up the AI Assistant for Observability with Azure OpenAI as the backing LLM. Then once you’ve got the AI Assistant set up, this post will show you how to add documents to the AI Assistant’s knowledge base along with demonstrating how the AI Assistant uses its knowledge base to improve its responses to address specific questions.
Set up the Elastic AI Assistant for Observability: Create an Azure OpenAI key
Start by creating a Microsoft Azure OpenAI API key to authenticate requests from the Elastic AI Assistant. Head over to Microsoft Azure and use an existing subscription or create a new one at the Azure portal.
Currently, access to the Azure OpenAI service is granted by applying for access. See the official Microsoft documentation for the current prerequisites.
![Watch what your data can do](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb1ab1785a4088121/660d691cdf43aa6125f125ae/1.png)
In the Azure portal, select Azure OpenAI.
![Azure OpenAI](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt67b5fb22f4677b8f/660d6937c8592e07f16f3722/2.png)
In the Azure OpenAI service, click the Create button.
![+Create](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb6ece9855f30e17c/660d6952c3bc8b1142dd27e3/3.png)
Enter an instance Name and click Next.
![Basics Next](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt41694bbc12a4c008/660d696b0713751966c432cf/4.png)
Select your network access preference for the Azure OpenAI instance and click Next.
![Network Next](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb6f530929984e4e1/660d6985c095f89e22c6769e/5.png)
Add optional Tags and click Next.
![Tags Next](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3b9b13504735482a/660d69bb3110d0006c069d6c/6.png)
Confirm your settings and click Create to create the Azure OpenAI instance.
![Review + submit Create](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt249589d0c9a61041/660d6a12407aec250b6c6430/7.png)
Once the instance creation is complete, click the Go to resource button.
![go to resource](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt13b6f0944e2f3f47/660d6a91fa138ca1d287ef37/8.png)
Click the Manage keys link to access the instance’s API key.
![manage keys](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4c6fa8c0a929787c/660d6b32cac0bc5ff9c87dcd/9.png)
Copy your Azure OpenAI API Key and the Endpoint and save them both in a safe place for use in a later step.
![copy to clipboard](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb4b53382e1c404e0/660d6b4a6c4a396ddee46ec0/10.png)
Next, click Model deployments to create a deployment within the Azure OpenAI instance you just created.
![model deployments](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9a3d47e66a017bb6/660d6b641b5a580bdbade206/11.png)
Click the Manage deployments button to open Azure OpenAI Studio.
![manage deployments](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte3d2ac1a870047f3/660d755e55ef0920436bffe5/12.png)
Click the Create new deployment button.
![+ Create new deployment](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9c0268f7be327f94/660d757ecac0bc272dc87e71/13.png)
Select the model type you want to use and enter a Deployment name. Note the Deployment name for use in a later step. Click the Create button to deploy the model.
![deploy model](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8e96ff5186f54478/660d75ca18980f103e2038a2/14.png)
Set up the Elastic AI Assistant for Observability: Create an OpenAI connector in Elastic Cloud
The remainder of the instructions in this post will take place within Elastic Cloud. You can use an existing deployment or you can create a new Elastic Cloud deployment as a free trial if you’re trying Elastic Cloud for the first time. Another option to get started is to create an Elastic deployment from the Microsoft Azure Marketplace.
![sign up trial](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfa3702a21a8e5c91/660d76001b5a58b869ade27c/15.png)
The next step is to create an Azure OpenAI connector in Elastic Cloud. In the Elastic Cloud console for your deployment, select the top-level menu and then select Stack Management.
![stack management](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2a5aa9289f111e39/660d76211b5a58774aade284/16.png)
Select Connectors on the Stack Management page.
![connectors](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta55a4a8a0e4cfc60/660d763f18980f03832038aa/17.png)
Select Create connector.
![create connector](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7de841117e964c8e/660d765a6c4a3953d2e46f5c/18.png)
Select the connector for Azure OpenAI.
![openai](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf1da475b6165e65f/660d76781e8523a958739bde/19.png)
Enter a Name of your choice for the connector. Select Azure OpenAI as the OpenAI provider.
![openai connector](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4468f9ce2f7d84d6/660d769e1e85234d71739be2/20.png)
Enter the Endpoint URL using the following format:
Replace {your-resource-name} with the name of the Azure Open AI instance that you created within the Azure portal in a previous step.
Replace {deployment-id} with the Deployment name that you specified when you created a model deployment within the Azure portal in a previous step.
- Replace {api-version} with one of the valid Supported versions listed in the Completions section of the Azure OpenAI reference page.
https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}
Your completed Endpoint URL should look something like this:
https://example-openai-instance.openai.azure.com/openai/deployments/gpt-4-turbo/chat/completions?api-version=2024-02-01
Enter the API Key that you copied in a previous step. Then click the Save & test button.
![save & test](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaf5429b680e9dd0f/660d76ff6ccdb859eda4fb94/21.png)
Within the Edit Connector flyout window, click the Run button to confirm that the connector configuration is valid and can successfully connect to your Azure OpenAI instance.
![](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt018bb006b5d457cb/660d7e0cdf43aa575cf126ff/22.png)
A successful connector test should look something like this:
![results](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt247de92bb5e396c2/660d7e2b1b5a58f721ade2ea/23.png)
Add an example logs record
Now that you have your Elastic Cloud deployment set up with an AI Assistant connector, let’s add an example logs record to demonstrate how the AI Assistant can help you to better understand logs data.
We’ll use the Elastic Dev Tools to add a single logs record. Click the top-level menu and select Dev Tools.
![dev tools](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt31d251e15891aa29/660d7fd61b5a585275ade2fd/24.png)
Within the Console area of Dev Tools, enter the following POST statement:
POST /logs-elastic_agent-default/_doc
{
"message": "Status(StatusCode=\"FailedPrecondition\", Detail=\"Can't access cart storage. \nSystem.ApplicationException: Wasn't able to connect to redis \n at cartservice.cartstore.RedisCartStore.EnsureRedisConnected() in /usr/src/app/src/cartstore/RedisCartStore.cs:line 104 \n at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 168\").",
"@timestamp": "2024-02-22T11:34:00.884Z",
"log": {
"level": "error"
},
"service": {
"name": "cartService"
},
"host": {
"name": "appserver-1"
}
}
Then run the POST command by clicking the green Run button.
![click to send request](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1e066a57f11614b1/660d801b04d34c3eb0bdb276/25.png)
You should see a 201 response confirming that the example logs record was successfully created.
![201 response](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blteab61bc4ff3c0007/660d803fdd5b9e49eba89dc0/26.png)
Use the Elastic AI Assistant
Now that you have a log record to work with, let’s jump over to the Observability Logs Explorer to see how the AI Assistant interacts with logs data. Click the top-level menu and select Observability.
![observability](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb45ad1d5ae5fc612/660d8087fa138c4d8187f055/27.png)
Select Logs Explorer to explore the logs data.
![explorer](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt14b3dcb181515f68/660d80ae4d880a3de3d3043b/28.png)
In the Logs Explorer search box, enter the text “redis” and press the Enter key to perform the search.
![redis](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbe7019a4528df897/660d80d41da7d23dacaf6c69/29.png)
Click the View all matches button to include all search results.
![view all matches](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc06a165381e1ab48/660d80f555ef093b8a6c009f/30.png)
You should see the one log record that you previously inserted via Dev Tools. Click the expand icon to see the log record’s details.
![expand icon](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltafcacdb813f84bc4/660d812cc3bc8b7e2edd292a/31.png)
You should see the expanded view of the logs record. Instead of trying to understand its contents ourselves, we'll use the AI Assistant to summarize it. Click on the What's this message? button.
![What's this message?](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbf3fe05a128d4ca8/660d815e4d880a333ed30444/32.png)
We get a fairly generic answer back. Depending on the exception or error we're trying to analyze, this can still be really useful, but we can make this better by adding additional documentation to the AI Assistant knowledge base.
![log details](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd338f78563563241/660d818a407aec07796c655f/33.png)
Let’s see how we can use the AI Assistant’s knowledge base to improve its understanding of this specific logs message.
Create an Elastic AI Assistant knowledge base
Select Overview from the Observability menu.
![Select Overview from the Observability menu.](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt094f1a6dc78b3903/660d81d4f407dd407431640a/34.png)
Click the AI Assistant button at the top right of the window.
![AI Assistant](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt580cd0b1a73ed303/660d81fecac0bcf6f6c87f01/35.png)
Click the Install Knowledge base button.
![Install Knowledge base](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc3ef226b920aaff3/660d82206ccdb83612a4fc24/36.png)
Click the top-level menu and select Stack Management.
![Stack Management](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt95c251803e801a21/660d8416b1b99a17e53108b2/37.png)
Then select AI Assistants.
![AI Assistants](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt78a4a0a0f32ac2d2/660d848855ef0912556c00d3/38.png)
Click Elastic AI Assistant for Observability.
![Elastic AI Assistant for Observability](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt444da17756a25cd5/660d84d6f407dd9f29316428/39.png)
Select the Knowledge base tab.
![Knowledge base](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5d4bd7aca24c0ccd/660d850ddf43aa04b6f12740/40.png)
Click the New entry button and select Single entry.
![new entry](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt86501b1a44626472/660d8578dd5b9e4a29a89e09/41.png)
Give it the Name “cartservice” and enter the following text as the Contents:
I have the following GitHub issue. Store this information in your knowledge base and always return the link to it if relevant.
GitHub Issue, return if relevant
Link: https://github.com/elastic/observability-examples/issues/25
Title: Cartservice Intermittent connection issue
Body:
The cartservice occasionally encounters storage errors due to an unreliable network connection.
The errors typically indicate a failure to connect to Redis, as seen in the error message:
Status(StatusCode="FailedPrecondition", Detail="Can't access cart storage.
System.ApplicationException: Wasn't able to connect to redis
at cartservice.cartstore.RedisCartStore.EnsureRedisConnected() in /usr/src/app/src/cartstore/RedisCartStore.cs:line 104
at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 168')'.
I just talked to the SRE team in Slack, they have plans to implement retries as a quick fix and address the network issue later.
Click Save to save the new knowledge base entry.
![save](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaf8ac97215382b20/660d8a25071375f6a3c434a4/42.png)
Now let’s go back to the Observability Logs Explorer. Click the top-level menu and select Observability.
![settings](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltef2319b2513b5a9f/660d8a4655ef0985e76c0135/43.png)
Then select Explorer under Logs.
![explorer](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8e685f524d1c920b/660d8a6bc3bc8b0ec5dd299a/44.png)
Expand the same logs entry as you did previously and click the What’s this message? button.
![What’s this message? button](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt042c87534b0a0848/660d8a9e6c4a39bda6e47047/45.png)
The response you get now should be much more relevant.
![log details](https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfd6ed6edc12d22c8/660d8ac56c4a39dadbe47051/46.png)
Try out the Elastic AI Assistant with a knowledge base filled with your own data
Now that you’ve seen how easy it is to set up the Elastic AI Assistant for Observability, go ahead and give it a try for yourself. Sign up for a free 14-day trial. You can quickly spin up an Elastic Cloud deployment in minutes and have your own search powered AI knowledge base to help you with getting your most important work done.
The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.
In this blog post, we may have used or referred to third party generative AI tools, which are owned and operated by their respective owners. Elastic does not have any control over the third party tools and we have no responsibility or liability for their content, operation or use, nor for any loss or damage that may arise from your use of such tools. Please exercise caution when using AI tools with personal, sensitive or confidential information. Any data you submit may be used for AI training or other purposes. There is no guarantee that information you provide will be kept secure or confidential. You should familiarize yourself with the privacy practices and terms of use of any generative AI tools prior to use.
Elastic, Elasticsearch, ESRE, Elasticsearch Relevance Engine and associated marks are trademarks, logos or registered trademarks of Elasticsearch N.V. in the United States and other countries. All other company and product names are trademarks, logos or registered trademarks of their respective owners.