Data summary

This is an experimental feature and is not recommended for use in a production environment. For updates on the progress of the feature or if you want to leave feedback, join the discussion on the OpenSearch forum.

The OpenSearch Dashboards Assistant data summary feature uses large language models (LLMs) to help you generate summaries for data stored in OpenSearch indexes. This tool provides an efficient way to gain insights from large datasets, making it easier to understand and act on the information contained in your OpenSearch indexes.

Configuration

To configure the data summary feature, use the following steps.

Prerequisite

Before using the data summary feature, enable query enhancements in OpenSearch Dashboards as follows:

  1. On the top menu bar, go to Management > Dashboards Management.
  2. In the left navigation pane, select Advanced settings.
  3. On the settings page, toggle Enable query enhancements to On.

Step 1: Enable the data summary feature

To enable the data summary feature, configure the following opensearch_dashboards.yml setting:

  1. queryEnhancements.queryAssist.summary.enabled: true

copy

Step 2: Create a data summary agent

To orchestrate data summarization, create a data summary agent. To create an agent, send a POST /_plugins/_flow_framework/workflow?provision=true request and provide the agent template as a payload:

Request

  1. POST /_plugins/_flow_framework/workflow?provision=true
  2. {
  3. "name": "Query Assist Agent",
  4. "description": "Create a Query Assist Agent using Claude on BedRock",
  5. "use_case": "REGISTER_AGENT",
  6. "version": {
  7. "template": "1.0.0",
  8. "compatibility": ["2.13.0", "3.0.0"]
  9. },
  10. "workflows": {
  11. "provision": {
  12. "user_params": {},
  13. "nodes": [
  14. {
  15. "id": "create_claude_connector",
  16. "type": "create_connector",
  17. "previous_node_inputs": {},
  18. "user_inputs": {
  19. "version": "1",
  20. "name": "Claude instant runtime Connector",
  21. "protocol": "aws_sigv4",
  22. "description": "The connector to BedRock service for Claude model",
  23. "actions": [
  24. {
  25. "headers": {
  26. "x-amz-content-sha256": "required",
  27. "content-type": "application/json"
  28. },
  29. "method": "POST",
  30. "request_body": "{\"prompt\":\"${parameters.prompt}\", \"max_tokens_to_sample\":${parameters.max_tokens_to_sample}, \"temperature\":${parameters.temperature}, \"anthropic_version\":\"${parameters.anthropic_version}\" }",
  31. "action_type": "predict",
  32. "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/anthropic.claude-instant-v1/invoke"
  33. }
  34. ],
  35. "credential": {
  36. "access_key": "<YOUR_ACCESS_KEY>",
  37. "secret_key": "<YOUR_SECRET_KEY>",
  38. "session_token": "<YOUR_SESSION_TOKEN>"
  39. },
  40. "parameters": {
  41. "region": "us-west-2",
  42. "endpoint": "bedrock-runtime.us-west-2.amazonaws.com",
  43. "content_type": "application/json",
  44. "auth": "Sig_V4",
  45. "max_tokens_to_sample": "8000",
  46. "service_name": "bedrock",
  47. "temperature": "0.0001",
  48. "response_filter": "$.completion",
  49. "anthropic_version": "bedrock-2023-05-31"
  50. }
  51. }
  52. },
  53. {
  54. "id": "register_claude_model",
  55. "type": "register_remote_model",
  56. "previous_node_inputs": {
  57. "create_claude_connector": "connector_id"
  58. },
  59. "user_inputs": {
  60. "description": "Claude model",
  61. "deploy": true,
  62. "name": "claude-instant",
  63. "guardrails": {
  64. "type": "local_regex",
  65. "input_guardrail": {
  66. "stop_words": [
  67. {
  68. "index_name": "words0",
  69. "source_fields": ["title"]
  70. }
  71. ],
  72. "regex": ["regex1", "regex2"]
  73. },
  74. "output_guardrail": {
  75. "stop_words": [
  76. {
  77. "index_name": "words0",
  78. "source_fields": ["title"]
  79. }
  80. ],
  81. "regex": ["regex1", "regex2"]
  82. }
  83. }
  84. }
  85. },
  86. {
  87. "id": "TransferQuestionToPPLAndExecuteTool",
  88. "type": "create_tool",
  89. "previous_node_inputs": {
  90. "register_claude_model": "model_id"
  91. },
  92. "user_inputs": {
  93. "type": "PPLTool",
  94. "name": "TransferQuestionToPPLAndExecuteTool",
  95. "description": "Use this tool to transfer natural language to generate PPL and execute PPL to query inside. Use this tool after you know the index name, otherwise, call IndexRoutingTool first. The input parameters are: {index:IndexName, question:UserQuestion}",
  96. "parameters": {
  97. "response_filter": "$.completion",
  98. "execute": false
  99. },
  100. "include_output_in_agent_response": true
  101. }
  102. },
  103. {
  104. "id": "summarize_success_tool",
  105. "type": "create_tool",
  106. "previous_node_inputs": {
  107. "register_claude_model": "model_id"
  108. },
  109. "user_inputs": {
  110. "type": "MLModelTool",
  111. "Name": "SummarizeSuccessTool",
  112. "description": "Use this tool to summarize a PPL success response in query assist",
  113. "parameters": {
  114. "prompt": "\n\nHuman: You will be given a search response, summarize it as a concise paragraph while considering the following:\nUser's question on index '${parameters.index}': ${parameters.question}\nPPL (Piped Processing Language) query used: ${parameters.query}\n\nGive some documents to support your point.\nNote that the output could be truncated, summarize what you see. Don't mention about total items returned and don't mention about the fact that output is truncated if you see 'Output is too long, truncated' in the response.\n\nSkip the introduction; go straight into the summarization.\n\nUse the following pieces of context to answer the users question.\nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n${parameters.response}\n\nAssistant:",
  115. "response_filter": "$.completion"
  116. }
  117. }
  118. },
  119. {
  120. "id": "summarize_error_tool",
  121. "type": "create_tool",
  122. "previous_node_inputs": {
  123. "register_claude_model": "model_id"
  124. },
  125. "user_inputs": {
  126. "type": "MLModelTool",
  127. "name": "SummarizeErrorTool",
  128. "description": "Use this tool to summarize a PPL error response in query assist",
  129. "include_output_in_agent_response": true,
  130. "parameters": {
  131. "prompt": "\n\nHuman: You will be given an API response with errors, summarize it as a concise paragraph. Do not try to answer the user's question.\nIf the error cannot be fixed, eg. no such field or function not supported, then give suggestions to rephrase the question.\nIt is imperative that you must not give suggestions on how to fix the error or alternative PPL query, or answers to the question.\n\nConsider the following:\nUser's question on index '${parameters.index}': ${parameters.question}\nPPL (Piped Processing Language) query used: ${parameters.query}\n\nSkip the introduction; go straight into the summarization.\n\nUse the following pieces of context to answer the users question.\nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n${parameters.response}\n\nAssistant:",
  132. "response_filter": "$.completion"
  133. }
  134. }
  135. },
  136. {
  137. "id": "suggestions_tool",
  138. "type": "create_tool",
  139. "previous_node_inputs": {
  140. "register_claude_model": "model_id"
  141. },
  142. "user_inputs": {
  143. "type": "MLModelTool",
  144. "name": "SuggestionsTool",
  145. "description": "Use this tool to generate possible questions for an index in query assist",
  146. "include_output_in_agent_response": true,
  147. "parameters": {
  148. "prompt": "\n\nHuman: OpenSearch index: ${parameters.index}\n\nRecommend 2 or 3 possible questions on this index given the fields below. Only give the questions, do not give descriptions of questions and do not give PPL queries.\n\nThe format for a field is\n```\n- field_name: field_type (sample field value)\n```\n\nFields:\n${parameters.fields}\n\nPut each question in a <question> tag.\n\nAssistant:",
  149. "response_filter": "$.completion"
  150. }
  151. }
  152. },
  153. {
  154. "id": "ppl_agent",
  155. "type": "register_agent",
  156. "previous_node_inputs": {
  157. "TransferQuestionToPPLAndExecuteTool": "tools"
  158. },
  159. "user_inputs": {
  160. "parameters": {},
  161. "app_type": "query_assist",
  162. "name": "PPL agent",
  163. "description": "this is the PPL agent",
  164. "type": "flow"
  165. }
  166. }
  167. ]
  168. }
  169. }
  170. }

copy

For sample agent templates, see Flow Framework sample templates. Note the agent ID; you’ll use it in the following step.

Step 3: Create a root agent

Next, create a root agent for the data summary agent created in the previous step:

  1. POST /.plugins-ml-config/_doc/os_data2summary
  2. {
  3. "type": "os_root_agent",
  4. "configuration": {
  5. "agent_id": "<DATA_SUMMARY_AGENT_ID>"
  6. }
  7. }

copy

This example demonstrates a system index. In security-enabled domains, only superadmins have permissions to execute this code. For information about making superadmin calls, see System indexes. For access permissions, contact your system administrator.

Step 4: Test the agent

You can verify that the data summary agent was created successfully by calling the agent with an example payload:

  1. POST /_plugins/_ml/agents/<DATA_SUMMARY_AGENT_ID>/_execute
  2. {
  3. "parameters": {
  4. "sample_data":"'[{\"_index\":\"90943e30-9a47-11e8-b64d-95841ca0b247\",\"_source\":{\"referer\":\"http://twitter.com/success/gemini-9a\",\"request\":\"/beats/metricbeat/metricbeat-6.3.2-amd64.deb\",\"agent\":\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)\",\"extension\":\"deb\",\"memory\":null,\"ip\":\"239.67.210.53\",\"index\":\"opensearch_dashboards_sample_data_logs\",\"message\":\"239.67.210.53 - - [2018-08-30T15:29:01.686Z] \\\"GET /beats/metricbeat/metricbeat-6.3.2-amd64.deb HTTP/1.1\\\" 404 2633 \\\"-\\\" \\\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)\\\"\",\"url\":\"https://artifacts.opensearch.org/downloads/beats/metricbeat/metricbeat-6.3.2-amd64.deb\",\"tags\":\"success\",\"geo\":{\"srcdest\":\"CN:PL\",\"src\":\"CN\",\"coordinates\":{\"lat\":44.91167028,\"lon\":-108.4455092},\"dest\":\"PL\"},\"utc_time\":\"2024-09-05 15:29:01.686\",\"bytes\":2633,\"machine\":{\"os\":\"win xp\",\"ram\":21474836480},\"response\":\"404\",\"clientip\":\"239.67.210.53\",\"host\":\"artifacts.opensearch.org\",\"event\":{\"dataset\":\"sample_web_logs\"},\"phpmemory\":null,\"timestamp\":\"2024-09-05 15:29:01.686\"}}]'",
  5. "sample_count":1,
  6. "total_count":383,
  7. "question":"Are there any errors in my logs?",
  8. "ppl":"source=opensearch_dashboards_sample_data_logs| where QUERY_STRING(['response'], '4* OR 5*')"}
  9. }

copy

Generating a data summary

You can generate a data summary by calling the /api/assistant/data2summary API endpoint. The sample_count, total_count, question, and ppl parameters are optional:

  1. POST /api/assistant/data2summary
  2. {
  3. "sample_data":"'[{\"_index\":\"90943e30-9a47-11e8-b64d-95841ca0b247\",\"_source\":{\"referer\":\"http://twitter.com/success/gemini-9a\",\"request\":\"/beats/metricbeat/metricbeat-6.3.2-amd64.deb\",\"agent\":\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)\",\"extension\":\"deb\",\"memory\":null,\"ip\":\"239.67.210.53\",\"index\":\"opensearch_dashboards_sample_data_logs\",\"message\":\"239.67.210.53 - - [2018-08-30T15:29:01.686Z] \\\"GET /beats/metricbeat/metricbeat-6.3.2-amd64.deb HTTP/1.1\\\" 404 2633 \\\"-\\\" \\\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)\\\"\",\"url\":\"https://artifacts.opensearch.org/downloads/beats/metricbeat/metricbeat-6.3.2-amd64.deb\",\"tags\":\"success\",\"geo\":{\"srcdest\":\"CN:PL\",\"src\":\"CN\",\"coordinates\":{\"lat\":44.91167028,\"lon\":-108.4455092},\"dest\":\"PL\"},\"utc_time\":\"2024-09-05 15:29:01.686\",\"bytes\":2633,\"machine\":{\"os\":\"win xp\",\"ram\":21474836480},\"response\":\"404\",\"clientip\":\"239.67.210.53\",\"host\":\"artifacts.opensearch.org\",\"event\":{\"dataset\":\"sample_web_logs\"},\"phpmemory\":null,\"timestamp\":\"2024-09-05 15:29:01.686\"}}]'",
  4. "sample_count":1,
  5. "total_count":383,
  6. "question":"Are there any errors in my logs?",
  7. "ppl":"source=opensearch_dashboards_sample_data_logs| where QUERY_STRING(['response'], '4* OR 5*')"
  8. }

copy

The following table describes the Assistant Data Summary API parameters.

ParameterRequired/OptionalDescription
sample_dataRequiredA sample of data returned by the specified query and used as input for summarization.
questionOptionalThe user’s natural language question about the data, which guides the summary generation.
pplOptionalThe Piped Processing Language (PPL) query used to retrieve data; in query assistance, this is generated by the LLM using the user’s natural language question.
sample_countOptionalThe number of entries included in sample_data.
total_countOptionalThe total number of entries in the full query result set.

Viewing data summaries in OpenSearch Dashboards

To view alert insights in OpenSearch Dashboards, use the following steps:

  1. On the top menu bar, go to OpenSearch Dashboards > Discover.

  2. From the query language dropdown list, select PPL. You will see the generated data summary after the query text, as shown in the following image.

    data summary