← 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 .sh preview

scripts/mysql_healthcheck.sh#!/usr/bin/env bash # ============================================================================= # mysql_healthcheck.sh -- quick MySQL/MariaDB health probe for cron, load # balancers, or a pre-deploy gate. One line per check; non-zero exit on failure. # # Credentials: pass them through a my.cnf-style defaults file so nothing secret # is on the command line or in this script. Point to it with MYSQL_DEFAULTS_FILE # (defaults to ~/.my.cnf). Example file (chmod 600): # [client] # user = monitor # password = ... # host = db03.example.com # # Usage: # MYSQL_DEFAULTS_FILE=/etc/healthcheck/.my.cnf ./mysql_healthcheck.sh # ./mysql_healthcheck.sh --max-conn-pct 90 --min-cache 0.95 # # Exit codes: 0 = healthy, 1 = a check failed, 2 = cannot connect. # ============================================================================= set -o errexit set -o nounset set -o pipefail MAX_CONN_PCT=85 MIN_CACHE_RATIO="0.95" DEFAULTS_FILE="${MYSQL_DEFAULTS_FILE:-$HOME/.my.cnf}" FAILURES=0 usage() { cat <<'USAGE' Usage: mysql_healthcheck.sh [--max-conn-pct N] [--min-cache R] Credentials via a defaults file (MYSQL_DEFAULTS_FILE, default ~/.my.cnf). USAGE } while [ "$#" -gt 0 ]; do case "$1" in --max-conn-pct) MAX_CONN_PCT="${2:-}"; shift 2 ;; --min-cache) MIN_CACHE_RATIO="${2:-}"; shift 2 ;; -h|--help) usage; exit 0 ;;
Buy Now — $39 Back to Products