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

# Observability and Analytics: Monitor Your AI Agents

> Monitor agent performance, trace workflow runs, and analyze usage in Layest. Real-time dashboards, logs, and metrics to optimize AI ops.

Layest gives you full visibility into how your agents behave, how your workflows execute, and where your resources are being spent. Observability in Layest means you can track every run from start to finish, diagnose failures in seconds, and continuously improve your AI operations with data-backed insights — all without leaving the platform.

## Dashboard Overview

The **Observability** dashboard is your central hub for monitoring agent health at a glance. Open it by navigating to **Observability** in the left sidebar. The top of the page surfaces four key metrics refreshed in real time:

<CardGroup cols={2}>
  <Card title="Runs Completed" icon="circle-check">
    Total workflow executions that finished successfully within the selected time window.
  </Card>

  <Card title="Success Rate" icon="chart-line">
    Percentage of runs that completed without errors, helping you spot reliability regressions quickly.
  </Card>

  <Card title="Avg. Response Time" icon="clock">
    Mean end-to-end latency across all runs, broken down by agent or workflow when you drill in.
  </Card>

  <Card title="Token Usage" icon="bolt">
    Aggregated input and output tokens consumed by all model calls, mapped to cost estimates per plan.
  </Card>
</CardGroup>

Use the **date range picker** in the top-right corner to filter all dashboard data by the last 1 hour, 24 hours, 7 days, 30 days, or a custom range.

## Workflow Run Logs

Every time a workflow executes, Layest records a structured run log you can inspect at any time.

To access run logs:

1. Go to **Observability → Runs** in the left sidebar.
2. Use the search bar to filter by agent name, status (`success`, `error`, `running`), or trigger type.
3. Click any row to open the **Run Detail** panel.

Each run log entry includes:

* **Run ID** — a unique identifier you can reference in support requests or API queries.
* **Trigger** — what started the run (manual, scheduled, webhook, or API call).
* **Status** — current or final state with a color-coded badge.
* **Duration** — total wall-clock time from trigger to completion.
* **Input / Output** — the exact payload passed into the workflow and the final response returned.
* **Step breakdown** — each step's name, duration, and result.

## Trace View

The trace view gives you a step-by-step timeline of a single workflow execution, making it easy to pinpoint exactly where time is spent or where errors originate.

Open a trace by clicking **View Trace** inside any run detail panel. The trace renders as a waterfall diagram:

* Each **horizontal bar** represents one workflow step (LLM call, tool execution, data lookup, conditional branch).
* Bar **width** is proportional to that step's duration.
* Bars are **color-coded**: green for success, red for error, yellow for warning or retry.
* Click any bar to expand the **step detail drawer**, which shows the raw input sent to that step, the output or error returned, the model or integration used, and token counts for LLM steps.

<Note>
  Traces are stored at full resolution for 7 days on the Free plan, 30 days on Pro, and 90 days on Enterprise. Aggregated metrics (without raw payloads) are retained for 12 months on all paid plans.
</Note>

## Error Tracking and Alerting

Layest automatically captures every unhandled error in a workflow and surfaces it in **Observability → Errors**. The error list shows:

* **Error type** and message
* Which workflow step and agent triggered it
* First seen / last seen timestamps
* Occurrence count over the selected period

### Setting Up Alerts

To receive notifications when errors exceed a threshold:

<Steps>
  <Step title="Open Alert Rules">
    Navigate to **Observability → Alerts** and click **New Alert Rule**.
  </Step>

  <Step title="Choose a Metric">
    Select the metric to watch: error rate, run failure count, average latency, or token spend.
  </Step>

  <Step title="Set a Threshold">
    Enter the value that triggers the alert (for example, error rate above 5% over a 15-minute window).
  </Step>

  <Step title="Choose a Notification Channel">
    Add an email address, a Slack webhook URL, or a third-party incident management integration key.
  </Step>

  <Step title="Save and Activate">
    Click **Save Rule**. The rule becomes active immediately and will fire whenever the threshold is breached.
  </Step>
</Steps>

## Usage Analytics

The **Analytics** tab provides a broader view of how your workspace consumes Layest resources over time.

<CardGroup cols={2}>
  <Card title="Agent Usage Over Time" icon="chart-bar">
    A time-series chart showing run volume per agent, letting you identify which agents are most active and spot unusual spikes.
  </Card>

  <Card title="Top Agents" icon="trophy">
    A ranked list of agents by run count, success rate, and average latency so you can focus optimization where it matters most.
  </Card>

  <Card title="Model Usage Breakdown" icon="microchip">
    Per-model token consumption and estimated cost, segmented by agent and date range.
  </Card>

  <Card title="Trigger Distribution" icon="sliders">
    A breakdown of how runs are initiated — manual, scheduled, webhook, or API — to understand how teams and systems rely on your agents.
  </Card>
</CardGroup>

## Exporting Analytics Data

You can export any analytics view as a CSV for further analysis in external tools.

1. Navigate to the analytics view you want to export (runs list, model usage, error list, etc.).
2. Apply any filters you need (date range, agent, status).
3. Click the **Export** button in the top-right corner of the table.
4. Select **CSV** or **JSON** as the output format.
5. The file downloads immediately to your browser.

For automated exports, use the Layest API to query run and metric data programmatically and pipe it into your data warehouse or BI tool.

<Tip>
  Connect Layest to your observability stack by forwarding run events to a webhook. Go to **Settings → Webhooks** and subscribe to the `run.completed` and `run.failed` event types to stream data in real time.
</Tip>
