---
title: "Visualize a Service in Managed Grafana"
description: "Chart Managed PostgreSQL data, logs and metrics in Exoscale Managed Grafana with a read-only user, and avoid the datasource integration."
url: https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/visualize-in-grafana/
product: "PostgreSQL"
section: product
last_updated: 2026-11-10
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Visualize a Service in Managed Grafana

Connect an Exoscale Managed Grafana service to a Managed PostgreSQL service and to the services that hold its telemetry, then build dashboards on them. Grafana reads three kinds of sources here: the PostgreSQL service itself for SQL queries, a Managed OpenSearch service for its logs, and a Managed Thanos service for its metrics.

Add the data sources by hand, as shown below, rather than through the datasource integration. The
integration connects to PostgreSQL as `avnadmin`, so Grafana users can modify the database. The
reasons are in [The datasource integration](#the-datasource-integration).

## Prerequisites

- A running [Managed Grafana](https://community.exoscale.com/product/dbaas/service-specific/grafana/index.md) service. Sign in as
  `avnadmin`, the user that can add data sources. Read the address and the password with:

  ```bash
  exo dbaas show GRAFANA_SERVICE -z ZONE --uri
  ```

  ```bash
  exo dbaas user reveal-secrets GRAFANA_SERVICE avnadmin -z ZONE
  ```

- For logs, a logs integration to Managed OpenSearch. See
  [Send logs to Managed OpenSearch](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/send-logs-to-opensearch/index.md).
- For metrics, a metrics integration to Managed Thanos. See
  [Send metrics to Managed Thanos](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/send-metrics-to-thanos/index.md).

The IP filters of the PostgreSQL, OpenSearch and Thanos services do not need to list the Grafana
service: Grafana reaches them while their filters allow only your own address.

To add a data source in Grafana, click **Connections** in the left-side menu, then
**Add new connection**, search for the data source type, select it and click
**Add new data source**. Fill in the fields listed below, then click **Save & test**.

## Add PostgreSQL with a Read-Only User

Grafana sends whatever SQL a panel or an Explore query contains. Give it a user that can only read.

1. Create the user:

   ```bash
   exo dbaas user create SERVICE_NAME grafana_reader -z ZONE
   ```

2. Connected as `avnadmin` with
   [psql](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/connect-with-psql/index.md), grant it read
   access to the `public` schema, including the tables created later:

   ```sql
   CREATE ROLE readonly NOLOGIN;
   GRANT CONNECT ON DATABASE defaultdb TO readonly;
   GRANT USAGE ON SCHEMA public TO readonly;
   GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
   ALTER DEFAULT PRIVILEGES FOR ROLE avnadmin IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
   GRANT readonly TO grafana_reader;
   ```

   For other schemas and databases, see
   [Create read-only users](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/create-read-only-users/index.md).

3. Read the host, the port and the password:

   ```bash
   exo api get-dbaas-service-pg SERVICE_NAME -z ZONE -q '"uri-params".[host, port]'
   ```

   ```bash
   exo dbaas user reveal-secrets SERVICE_NAME grafana_reader -z ZONE
   ```

4. Add a **PostgreSQL** data source:

   | Field | Value |
   | --- | --- |
   | Host URL | `HOST:PORT` |
   | Database name | `defaultdb` |
   | Username | `grafana_reader` |
   | Password | The password of `grafana_reader` |
   | TLS/SSL Mode | `require` |

Parameters:

- `SERVICE_NAME`: name of the Managed PostgreSQL service.
- `ZONE`: zone the service runs in, for example `ch-gva-2`.
- `HOST`, `PORT`: the two values returned by the `get-dbaas-service-pg` command.

**Save & test** answers `Database Connection OK`. Through this data source `SELECT` queries return
data, an `INSERT` fails with `permission denied for table` and a `DROP TABLE` fails with
`must be owner of table`.

If you created extensions such as `pg_stat_statements` in the `public` schema, the
`GRANT SELECT ON ALL TABLES` statement prints a `no privileges were granted` warning for their
views. The warning is harmless.

> [!NOTE]
> After a change to the Grafana service settings, each connection that Grafana had open left a
> `LOG:  SSL error: unexpected eof while reading` line in the PostgreSQL log. It does not mean that
> a query failed.

## Add the Logs from OpenSearch

1. Read the host, the port and the password of the OpenSearch service:

   ```bash
   exo api get-dbaas-service-opensearch OPENSEARCH_SERVICE -z ZONE -q '"uri-params".[host, port]'
   ```

   ```bash
   exo dbaas user reveal-secrets OPENSEARCH_SERVICE avnadmin -z ZONE
   ```

2. Add an **OpenSearch** data source:

   | Field | Value |
   | --- | --- |
   | URL | `https://HOST:PORT` |
   | Basic auth | On, with User `avnadmin` and its password |
   | Index name | `[INDEX_PREFIX-]YYYY-MM-DD` |
   | Pattern | `Daily` |
   | Time field name | `timestamp` |
   | Version | Click **Get Version and Save** |
   | Message field name | `MESSAGE` |

Parameters:

- `OPENSEARCH_SERVICE`: name of the Managed OpenSearch service.
- `INDEX_PREFIX`: the index prefix set on the logs integration, for example `my-postgresql`.

> [!IMPORTANT]
> Change **Time field name**. Its default, `@timestamp`, does not exist in the indices that the logs
> integration writes; the time field there is `timestamp`. With `@timestamp`, **Save & test** warns
> `No field named @timestamp found`.

With **Index name** set to `INDEX_PREFIX-*` and no pattern, queries work but **Save & test**
reports `Index not found`. The daily pattern above passes the test with
`Index OK. Time field name OK.`

`avnadmin` can read and write every index of the OpenSearch service. For a narrower account, see
[OpenSearch access control](https://community.exoscale.com/product/dbaas/service-specific/opensearch/how-to/acls/index.md).

## Add the Metrics from Thanos

Add a **Prometheus** data source with the query endpoint of the Thanos service:

| Field | Value |
| --- | --- |
| Prometheus server URL | `https://THANOS_HOST:THANOS_PORT`, from the `query-frontend-uri` of the Thanos service |
| Basic authentication | User `avnadmin` and its password |

[Send metrics to Managed Thanos](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/send-metrics-to-thanos/index.md#query-the-metrics)
shows how to read the address and the password, and lists the metrics and their labels.
[Integrate Grafana](https://community.exoscale.com/product/dbaas/service-specific/thanos/how-to/integ-grafana/index.md) shows the same
form with screenshots. **Save & test** answers `Successfully queried the Prometheus API.`

## The Datasource Integration

A `datasource` integration from Grafana to a PostgreSQL or OpenSearch service creates the data
source for you:

```bash
echo '{"integration-type":"datasource","source-service":"GRAFANA_SERVICE","dest-service":"SERVICE_NAME"}' | \
  exo api create-dbaas-integration -z ZONE
```

It adds a data source named `aiven-pg-SERVICE_NAME` or `aiven-opensearch-SERVICE_NAME`. Those data
sources have three problems:

> [!WARNING]
> **The PostgreSQL data source connects as `avnadmin`.** Any Grafana user who can edit a panel or
> use Explore can change the database through it: `CREATE TABLE`, `INSERT` and `DROP TABLE` sent
> through Grafana all succeed.

- **Your changes do not last.** Pointing the data source at a read-only user works until the next
  change to the Grafana service settings: within seconds of such a change, the data source is back
  to `avnadmin`. Data sources added by hand are left untouched.
- **The OpenSearch data source does not work as created.** **Save & test** reports
  `No version set`, queries fail with `An error occurred within the plugin`, and its time field is
  `@timestamp`.

Thanos cannot be a target: the API refuses the integration with
`Service integration datasource is not available for this service` (HTTP 403).

To remove a datasource integration, delete it with
`exo api delete-dbaas-integration INTEGRATION_ID -z ZONE`. Grafana drops its data source at the same
time.

## Related Pages

- [Send logs to Managed OpenSearch](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/send-logs-to-opensearch/index.md)
- [Send metrics to Managed Thanos](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/send-metrics-to-thanos/index.md)
- [Monitor a Managed PostgreSQL service](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/monitor-your-service/index.md)
- [Create read-only users](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/create-read-only-users/index.md)
- [Managed Grafana](https://community.exoscale.com/product/dbaas/service-specific/grafana/index.md)
- [Grafana PostgreSQL data source](https://grafana.com/docs/grafana/latest/datasources/postgres/configure/) ↗

