﻿---
title: Analyze your data with AI in Discover
description: Ask an AI agent to analyze the full dataset behind your Discover ES|QL query, chart the main finding, and suggest drill-down queries.
url: https://www.elastic.co/docs/explore-analyze/discover/analyze-discover-data-with-ai
products:
  - Elastic Documentation
  - Kibana
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview since 9.5
---

# Analyze your data with AI in Discover
If you want to know what is behind your ES|QL results without writing the aggregation queries yourself, you can ask an AI agent. An agent is an AI assistant that answers questions about your data in a chat. In **Discover**, the agent runs aggregation queries on the full data behind your results, charts the main finding, and suggests follow-up queries. If your query already aggregates the data, for example with `STATS`, the agent works from the rows shown instead and runs at most one extra query. It does this with the [`discover-data-analysis` skill](/docs/explore-analyze/ai-features/agent-builder/builtin-skills-reference#agent-builder-discover-data-analysis-skill), a built-in set of instructions and tools for this task. [Elastic Agent Builder](https://www.elastic.co/docs/explore-analyze/ai-features/elastic-agent-builder) provides the agents and skills.

## Before you begin

- Make sure **Discover** is in ES|QL mode. Classic mode doesn't support this functionality. To switch, refer to [Switch to Discover's ES|QL mode](/docs/explore-analyze/discover/switch-esql-mode#switch-discover-query-mode).
- Make sure Elastic Agent Builder is available for your deployment or project. On Elastic Stack, it requires an Enterprise [subscription](https://www.elastic.co/pricing). On Serverless, it requires the appropriate [project feature tier](/docs/deploy-manage/deploy/elastic-cloud/project-settings#project-features-add-ons). The agent also needs an AI model to answer with. Elastic Cloud Hosted and Serverless include preconfigured models. On other deployments, configure a model first. Refer to [Get started with Elastic Agent Builder](https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/get-started).
- Run a query so results are loaded in the table.


## Start an analysis

1. Select the **AI Agent** button in the Kibana header, or press <kbd>Cmd</kbd> + <kbd>;</kbd> (Mac) or <kbd>Ctrl</kbd> + <kbd>;</kbd> (Windows and Linux), to open the agent chat.
   The agent automatically receives your current query, columns, sample rows, and time range as context.
2. Ask the agent to analyze your data. For example, enter `analyze this data`, or ask a more specific question such as `Which hosts have the most errors?`.
3. Review the agent's findings, the inline visualization, and the suggested drill-down queries. A drill-down query narrows the analysis to one group or value. Each query comes with a copy button. To run one in a new **Discover** tab, ask the agent to open it.

**Result:** The agent answers in the chat with its findings, a chart of the main result, and suggested queries.
After the first answer, keep asking. For example, ask whether two fields are related, how this week compares with last week, or what the values in one column look like.

## How the analysis adapts to your data

When your data matches one of the [context-aware experiences](/docs/explore-analyze/discover/discover-get-started#context-aware-discover), the agent receives guidance for that type of data, so the analysis fits it:
- **Logs**: Groups by `log.level`, `service.name`, `host.name`, and `event.dataset`. It surfaces error and warning frequency and shifts in level distribution.
- **Metrics**: Uses the ES|QL `TS` source command for time series data streams, runs `TS_INFO` first to discover metric names, types, and dimension fields, then aggregates with the right function for each metric type (`RATE` or `SUM` for counters, `AVG`, `MAX`, `MIN`, or `PERCENTILE` for gauges, `PERCENTILE` for histograms).
- **Application performance monitoring (APM) traces**: Focuses on latency percentiles of transaction and span durations, throughput by transaction or span name, and error rate by `event.outcome`.
- **OpenTelemetry (OTel) traces**: Focuses on latency percentiles of `duration`, throughput by service and span kind, and error rate by `status.code`.

If your query doesn't match any of those experiences, the agent infers the analysis strategy from the column names and types in the results instead.

## Next steps

- <applies-to>Elastic Cloud Serverless: Preview</applies-to> <applies-to>Elastic Stack: Planned</applies-to> To see the current documents without leaving the conversation, ask the agent to show them in an interactive **Discover** table. Refer to [Discover tables in chat](https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/agent-builder-discover-tables).


## Related pages

- [AI assistance in the ES|QL editor](/docs/explore-analyze/query-filter/languages/esql-kibana#esql-kibana-ai-assistance)
- [How Discover works](https://www.elastic.co/docs/explore-analyze/discover/discover-get-started)