> ## 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 Grafana user need for dashboards that read ClickHouse system tables?

> Create a role for Grafana monitoring dashboards: SELECT on the system tables the panels read, plus SHOW privileges so that those tables do not come back empty.

Grafana dashboards that monitor ClickHouse query tables of the `system` database. They do not need the `default` user. Create a role that has `SELECT` on the system tables the panels read, add the `SHOW` privileges that make the rows of those tables visible, and grant the role to a dedicated user.

## Create the role and the user

The role below covers the system tables read by the `ClickHouse - Cluster Analysis`, `ClickHouse - Data Analysis` and `ClickHouse - Query Analysis` dashboards that are bundled with the [ClickHouse data source plugin for Grafana](https://github.com/grafana/clickhouse-datasource/tree/main/src/dashboards):

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

GRANT SELECT ON system.clusters TO grafana_monitoring;
GRANT SELECT ON system.databases TO grafana_monitoring;
GRANT SELECT ON system.tables TO grafana_monitoring;
GRANT SELECT ON system.columns TO grafana_monitoring;
GRANT SELECT ON system.parts TO grafana_monitoring;
GRANT SELECT ON system.detached_parts TO grafana_monitoring;
GRANT SELECT ON system.merges TO grafana_monitoring;
GRANT SELECT ON system.mutations TO grafana_monitoring;
GRANT SELECT ON system.replicas TO grafana_monitoring;
GRANT SELECT ON system.dictionaries TO grafana_monitoring;
GRANT SELECT ON system.disks TO grafana_monitoring;
GRANT SELECT ON system.query_log TO grafana_monitoring;

GRANT SHOW ON *.* TO grafana_monitoring;

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

GRANT grafana_monitoring TO grafana;
```

Use the `grafana` user in the [data source configuration](https://clickhouse.com/docs/integrations/connectors/data-visualization/grafana.md).

To adapt the list to your dashboards, search the SQL of their panels for `system.` and grant `SELECT` on every table you find. If a panel fails with an `ACCESS_DENIED` error, the message names the missing grant, for example:

```text theme={null}
Code: 497. DB::Exception: grafana: Not enough privileges. To execute this query, it's necessary to have the grant SELECT ON system.merges. (ACCESS_DENIED)
```

The plugin also bundles the `Advanced ClickHouse Monitoring Dashboard`. Its panels read the metric log tables through the [`merge`](https://clickhouse.com/docs/reference/functions/table-functions/merge) table function, and its `Cloud overview` panels query all replicas with `clusterAllReplicas`. For this dashboard, add:

```sql theme={null}
GRANT SELECT ON system.metric_log* TO grafana_monitoring;
GRANT SELECT ON system.asynchronous_metric_log* TO grafana_monitoring;
GRANT REMOTE ON *.* TO grafana_monitoring;
```

The `REMOTE` grant is needed by any panel that uses the `cluster` or `clusterAllReplicas` table function. For the same grants applied to the dashboard built into ClickHouse, see [Which grants does a user need to use the built-in advanced dashboard?](https://clickhouse.com/docs/resources/support-center/knowledge-base/security/grants-for-advanced-dashboard.md).

`system.query_log` contains the text of the queries of all users. Leave it out of the role if the people who use the dashboards must not see them.

## Why the `SHOW` privileges are needed

`SELECT` on a system table is not enough for the tables that describe databases, tables, columns and dictionaries. These tables return only the rows about objects that the user is allowed to see, so without `SHOW` privileges the panels are empty and no error is reported. In the role above this affects:

| System table | Rows are visible with |
| - | - |
| `system.databases` | `SHOW DATABASES` |
| `system.tables`, `system.parts`, `system.detached_parts`, `system.merges`, `system.mutations`, `system.replicas` | `SHOW TABLES` |
| `system.columns` | `SHOW COLUMNS` |
| `system.dictionaries` | `SHOW DICTIONARIES` |

`GRANT SHOW ON *.*` grants these four privileges for all databases. It exposes the names and the structure of the objects, not their data: with this role, a `SELECT` from a table outside the `system` database is still refused. To limit what the dashboards show, grant `SHOW` on selected databases, for example `GRANT SHOW ON db1.* TO grafana_monitoring`.

`system.clusters`, `system.disks` and `system.query_log` are not filtered this way. For details and the list of other filtered tables, see [Why is `system.parts` empty for a user that has `SELECT` on it?](https://clickhouse.com/docs/resources/support-center/knowledge-base/security/system-tables-empty-after-grant-select).

## Settings that the plugin changes

The role makes the user read-only through its privileges, and such a user can still change query settings. That matters because, as the [Grafana integration guide](https://clickhouse.com/docs/integrations/connectors/data-visualization/grafana.md#2-making-a-read-only-user) explains, the user must be able to modify the `max_execution_time` setting.

If you additionally restrict the user with `readonly = 1`, settings cannot be changed any more, so allow this one explicitly:

```sql theme={null}
ALTER USER grafana SETTINGS readonly = 1, max_execution_time CHANGEABLE_IN_READONLY;
```

## Related documentation

* [ClickHouse data source plugin for Grafana](https://clickhouse.com/docs/integrations/connectors/data-visualization/grafana.md)
* [`GRANT`: the `SHOW` privileges](https://clickhouse.com/docs/reference/statements/grant#show)
* [Constraints on settings](https://clickhouse.com/docs/concepts/features/configuration/settings/constraints-on-settings.md)
* [How do I create a read-only user or role?](https://clickhouse.com/docs/resources/support-center/knowledge-base/security/create-read-only-user.md)
