> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.

# Custom widgets

> Describe a chart, table, or KPI to Ollie and add it to a dashboard as a live widget.

A custom widget shows what no built-in widget covers. To build one, describe it to [Ollie](/docs/opik/ollie). Ollie writes a read-only query over your workspace's traces, spans, threads, feedback scores, experiments, and datasets, draws the result in the chat, and adds it to a [dashboard](/docs/opik/tracing/dashboards/dashboards) as a widget. The widget re-runs its query whenever the dashboard loads, so it stays live.

> **Note**
>
> Custom widgets are available on Opik Cloud, where Ollie is available. Ollie's queries are read-only and limited to
> the workspace you are in.

## What you can ask for

Ollie isn't limited to a fixed list of chart types. Say what to measure, how to break it down, and how it should look.

| You want                     | Example prompt                                                             |
| ---------------------------- | -------------------------------------------------------------------------- |
| A chart over time            | *"Average trace duration per day, one line per tag."*                      |
| A breakdown                  | *"Total tokens by model as a bar chart, sorted from highest to lowest."*   |
| A table                      | *"A table of the 10 slowest tool spans with their name and duration."*     |
| A KPI                        | *"Total estimated cost, with the change from the previous period."*        |
| Experiment results           | *"Average hallucination score per experiment on the support-bot dataset."* |
| Several charts in one widget | *"Cost by provider next to error rate by provider."*                       |

Style requests work too:

* *"Use green for passed and red for failed."*
* *"Add a dashed line at the 2 second target."*
* *"Highlight rows with an error in red."*

A few things to know before you ask:

* **Tables** have sortable headers, resizable columns, and paging.
* **KPIs** show one headline number and, by default, its change from the previous period of the same length.
* **Widgets can be interactive:** tabs, toggles, sorting, filtering, and expandable details all work inside a widget.
* **Widgets can't link out or load external content.** A widget can't open a page or load images from the internet. If you ask for links, Ollie shows the URL as text.

## Add a widget

#### Open Ollie from the dashboard

Start from the dashboard the widget belongs on, so Ollie can add it there in one click:

* Click **Add widget** in a section header and choose **Ask Ollie**.
* In an empty section, click the **Ask Ollie** card.
* In the **Add widget** dialog, click **Ask Ollie** next to **Need a custom widget?**.

Ollie opens in the sidebar and asks what the widget should show. You can also open Ollie from any other page and ask for a chart; you then pick the dashboard when you add it.

![The Add widget menu of an empty section, with Pick a chart and Ask Ollie](/docs/opik/_fern-files/_img/d8d88b9d6903081d954e5d25326a74254a8ab203e8b3dda2fc8582738ee6ba19.webp)

On a built-in dashboard such as **Project overview**, which can't be edited, Ollie adds the widget to a new or existing dashboard of the project instead.

#### Describe the widget

Say what to measure, how to break it down, and which period to cover. Ollie writes the query, runs it, and draws the result in the chat.

Reply in the chat to refine it: *"make it a line chart"*, *"group by model instead"*, *"use a dashed line for the target"*. Ollie draws it again.

#### Add it to a dashboard

Under the drawing, click **Add to “Dashboard name”** to add it to the dashboard you started from. **Add to different dashboard** (or **Add to dashboard…** when you started from another page) lists the other dashboards it can go on and lets you create a new one. You can also ask in the chat: *"add it to the Latency dashboard"*.

The widget lands in the section you started from, and an open dashboard reloads to show it. The widget on the dashboard is the same drawing you saw in the chat.

## How a custom widget works

![A project dashboard with two custom widgets: a line chart of weekly rates with a dashed target line, and a stacked bar chart of daily cost by user](/docs/opik/_fern-files/_img/9dba0469c14987de53f374bb80771273a98efe482d783a710e220aeeb58bb9c7.webp)

* **Badge and freshness:** the title carries an owl badge, **Created with Ollie**. The header shows when the data was last computed, with a refresh icon next to it.
* **Date range:** on project dashboards and Multi-project dashboards the widget follows the dashboard's [date range](/docs/opik/tracing/dashboards/dashboards#date-range), so changing the range changes the widget. Experiments dashboards have no date range, so the widget shows whatever period its query covers.
* **Theme:** the widget follows the light or dark theme of Opik.
* **Size:** Ollie picks a size that fits the content. Drag the widget's edge to resize it, down to one column by one row.
* **Saved table settings:** when you sort a table or resize its columns on a dashboard you can edit, Opik saves those settings with the widget, so everyone who opens the dashboard sees the same table. On a read-only dashboard your changes last until you leave the page.
* **Read-only data:** the widget's query is read-only, scoped to your workspace, and only Ollie can create or change it.

## Widget menu

Open the **...** menu in the widget header. The menu is hidden on read-only dashboards.

| Action              | What it does                                                                             |
| ------------------- | ---------------------------------------------------------------------------------------- |
| **Edit in Ollie**   | Opens Ollie with the widget so you can describe a change. Shown when Ollie is available. |
| **Duplicate**       | Adds a copy of the widget to the same section.                                           |
| **Move to section** | Moves the widget to another section. Shown when the dashboard has more than one section. |
| **Refresh**         | Runs the widget's query again.                                                           |
| **Version history** | Lists the versions of the widget and lets you switch to another one.                     |
| **Remove**          | Deletes the widget from the dashboard, after you confirm.                                |

![The menu of a custom widget, with Edit in Ollie, Duplicate, Refresh, Version history, and Remove](/docs/opik/_fern-files/_img/89d261f28d9e117ee2650b1ba33f04b58c7b92a15bc9eb698367d08954d45929.webp)

## Edit a widget

1. Open the widget's **...** menu and click **Edit in Ollie**.
2. Ollie opens with the current widget at the top of the chat, marked **On the dashboard now**. Describe what to change, for example *"show it as a line chart"* or *"group by provider instead of model"*.
3. Under the new drawing, click **Save changes**. The widget is updated in place and keeps its position and size.

Each saved edit creates a new version of the widget. Nothing is overwritten, so you can always go back.

## Version history

To see earlier versions of a widget, open its **...** menu and hover **Version history**. Each entry shows the version number, when it was created, and who created it. A check mark shows the version the widget displays now. The list holds the 100 most recent versions.

![The Version history submenu of a custom widget, with a check mark next to the version the widget shows](/docs/opik/_fern-files/_img/7475776d108ff726c15caf3e23fe7797a41f4241435f2713fb77c57a549ca896.webp)

To switch, click a version and confirm with **Switch version**. Every version stays in the history, so you can switch back the same way. Switching versions, like saving an edit, resets the widget's saved table sort and column widths.

## Troubleshooting

When a widget can't show its content, it shows a message instead.

| Message                             | Why                                                                                                           | What to do                                                                      |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| **No data for the selected period** | The query returned no rows for the current date range                                                         | Widen the date range, or ask Ollie to loosen the filters                        |
| **No access to this view**          | You don't have permission to see custom widgets                                                               | Ask a workspace admin for access                                                |
| **View not found**                  | The view behind the widget no longer exists                                                                   | Ask Ollie to create the widget again, then remove the old one                   |
| **Data not found**                  | The query behind the widget no longer exists                                                                  | Ask Ollie to create the widget again, then remove the old one                   |
| **Data is masked**                  | Sensitive data is masked for your account in this workspace, and the result of a custom query can't be masked | Ask a workspace admin for access to the original data                           |
| **Charts unavailable**              | Custom charts are turned off for this workspace                                                               | Ask a workspace admin to turn them on                                           |
| **Query failed**                    | The query returned an error, shown under the title                                                            | Click **Refresh**. If it fails again, use **Edit in Ollie** and paste the error |
| **View failed to load**             | The version the widget shows could not be loaded                                                              | Reload the page, or switch to another version in **Version history**            |
| **View not supported**              | The widget was made in a way this version of Opik can't display; the message names what isn't supported       | Reload the page. If the message stays, ask Ollie to draw the widget again       |

## Charts made before this update

Ollie used to add charts as **Ollie chart** widgets. If you have some on your dashboards:

* **They keep working.** An existing Ollie chart widget shows its data and follows the date range as before.
* **They switch when you edit them.** Click **Edit in Ollie**, describe the change, and click **Save changes**. The widget is replaced in place by the new kind, which has a version history.

## Next steps

* Read [Dashboards](/docs/opik/tracing/dashboards/dashboards) for sections, the date range, sharing, and the built-in widget types.
* Meet [Ollie](/docs/opik/ollie), the assistant that builds these widgets and helps you debug the traces behind them.
* Configure [alerts](/docs/opik/production/alerts/alerts) to get notified when a metric crosses a threshold.