---
title: "Monitoring"
description: "Engine metrics in Observability, free and automatic, built-in dashboards, Insights on top statements and waits, and engine logs you can export."
---

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

# Monitoring

Every database sends its engine metrics to its project in [Observability](/observability), **free and
automatically**: there's nothing to install or turn on, and they aren't billed or counted against
Observability's limits. They arrive every 30 seconds, in the project's `production` environment, with
the database's ID as the `database` label.

## Dashboards

The database's **Monitoring** tab in the console shows a built-in dashboard for its engine:
connections, transactions or queries, cache, locks, replication, storage, vacuum or InnoDB, and
statements. **Duplicate as dashboard** saves a copy you can edit, as an ordinary
[dashboard](/observability/dashboards). Viewing it needs `obs.metrics.query`.

## Metrics

Metrics come from the widely used `postgres_exporter` and `mysqld_exporter` collectors, with their
names as PromQL shows them. They carry the labels `database` and `role`. Take the maximum over
`role`, for example `max(sum by (role) (…))`, so a query keeps working through failovers.

| Engine | Examples |
| --- | --- |
| PostgreSQL | `pg_stat_activity_count`, `pg_settings_max_connections`, `pg_locks_count`, `pg_replication_lag_seconds`, `pg_database_size_bytes`, `pg_stat_database_xact_commit_total`, `pg_stat_database_xact_rollback_total`, `pg_stat_database_blks_hit_total`, `pg_stat_database_blks_read_total`, `pg_stat_database_deadlocks_total`, `pg_stat_database_temp_bytes_total`, `pg_stat_user_tables_n_dead_tup` |
| Percona Server, MariaDB | `mysql_global_status_threads_connected`, `mysql_global_status_threads_running`, `mysql_global_variables_max_connections`, `mysql_global_status_questions_total`, `mysql_global_status_commands_total`, `mysql_global_status_slow_queries_total`, `mysql_global_status_innodb_row_ops_total`, `mysql_global_status_innodb_buffer_pool_read_requests`, `mysql_global_status_innodb_buffer_pool_reads`, `mysql_global_status_innodb_row_lock_waits`, `mysql_global_status_innodb_deadlocks`, `mysql_binlog_size_bytes` |

```promql
# Connections to one database
max(sum by (role) (pg_stat_activity_count{database="dbi_4k2m9x0a7qpe"}))

# Buffer cache hit ratio over 5 minutes
max(
  sum by (role) (rate(pg_stat_database_blks_hit_total{database="dbi_4k2m9x0a7qpe"}[5m]))
  / (sum by (role) (rate(pg_stat_database_blks_hit_total{database="dbi_4k2m9x0a7qpe"}[5m]))
   + sum by (role) (rate(pg_stat_database_blks_read_total{database="dbi_4k2m9x0a7qpe"}[5m])))
)
```

`pg_stat_user_tables_*` cover the `postgres` database.

## Insights

The database's **Insights** tab shows its top statements by time and by calls, and what sessions
waited on, over the last 24 hours. It's built from:

| Metric | Labels | Meaning |
| --- | --- | --- |
| `db_digest_seconds_total` | `digest` | Time spent running the statement |
| `db_digest_calls_total` | `digest` | Times the statement ran |
| `db_wait_seconds_total` | `event` | Time sessions waited, by wait event |

Each statement's normalized text, with no literal values, is a log record in Obs with the service
`ezgh.databases`, the resource attribute `database`, and record attributes `digest` and `text`.

## Logs

Engine logs are off until you choose which to export. Exported logs go to the project's Observability
logs and are billed as log ingest.

| Log | Holds |
| --- | --- |
| `error` | The engine's error log. |
| `slow` | Statements slower than `log_min_duration_statement` (PostgreSQL) or `long_query_time` (Percona Server, MariaDB), 1 second unless you set it. |
| `audit` | Schema, user, role and privilege changes, and on Percona Server and MariaDB, connections. On PostgreSQL, connections go to the `error` log while `log_connections` is on. |

```sh
ezgh databases update dbi_4k2m9x0a7qpe --log-export error --log-export slow
ezgh databases update dbi_4k2m9x0a7qpe --no-log-exports
```

In the API, it's `logExports`, for example `["error", "slow"]`. A change applies with no
interruption.

## Events

A database's events list its failovers and recoveries, maintenance, blue/green switchovers and
failures, backups, and full storage, newest first:

```sh
ezgh databases events dbi_4k2m9x0a7qpe
```

Source: https://docs.ezghcloud.com/databases/monitoring/index.mdx
