← Back to all products

Database Monitoring Setup

$39

Monitoring configs for pg_stat, MySQL Performance Schema, MongoDB Atlas, with Grafana dashboards and alert rules.

📁 22 files
JSONMarkdownYAMLShellSQLPostgreSQLGrafanaPrometheus

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 22 files

database-monitoring-setup/ ├── LICENSE ├── README.md ├── dashboards/ │ ├── mysql-overview.json │ └── postgresql-overview.json ├── docs/ │ ├── alerting-runbook.md │ └── key-metrics-guide.md ├── exporters/ │ ├── mysqld-exporter-setup.md │ ├── postgres-exporter-queries.yaml │ └── postgres-exporter-setup.md ├── free-sample.zip ├── guide/ │ ├── 01_who-this-is-for.md │ ├── 02_quick-start.md │ └── 03_faq.md ├── index.html ├── monitoring/ │ ├── alert.rules.yml │ ├── alertmanager.yml │ └── prometheus.yml ├── scripts/ │ ├── mysql_healthcheck.sh │ ├── pg_healthcheck.sh │ └── replication_check.sh └── sql/ ├── mysql-metric-queries.sql └── postgres-metric-queries.sql

📖 Documentation Preview README excerpt

Database Monitoring Setup

A complete, copy-paste monitoring stack for PostgreSQL and MySQL/MariaDB

built on Prometheus + Grafana + the standard exporters. You get a tuned scrape

config, real PromQL alert rules with severities and runbook links, two Grafana

dashboards (valid JSON, importable as-is), exporter setup guides with

least-privilege roles, health-check scripts, and the raw SQL behind every metric.

Most "set up monitoring" tutorials stop at "install the exporter and import a

community dashboard." This kit goes the rest of the way: which metrics actually

predict outages, what thresholds to alert on, and what to do when each alert

fires.


Who this is for

  • Engineers/DBAs who run their own PostgreSQL or MySQL and want real visibility.
  • Teams adding databases to an existing Prometheus/Grafana setup.
  • Anyone tired of finding out the database was at 99% connections after the

outage.

You should be comfortable running an exporter, editing Prometheus/Alertmanager

config, and importing a Grafana dashboard. No paid tooling required.


Contents


database-monitoring-setup/
├── README.md
├── LICENSE
├── monitoring/
│   ├── prometheus.yml                # scrape config: postgres/mysql/node exporters
│   ├── alert.rules.yml               # PromQL alerts + recording rules, severities
│   └── alertmanager.yml              # severity-based routing, grouping, inhibition
├── dashboards/
│   ├── postgresql-overview.json      # importable Grafana dashboard (8 panels)
│   └── mysql-overview.json           # importable Grafana dashboard (8 panels)
├── exporters/
│   ├── postgres-exporter-setup.md    # least-privilege role + systemd + verify
│   ├── postgres-exporter-queries.yaml# custom queries: lag, activity, locks, bloat
│   └── mysqld-exporter-setup.md       # least-privilege user + collectors + verify
├── scripts/
│   ├── pg_healthcheck.sh             # one-shot PostgreSQL health probe
│   ├── mysql_healthcheck.sh          # one-shot MySQL health probe
│   └── replication_check.sh          # replica lag / replication-health gate
├── sql/
│   ├── postgres-metric-queries.sql   # cache ratio, lag, bloat, locks, slow queries
│   └── mysql-metric-queries.sql      # buffer pool, lag, locks, digests
└── docs/
    ├── key-metrics-guide.md          # what to watch and why; good/alert values
    └── alerting-runbook.md           # one response section per alert

Prerequisites

... continues with setup instructions, usage examples, and more.

📄 Code Sample .yml preview

monitoring/alert.rules.yml # ============================================================================= # alert.rules.yml -- Prometheus alerting + recording rules for databases # ============================================================================= # Real PromQL against postgres_exporter and mysqld_exporter. Thresholds are # sensible defaults -- tune `expr` and `for` to your workload, then validate: # promtool check rules alert.rules.yml # # Each alert carries a `severity` label (page | ticket | info) so Alertmanager # can route it (see monitoring/alertmanager.yml), and a `runbook` annotation # pointing at docs/alerting-runbook.md. # ============================================================================= groups: # =========================================================================== # Recording rules -- precompute expensive ratios once so dashboards and alerts # share the same definition and stay cheap. # =========================================================================== - name: database.recording interval: 30s rules: # PostgreSQL cache hit ratio per instance (0..1). blks_hit / (hit+read). - record: instance:pg_cache_hit_ratio:ratio expr: | sum by (instance) (rate(pg_stat_database_blks_hit[5m])) / clamp_min( sum by (instance) (rate(pg_stat_database_blks_hit[5m])) + sum by (instance) (rate(pg_stat_database_blks_read[5m])), 1 ) # PostgreSQL connection utilization (used / max), 0..1. - record: instance:pg_connections_used:ratio expr: | sum by (instance) (pg_stat_database_numbackends) / clamp_min(max by (instance) (pg_settings_max_connections), 1) # MySQL InnoDB buffer pool hit ratio (0..1). - record: instance:mysql_buffer_pool_hit_ratio:ratio expr: | 1 - ( rate(mysql_global_status_innodb_buffer_pool_reads[5m]) / clamp_min(rate(mysql_global_status_innodb_buffer_pool_read_requests[5m]), 1) ) # MySQL connection utilization (used / max), 0..1. - record: instance:mysql_connections_used:ratio expr: | # ... 168 more lines ...
Buy Now — $39 Back to Products