|
| 1 | +# Monitoring |
| 2 | + |
| 3 | +This directory enables monitoring of your CloudNativePG clusters using the official |
| 4 | +[CloudNativePG Grafana Dashboard](https://github.com/cloudnative-pg/grafana-dashboards). |
| 5 | +The included script installs both the [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator) |
| 6 | +and the [Grafana Operator](https://github.com/grafana/grafana-operator), |
| 7 | +and deploys the dashboard on top of your existing playground environment. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Setup |
| 12 | + |
| 13 | +To install monitoring components for the environment you previously created (by |
| 14 | +default consisting of two regions: `eu` and `us`), simply run: |
| 15 | + |
| 16 | +```bash |
| 17 | +./setup.sh |
| 18 | +``` |
| 19 | + |
| 20 | +You may also specify one or more region names to match a customised setup: |
| 21 | + |
| 22 | +```bash |
| 23 | +# Monitoring setup for clusters named 'it' and 'de' |
| 24 | +./setup.sh it de |
| 25 | + |
| 26 | +# Monitoring setup for a single-region environment |
| 27 | +./setup.sh local |
| 28 | +``` |
| 29 | + |
| 30 | +The script will automatically deploy Prometheus, Grafana, and the CloudNativePG dashboard in each region provided. |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Accessing the Dashboard |
| 35 | + |
| 36 | +Once installation completes, you can access Grafana via port forwarding. |
| 37 | +The `setup.sh` script prints the exact commands needed. |
| 38 | +For the default two-region environment, they look similar to: |
| 39 | + |
| 40 | +```bash |
| 41 | +kubectl port-forward service/grafana-service 3000:3000 -n grafana --context kind-k8s-eu |
| 42 | +kubectl port-forward service/grafana-service 3001:3000 -n grafana --context kind-k8s-us |
| 43 | +``` |
| 44 | + |
| 45 | +After forwarding the port, open your browser at: |
| 46 | + |
| 47 | +``` |
| 48 | +http://localhost:3000 |
| 49 | +``` |
| 50 | + |
| 51 | +Log in using: |
| 52 | + |
| 53 | +- **Username:** `admin` |
| 54 | +- **Password:** `admin` |
| 55 | + |
| 56 | +Grafana will prompt you to choose a new password at first login. |
| 57 | + |
| 58 | + |
| 59 | +You can find the dashboard under `Home > Dashboards > grafana > CloudNativePG`. |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +## PodMonitor |
| 64 | + |
| 65 | +To enable Prometheus to scrape metrics from your PostgreSQL pods, you must |
| 66 | +create a `PodMonitor` resource as described in the |
| 67 | +[documentation](https://cloudnative-pg.io/documentation/current/monitoring/#creating-a-podmonitor). |
| 68 | + |
0 commit comments