Visualization tool

Introduced 2.12

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, see the associated GitHub issue.

Use the VisualizationTool to find visualizations relevant to a question.

Step 1: Register a flow agent that will run the VisualizationTool

A flow agent runs a sequence of tools in order and returns the last tool’s output. To create a flow agent, send the following register agent request:

  1. POST /_plugins/_ml/agents/_register
  2. {
  3. "name": "Test_Agent_For_Visualization_tool",
  4. "type": "flow",
  5. "description": "this is a test agent for the VisuailizationTool",
  6. "tools": [
  7. {
  8. "type": "VisualizationTool",
  9. "name": "DemoVisualizationTool",
  10. "parameters": {
  11. "index": ".kibana",
  12. "input": "${parameters.question}",
  13. "size": 3
  14. }
  15. }
  16. ]
  17. }

copy

For parameter descriptions, see Register parameters.

OpenSearch responds with an agent ID:

  1. {
  2. "agent_id": "9X7xWI0Bpc3sThaJdY9i"
  3. }

Step 2: Run the agent

Before you run the agent, make sure that you add the sample OpenSearch Dashboards Sample eCommerce orders dataset. To learn more, see Adding sample data.

Then, run the agent by sending the following request:

  1. POST /_plugins/_ml/agents/9X7xWI0Bpc3sThaJdY9i/_execute
  2. {
  3. "parameters": {
  4. "question": "what's the revenue for today?"
  5. }
  6. }

copy

By default, OpenSearch returns the top three matching visualizations. You can use the size parameter to specify the number of results returned. The output is returned in CSV format. The output includes two columns: Title (the visualization title displayed in OpenSearch Dashboards) and Id (a unique ID for this visualization):

  1. {
  2. "inference_results": [
  3. {
  4. "output": [
  5. {
  6. "name": "response",
  7. "result": """Title,Id
  8. [eCommerce] Total Revenue,10f1a240-b891-11e8-a6d9-e546fe2bba5f
  9. """
  10. }
  11. ]
  12. }
  13. ]
  14. }

Register parameters

The following table lists all tool parameters that are available when registering an agent.

ParameterTypeRequired/OptionalDescription
inputStringRequiredThe user input used to match visualizations.
indexStringOptionalThe index to search. Default is .kibana (the system index for OpenSearch Dashboards data).
sizeIntegerOptionalThe number of visualizations to return. Default is 3.

Execute parameters

The following table lists all tool parameters that are available when running the agent.

ParameterTypeRequired/OptionalDescription
questionStringRequiredThe natural language question to send to the LLM.