> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Elastic Agent Builder

> Pull Elastic Agent Builder conversation traces into Openlayer for evaluation, monitoring, and alerting

![Elastic hero](https://mintcdn.com/openlayer-44/wnQ5GOSmAIjIbLk_/images/integrations/elastic_hero.png?fit=max\&auto=format\&n=wnQ5GOSmAIjIbLk_\&q=85\&s=4be9c6ed144f3b5bad866dde2483e6b3)

Openlayer connects to
[Elastic Agent Builder](https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder) and
imports the conversations people have with your agents. Every conversation round — the user's
question, the model calls it triggered, and the tools it ran — becomes an Openlayer trace you can
inspect, evaluate, and alert on, with no SDK, proxy, or change to your agents.

Agent Builder is managed by Elastic, so there is no service of your own to instrument and no
exporter to point at Openlayer. Elastic writes Agent Builder's traces into data streams in your own
Elasticsearch cluster, and Openlayer reads them from there — which is why you connect a deployment
rather than sending anything to us.

> [!NOTE]
>
> All access is **read-only**. Openlayer never writes to your Elastic
> deployment, never runs an agent, and never changes anyone's privileges there.
> The API key you create only needs to read one index pattern and list your
> agents.

> [!NOTE]
>
> This page is for agents you build **in Elastic Agent Builder**. If you want to
> send traces from your own application — one you instrument yourself — use the
> [OpenTelemetry](https://docs.openlayer.com/integrations/opentelemetry.md) integration instead. The two are
> independent.

## How it works

Once connected, Openlayer:

1. **Finds your agents** — lists them from the Agent Builder catalog
   (`GET /api/agent_builder/agents`) and merges in any agent id seen on a trace, so agents that have
   been deleted from the catalog but still have history are not lost.
2. **Reads the trace data streams** — searches `traces-agent_builder.otel-*` for spans belonging to
   the agents you enabled.
3. **Groups spans into conversation rounds** — all spans sharing a `trace_id` are one round, which
   becomes one Openlayer trace.
4. **Maps Elastic's OTel spans onto Openlayer steps** — reusing the same OpenTelemetry GenAI parser
   that every other Openlayer OTel source goes through, so Agent Builder traces behave like any
   other trace once ingested.
5. **Keeps pulling on a schedule** — every 15, 30, or 60 minutes, resuming from a durable cursor so
   nothing is dropped and nothing is ingested twice.

## Prerequisites

* An Elastic deployment running Agent Builder, with **trace collection enabled** (see below).
* An Elasticsearch **API key** with the two privileges in
  [The minimum Elastic role](#the-minimum-elastic-role).
* The **Admin** role in your Openlayer workspace. Connecting, disconnecting, and enabling agents are
  all admin-only actions.

### Enable trace collection in Elastic

Agent Builder does not record traces until an administrator turns collection on.

1. In Kibana, open **Stack Management → GenAI Settings**.
2. Enable **Collect conversation traces** for Agent Builder.
3. Have at least one conversation with an agent — the data stream is created on first write.

Until a conversation has been recorded, the index pattern does not exist. Openlayer reports this as
`missing_data_streams` rather than treating it as a bad credential, so you can tell "not set up yet"
apart from "wrong key".

### The minimum Elastic role

Openlayer needs exactly two privileges: read the trace streams, and list the agents.

```json Verified least-privilege role theme={null}
{
  "read-only-role": {
    "cluster": [],
    "indices": [
      {
        "names": ["traces-agent_builder.otel-*"],
        "privileges": ["read"],
        "allow_restricted_indices": false
      }
    ],
    "applications": [
      {
        "application": "kibana-.kibana",
        "privileges": ["feature_agentBuilder.read"],
        "resources": ["space:default"]
      }
    ],
    "run_as": [],
    "metadata": {},
    "transient_metadata": { "enabled": true }
  }
}
```

Send that as the body of `PUT /_security/role/read-only-role`, then create an API key restricted to
it. Repeat the `applications` block for each additional Kibana space you want to ingest.

> [!NOTE]
>
> This role has been verified end to end against a live Elastic Cloud
> deployment. It is genuinely minimal: it grants **no cluster privileges at
> all** — a key with this role gets `403` on `GET /`, and the connector never
> needs `cluster:monitor/main`. `view_index_metadata` is **not** required
> either; it only helps Openlayer enumerate data streams by name.

Two details are easy to get wrong:

* **`feature_agentBuilder.read` is the privilege that unlocks the Agent Builder API.**
  `feature_aiAssistant.read` looks like the right one and is not — it returns `403` on
  `GET /api/agent_builder/agents`.
* **The `application` value is literally `kibana-.kibana`**, not your deployment name.

Anyone holding this key can read whatever content Elastic has been configured to store on those
traces. Scope the index pattern to specific space streams if you do not want all-spaces access.

## Setup guide

### Step 1: Open the integration

In Openlayer, go to **Workspace settings → Integrations** and choose **Elastic Agent Builder**.

### Step 2: Create the API key

In Kibana, create an API key restricted to the role above
(**Stack Management → API keys**, or `POST /_security/api_key`). Copy the encoded key — Openlayer
encrypts it at rest and never returns it again.

### Step 3: Connect

Fill in the **Connect** card:

| Field | What to enter |
| - | - |
| **Deployment URL** | Your Elastic Cloud endpoint. Pasting the **Kibana** URL is fine — see the note below. |
| **API key** | The encoded key from Step 2. |
| **Ingest all Kibana spaces** | On by default. Turn it off to enter a comma-separated list in **Kibana space IDs**. |
| **Automatically enable new agents** | Off by default. When on, agents discovered *after* you enable the toggle start syncing on their own. |

Click **Test connection** before connecting. It distinguishes four failure modes rather than
returning one generic error:

| Error code | What it means |
| - | - |
| `invalid_credentials` | The URL or API key is wrong, or the key was revoked. |
| `missing_privileges` | The key cannot read `traces-agent_builder.otel-*`. |
| `missing_data_streams` | Collection is off, the spaces are wrong, or no conversation exists yet. |
| `unreachable` | The cluster is unreachable from Openlayer. |

> [!NOTE]
>
> You can paste either the Kibana host (`https://<deployment>.kb.<region>.<cloud>.elastic.cloud`) or
> the Elasticsearch host (`*.es.*`). Openlayer stores the Elasticsearch host and rewrites `.kb.`
> to `.es.` for you — then rewrites it back to `.kb.` when it calls the Kibana Agent Builder API,
> because the agent catalog only lives on the Kibana host. Both legs use the same API key.

### Step 4: Enable the agents you want

Discovered agents appear in the **Agents** card with a **Synced traces** count. Nothing is ingested
until you enable an agent.

Enabling an agent creates an Openlayer project and inference pipeline for it, or maps it onto ones
you already have. Agent enablement is independent of space scoping: narrowing the spaces changes
*which streams* are read, not *which agents* are on.

> [!NOTE]
>
> Turning **Automatically enable new agents** off later preserves your current
> selections — it does not re-enable agents you deliberately disabled, and it
> does not disable ones already running.

### Step 5: Confirm traces are arriving

Use **Sync now** in the **Settings** card rather than waiting for the next scheduled run. Traces
appear on the **project** created for the agent, not on the integration page.

## Privacy and content capture

By default, **Elastic records structural metadata only**: model, provider, latency, token usage,
status, and hashed or anonymized identifiers. Prompt and response content, system instructions, tool
arguments, tool results, real names, and real IDs are each a **separate administrator opt-in** in
Elastic's GenAI settings.

The **Overview** card tells you which case you are in, under **Content capture**:

* **Prompt and tool content observed** — Openlayer has seen real content on your traces.
* **Metadata only** — Elastic has not sent prompt, response, system, or tool content. Latency, token
  usage, model, and status still sync.

> [!WARNING]
>
> Metadata-only traces ingest cleanly and are useful for latency, cost, and
> error monitoring — but **content-dependent evaluations will not work**.
> Groundedness, hallucination, answer relevance, and anything else that reads
> the prompt or response has no input to read. Turn on the content opt-ins in
> Elastic before relying on those tests.

Anonymized custom names arrive as `custom`, and identifiers may be stable hashes rather than the
real agent ids. That is Elastic's anonymization, not Openlayer's — it is what was written to the
index.

## Sync, backfill, and deduplication

| Behavior | Value |
| - | - |
| Sync frequency | Every 15, 30, or 60 minutes |
| First sync looks back | 7 days |
| Manual backfill limit | 90 days |
| In-flight holdback | 60 seconds |
| Per-tick ceiling | 100 traces per agent |

Openlayer tracks a durable cursor of `(@timestamp, span.id)` per agent. That pair — rather than a
timestamp alone — is what makes overlapping windows safe: spans written in the same millisecond are
still ordered, so a retried window re-reads the same spans and skips the ones already written.

Two consequences worth knowing:

* **A failed tick does not lose data.** The cursor only advances past traces that were written
  successfully, so the next run retries the same window rather than skipping it.
* **A conversation still in progress is left alone.** Rounds whose newest span is less than 60
  seconds old are held back, so Openlayer does not ingest half a trace and then never revisit it.

If an agent has more than 100 new traces in one tick, the remainder is picked up on the next run.

## Settings

The **Settings** card controls ongoing sync:

* **Periodic sync** — pause or resume scheduled pulls. Pausing preserves everything already
  ingested.
* **Sync frequency** — 15, 30, or 60 minutes.
* **Sync now** — run a sync immediately instead of waiting.

### Backfilling history

Use the **Backfill** action in an agent's row menu to import history from before you connected,
capped at 90 days. Backfill is deduplicated against what you already have, so it is safe to run over
a window you have already synced.

### Disconnecting

**Disconnect** stops all syncing and removes the stored credential. **Traces already ingested are
preserved** — disconnecting is not a delete. Reconnecting later resumes from a fresh cursor.

## Troubleshooting

**No agents listed.** The Kibana leg is failing or the space is wrong. Confirm the key has
`feature_agentBuilder.read` on the target space, then **Sync now**. A `403` mentioning
`agentBuilder:read` almost always means the role has `feature_aiAssistant.read` instead.

**`missing_privileges`.** Grant `read` on `traces-agent_builder.otel-*`. Note that
`view_index_metadata` is optional — its absence is not the cause.

**`missing_data_streams`.** Either trace collection is off in **Stack Management → GenAI Settings**,
no conversation has been recorded yet, or the spaces you scoped to have no traces. The index pattern
does not exist until the first conversation is written.

**Traces arrive but the request row is empty.** Elastic is in metadata-only mode — check **Content
capture** on the **Overview** card and enable the content opt-ins in Elastic.

**Provider reads `elastic` instead of the real vendor.** When an agent calls a model through
Elastic's Inference service, Elastic reports itself as the provider and names the model with its own
connector id, such as `anthropic-claude-4.5-sonnet`. Openlayer rewrites the documented connector
prefixes — Anthropic, OpenAI, Azure OpenAI, Bedrock, Gemini, Cohere, Mistral, and DeepSeek — back to
the real vendor and model. A custom connector id outside that set passes through unchanged, which
also leaves cost estimation without a model id to price against.

**A sync errored and then recovered.** Expected. The cursor does not advance past a failed write, so
the next tick retries the same window. No gap, no duplicates.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.