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

# Which grants does a user need to use the built-in advanced dashboard?

> The built-in /dashboard page runs its queries as the database user you enter. Create a role with SELECT on system.dashboards and the metric log tables instead of sharing the default user.

The built-in [advanced dashboard](https://clickhouse.com/docs/guides/oss/deployment-and-scaling/monitoring/monitoring.md#built-in-advanced-observability-dashboard), the `/dashboard` page of the HTTP interface, runs every query as the database user whose name and password you type into the page. That user does not have to be `default`. It needs `SELECT` on `system.dashboards`, `system.metric_log` and `system.asynchronous_metric_log`.

## Create a role for the dashboard

```sql theme={null}
CREATE ROLE dashboard_viewer;

GRANT SELECT ON system.dashboards TO dashboard_viewer;
GRANT SELECT ON system.metric_log* TO dashboard_viewer;
GRANT SELECT ON system.asynchronous_metric_log* TO dashboard_viewer;

CREATE USER dashboard_user IDENTIFIED WITH sha256_password BY '<password>';

GRANT dashboard_viewer TO dashboard_user;
```

Open the dashboard (for example `http://localhost:8123/dashboard`) and enter `dashboard_user` and its password. On a self-managed cluster, create the role and the user on every server whose dashboard you open, for example with [`ON CLUSTER`](https://clickhouse.com/docs/reference/statements/distributed-ddl).

## What the page reads

The page loads the list of charts from [`system.dashboards`](https://clickhouse.com/docs/reference/system-tables/dashboards) and then runs the query of each chart. In ClickHouse 26.12 every default chart reads from `merge('system', '^metric_log')` or `merge('system', '^asynchronous_metric_log')`.

The [`merge`](https://clickhouse.com/docs/reference/functions/table-functions/merge) table function reads all tables whose names match the pattern and that the user is allowed to see. A matching table that is hidden from the user, because the user has no privilege on it at all, is skipped without an error. A matching table that the user can see but may not read fails the query with `ACCESS_DENIED`. This is why the role uses [wildcard grants](https://clickhouse.com/docs/reference/statements/grant.md#wildcard-grants): after an upgrade that changes the structure of a system log table, the older data stays in a table with a numeric suffix, such as `metric_log_1` (see [Querying multiple versions](https://clickhouse.com/docs/reference/system-tables/overview.md#querying-multiple-versions)). `GRANT SELECT ON system.metric_log*` covers those tables too.

With a grant on `system.metric_log` alone, the result depends on what else the user holds. A user without any other privilege on the `system` database gets charts that show only the data of the current table. A user who can see the older tables, for example through `GRANT SHOW ON *.*` or `GRANT SHOW TABLES ON system.*`, gets an `ACCESS_DENIED` error for every chart.

## Dashboards that query all replicas

`system.dashboards` contains several dashboards, which you can choose on the page. Some of them collect the metrics of all replicas with the [`clusterAllReplicas`](https://clickhouse.com/docs/reference/functions/table-functions/cluster) table function. In ClickHouse 26.12:

```sql theme={null}
SELECT
    dashboard,
    countIf(query LIKE '%clusterAllReplicas%') > 0 AS reads_all_replicas
FROM system.dashboards
GROUP BY dashboard
ORDER BY dashboard;
```

```text theme={null}
   ┌─dashboard────────────────────────┬─reads_all_replicas─┐
1. │ Cloud Memory (host)              │                  1 │
2. │ Cloud overview                   │                  1 │
3. │ Cloud overview (host)            │                  1 │
4. │ Filesystem cache overview        │                  1 │
5. │ Filesystem cache overview (host) │                  1 │
6. │ Memory (host)                    │                  0 │
7. │ Overview                         │                  0 │
8. │ Overview (host)                  │                  0 │
   └──────────────────────────────────┴────────────────────┘
```

`Overview` is the default dashboard of self-managed ClickHouse, and the dashboards whose names start with `Cloud` are written for ClickHouse Cloud. A dashboard that reads through `clusterAllReplicas` also needs the `REMOTE` [source privilege](https://clickhouse.com/docs/reference/statements/grant.md#sources):

```sql theme={null}
GRANT REMOTE ON *.* TO dashboard_viewer;
```

## ClickHouse Cloud

The Advanced dashboard page of the ClickHouse Cloud console is described in [Advanced dashboard in ClickHouse Cloud](https://clickhouse.com/docs/products/cloud/features/monitoring/advanced-dashboard.md). The native advanced dashboard that this page links to asks you to authenticate. Use a database user with the role above, including the `REMOTE` grant, because the `Cloud` dashboards read from all replicas.

## Things to know

* If a chart shows an `ACCESS_DENIED` error, the message names the missing grant. Add that grant to the role.

* Do not set `readonly = 1` for the dashboard user. The page adds the `add_http_cors_header` setting to its requests, and some chart queries have a `SETTINGS` clause. With `readonly = 1` these are refused with an error such as `Cannot modify 'add_http_cors_header' setting in readonly mode`. If you want the extra restriction, use [`readonly = 2`](https://clickhouse.com/docs/concepts/features/configuration/settings/permissions-for-queries#readonly), which allows changing settings:

  ```sql theme={null}
  ALTER USER dashboard_user SETTINGS readonly = 2;
  ```

* The page can also render charts from any other table that has the same columns as `system.dashboards`. For a custom dashboard, grant `SELECT` on that table and on the tables its queries read.

## Related documentation

* [`system.dashboards`](https://clickhouse.com/docs/reference/system-tables/dashboards)
* [`system.metric_log`](https://clickhouse.com/docs/reference/system-tables/metric_log) and [`system.asynchronous_metric_log`](https://clickhouse.com/docs/reference/system-tables/asynchronous_metric_log)
* [`GRANT`](https://clickhouse.com/docs/reference/statements/grant)
