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

# Dashboards

> Define dashboards and their widgets in YAML, versioned and reviewed like the rest of your config

A `kind: dashboard` declares a [dashboard](https://docs.roark.ai/documentation/observability/dashboards.md): its window, the filters over every widget, and its widgets top to bottom. A widget is an [analytics query](https://docs.roark.ai/documentation/observability/analytics-api.md) plus a name, a chart type and a size, so a query you tried over the API drops straight into a widget.

```typescript TypeScript theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
import { defineDashboard } from '@roarkanalytics/sdk/lib/config';

const frontdeskHealth = defineDashboard({
  name: 'frontdesk-health',
  displayName: 'Frontdesk health',
  timeRange: { type: 'LAST', value: 30, unit: 'DAYS' },
  filters: [
    { type: 'AGENT_PROPERTY', value: 'frontdesk' }, // an agent by its config name, or its id
    { type: 'MODALITY', value: 'call' },
  ],
  widgets: [
    {
      name: 'Calls',
      display: 'NUMBER',
      size: 'SMALL',
      measures: [{ type: 'CONVERSATION' }],
    },
    {
      name: 'Task completion',
      display: 'LINE',
      size: 'LARGE',
      interval: 'DAY',
      measures: [{ metric: 'task_completion' }],
    },
    {
      name: 'Call outcomes',
      display: 'STACKED_BAR',
      interval: 'WEEK',
      measures: [{ metric: 'call_outcome' }], // a classification: counted and split by value
    },
    {
      name: 'Calls by direction',
      display: 'STACKED_BAR',
      measures: [
        {
          type: 'CONVERSATION',
          breakdown: { type: 'CALL_PROPERTY', property: 'direction' },
        },
      ],
    },
  ],
});
```

```yaml YAML theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
# yaml-language-server: $schema=https://roark.ai/roark-config.schema.json
kind: dashboard
name: frontdesk-health
displayName: Frontdesk health
timeRange: { type: LAST, value: 30, unit: DAYS }
filters:
  - { type: AGENT_PROPERTY, value: frontdesk }   # an agent by its config name, or its id
  - { type: MODALITY, value: call }
widgets:
  - name: Calls
    display: NUMBER
    size: SMALL
    measures:
      - type: CONVERSATION
  - name: Task completion
    display: LINE
    size: LARGE
    interval: DAY
    measures:
      - metric: task_completion
  - name: Call outcomes
    display: STACKED_BAR
    interval: WEEK
    measures:
      - metric: call_outcome      # a classification: counted and split by value
  - name: Calls by direction
    display: STACKED_BAR
    measures:
      - type: CONVERSATION
        breakdown: { type: CALL_PROPERTY, property: direction }
```

***

## Fields

| Field | Required | |
| :- | :- | :- |
| `name` | yes | The config name. |
| `displayName` | no | The title shown in Roark. Defaults to `name`. |
| `description` | no | Free text. |
| `isDefault` | no | Make it the project's default dashboard. Left out, the flag is left as it is. |
| `timeRange` | no | The window every widget reads. A new dashboard defaults to the last 30 days; left out on an existing one, whatever a viewer last picked is kept. Same shapes as an [analytics query](https://docs.roark.ai/documentation/observability/analytics-api.md#time-windows). |
| `filters` | no | Over every widget: `AGENT_PROPERTY`, `CALL_PROPERTY`, `MODALITY`, `DATASET` or `METRIC_VALUE`. Left out, a viewer's filters are kept. See [Filters](#filters). |
| `widgets` | no | Up to 50, top to bottom. |

### Widgets

| Field | Required | |
| :- | :- | :- |
| `name` | yes | The widget's title, unique on the dashboard. It is the widget's identity across applies. |
| `measures` | yes | 1 to 10 [measures](https://docs.roark.ai/documentation/observability/analytics-api.md#measures): `metric: <slug>`, or `type: CONVERSATION` / `type: UPTIME`, each with optional `aggregation`, `percentile`, `breakdown` and `filters`. |
| `display` | no | `LINE` (default), `NUMBER`, `RADAR`, `STACKED_BAR` or `TABLE`. |
| `size` | no | `SMALL`, `MEDIUM` (default), `LARGE` or `EXTRA_LARGE`. |
| `interval` | no | `HOUR`, `DAY` (default), `WEEK` or `MONTH`. Stepped coarser on wide windows. |
| `filters` | no | Applied to every measure in the widget. |
| `comparisonMode` | no | `PREVIOUS_PERIOD` to add the preceding window. |
| `comparisonGroups` | no | 2 to 5 named filter sets compared as separate series. |

### Filters

A filter is `{ type, property, operator, value }`, the same shape as an [analytics filter](https://docs.roark.ai/documentation/observability/analytics-api.md#filters-breakdowns-and-comparisons); `operator` defaults to `EQUALS`. A `CALL_PROPERTY` filter also takes `IS_SET` or `IS_NOT_SET` with no `value`: conversations where the property is set (whatever the value, an empty string included) or missing (never sent, sent as `null`, or removed).

```yaml theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
filters:
  - { type: AGENT_PROPERTY, value: frontdesk }
  - { type: CALL_PROPERTY, property: escalation_reason, operator: IS_NOT_SET }
```

#### Filter by another metric

A `METRIC_VALUE` filter keeps the conversations where another metric came out a certain way, such as refund accuracy only on calls where the task was completed. It works on the dashboard, a widget, a measure and a comparison group. `property` is that metric's slug, resolved the same way as a measure's `metric`, optionally followed by `.AGENT` or `.CUSTOMER` to read one side of a per-participant metric. `operator` and `value` are required, and depend on the metric:

| Metric | Operators | Value |
| :- | :- | :- |
| Boolean | `EQUALS`, `NOT_EQUALS` | `true` or `false` |
| Number, scale, count, offset | `EQUALS`, `NOT_EQUALS`, `GREATER_THAN`, `GREATER_THAN_OR_EQUAL_TO`, `LESS_THAN`, `LESS_THAN_OR_EQUAL_TO` | A number |
| Classification, text | `EQUALS`, `NOT_EQUALS` (ignoring case), `CONTAINS` | A label or text |
| [Threshold](https://docs.roark.ai/documentation/config-as-code/metrics.md#thresholds) | `EQUALS`, `NOT_EQUALS` | `PASSED` or `FAILED`, with no `.AGENT` or `.CUSTOMER` suffix |

A slug that matches no metric, or a value the metric can't compare, fails that dashboard's apply and leaves it as it was. For how the filter matches, see [Filter by another metric](https://docs.roark.ai/documentation/observability/dashboards.md#filter-by-another-metric).

```yaml theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
widgets:
  - name: Refund accuracy when the task was completed
    filters:
      - { type: METRIC_VALUE, property: task_completion, operator: EQUALS, value: 2 } # 2 = Completed
    measures: [{ metric: refund_policy_accuracy }]
  - name: Containment by caller sentiment
    measures: [{ metric: agent_containment }]
    comparisonGroups:
      - name: Negative callers
        filters: [{ type: METRIC_VALUE, property: sentiment_score.CUSTOMER, operator: LESS_THAN_OR_EQUAL_TO, value: 3 }]
      - name: Everyone else
        filters: [{ type: METRIC_VALUE, property: sentiment_score.CUSTOMER, operator: GREATER_THAN, value: 3 }]
  - name: Sentiment on calls that failed the latency check
    filters:
      - { type: METRIC_VALUE, property: latency_under_2s, operator: EQUALS, value: FAILED }
    measures: [{ metric: sentiment_score }]
```

***

## References

* **Metrics** resolve by slug: a [`kind: metric`](https://docs.roark.ai/documentation/config-as-code/metrics) in the same config (applied first), or any metric the project can see, system metrics included.
* **Agents** in an agent filter can be written by their config name; Roark resolves them to ids, the same way other kinds reference agents.

Every widget is checked against what its metric can answer before anything is written. A widget asking for `AVG` of a classification, or naming a metric that doesn't exist, fails that dashboard's apply with the reason, and the dashboard is left exactly as it was.

***

## In Roark

A dashboard created by config shows **Managed by config**. Its title and widgets are read-only in Roark and over the API (edits return `409`): change them in your config and re-apply. Anyone viewing it can still pick a time range and filter it, and an apply only overwrites those when the config declares `timeRange` or `filters`. Duplicating a managed dashboard gives you an editable copy.

A dashboard made in Roark with the same title as a `kind: dashboard` (its `displayName`, or `name`) is adopted on the first apply rather than duplicated, as long as exactly one unmanaged dashboard has that title.

***

## Removing a dashboard

Deleting a dashboard from your config (with prune on, the default) deletes the dashboard and its widgets.


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