diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b0cdd63 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +helm/pgwatch/test_values.yaml \ No newline at end of file diff --git a/docs/index.yaml b/docs/index.yaml new file mode 100644 index 0000000..cd1d13b --- /dev/null +++ b/docs/index.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +entries: + pgwatch: + - apiVersion: v1 + appVersion: "3.2" + created: "2025-04-17T08:06:39.604311384+02:00" + description: A Helm chart for pgwatch monitoring tools + digest: 114f2f8ac8e1a8cceb5c5062a86e54f9b45c742bfa3b04e9701dd03bc22262b8 + name: pgwatch + urls: + - https://cybertec-postgresql.github.io/pgwatch-charts/pgwatch-3.1.0.tgz + version: 3.1.0 + - apiVersion: v1 + appVersion: "3.2" + created: "2025-04-17T08:06:39.601137999+02:00" + description: A Helm chart for pgwatch monitoring tools + digest: 69410525096ac64bac0f782205d92485e0d57cfc72f2e1d1684933baf3c21100 + name: pgwatch + urls: + - https://cybertec-postgresql.github.io/pgwatch-charts/pgwatch-3.0.1.tgz + version: 3.0.1 +generated: "2025-04-17T08:06:39.588535932+02:00" diff --git a/docs/pgwatch-3.0.1.tgz b/docs/pgwatch-3.0.1.tgz new file mode 100644 index 0000000..fec39ce Binary files /dev/null and b/docs/pgwatch-3.0.1.tgz differ diff --git a/docs/pgwatch-3.1.0.tgz b/docs/pgwatch-3.1.0.tgz new file mode 100644 index 0000000..3d32c6f Binary files /dev/null and b/docs/pgwatch-3.1.0.tgz differ diff --git a/helm/README.md b/helm/README.md index 25bd169..5c5c186 100644 --- a/helm/README.md +++ b/helm/README.md @@ -1,11 +1,58 @@ -# Documentation +[![Documentation](https://img.shields.io/badge/Documentation-pgwat.ch-brightgreen)](https://pgwat.ch) +[![License: MIT](https://img.shields.io/badge/License-BSD_3-green.svg)](https://opensource.org/license/bsd-3-clause) +[![Go Build & Test](https://github.com/cybertec-postgresql/pgwatch/actions/workflows/build.yml/badge.svg)](https://github.com/cybertec-postgresql/pgwatch/actions/workflows/build.yml) +[![Coverage Status](https://coveralls.io/repos/github/cybertec-postgresql/pgwatch/badge.svg?branch=master&service=github)](https://coveralls.io/github/cybertec-postgresql/pgwatch?branch=master) -Key | Default value | Description ----|---|--- -storage | influx | influx or postgres; Defines backend for storing data -postgres_storage.database | pgwatch2_metrics | in case if storage is set to postgres, defines database name -metrics_preset | | -metrics_preset.name | remotedba | name of the default metrics_preset -metrics_preset.description| Metrics used for monitoring of Remote-DBA Databases | Metrics preset description -metrics_preset.metrics | '{"kpi": 120, "wal": 60, "locks": 60, "db_size": 300, "archiver": 60, "backends": 60, "bgwriter": 60, "cpu_load": 60, "db_stats": 60, "settings": 7200, "wal_size": 300, "locks_mode": 60, "index_stats": 900, "replication": 120, "sproc_stats": 180, "table_stats": 300, "wal_receiver": 120, "change_events": 300, "table_io_stats": 600, "sequence_health": 3600, "replication_slots": 120}' | Metrics +# pgWatch-Helm-Charts + +These Helm charts are available for a quick start on Kubernetes and Openshift. +Since the new pgWatch release (3.x), the Helm charts have been developed and tested primarily for Openshift. +The old Helm charts for pgwatch2 are deprecated and no longer maintained. Furthermore, they will be removed in summer 2025. + +## Quick Start +To use the Helm-Charts, you can either patch the repo onto your local system or install and update it directly using the Helm repository. +In either case, please familiarise yourself with the relevant values files before use and create a custom variant to set up pgWatch according to your preferences in your environment. + +### Helm-Repository +```sh +# Add Helm-Repo +helm repo add pgwatch https://cybertec-postgresql.github.io/pgwatch-charts +helm repo update + +# Install helm-Chart +helm install pgwatch pgwatch/pgwatch --values custom-values.yaml + +# Upgrade helm-Chart +helm upgrade pgwatch pgwatch/pgwatch --values custom-values.yaml +``` + +### git clone +```sh +git clone https://github.com/cybertec-postgresql/pgwatch-charts.git +cd pgwatch-chart/helm/pgwatch + + +# Install helm-Chart +helm install pgwatch -n pgwatch -f custom-values.yaml . + +# Upgrade Helm-Chart +helm upgrade pgwatch -n pgwatch -f custom-values.yaml . + +``` + +### Custom Values-file +```sh +// Edit Values File +cp values.yaml custom-values.yaml +vi custom-values.yaml +``` +### Check the Pods +```sh +kubectl get pods -n pgwatch +oc get pods -n pgwatch +``` + +# Contributing + +Feedback, suggestions, problem reports, and pull requests are very much appreciated. diff --git a/helm/pgwatch/Chart.yaml b/helm/pgwatch/Chart.yaml new file mode 100644 index 0000000..6b4f272 --- /dev/null +++ b/helm/pgwatch/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "3.2" +description: A Helm chart for pgwatch monitoring tools +name: pgwatch +version: 3.1.0 diff --git a/helm/pgwatch/README.md b/helm/pgwatch/README.md new file mode 100644 index 0000000..d982378 --- /dev/null +++ b/helm/pgwatch/README.md @@ -0,0 +1,55 @@ +[![Documentation](https://img.shields.io/badge/Documentation-pgwat.ch-brightgreen)](https://pgwat.ch) +[![License: MIT](https://img.shields.io/badge/License-BSD_3-green.svg)](https://opensource.org/license/bsd-3-clause) +[![Go Build & Test](https://github.com/cybertec-postgresql/pgwatch/actions/workflows/build.yml/badge.svg)](https://github.com/cybertec-postgresql/pgwatch/actions/workflows/build.yml) +[![Coverage Status](https://coveralls.io/repos/github/cybertec-postgresql/pgwatch/badge.svg?branch=master&service=github)](https://coveralls.io/github/cybertec-postgresql/pgwatch?branch=master) + + +# pgWatch-Helm-Chart +This Helm chart allows you to set up the pgWatch stack using helm in containers or distributions such as Openshift. +Note: This Helm chart is developed and tested primarily for Openshift. + +## Quick Start +To use the Helm-Charts, you can either patch the repo onto your local system or install and update it directly using the Helm repository. +In either case, please familiarise yourself with the relevant values files before use and create a custom variant to set up pgWatch according to your preferences in your environment. + +### Helm-Repository +```sh +# Add Helm-Repo +helm repo add pgwatch https://cybertec-postgresql.github.io/pgwatch-charts +helm repo update + +# Install helm-Chart +helm install pgwatch pgwatch/pgwatch --values custom-values.yaml + +# Upgrade helm-Chart +helm upgrade pgwatch pgwatch/pgwatch --values custom-values.yaml +``` + +### git clone +```sh +git clone https://github.com/cybertec-postgresql/pgwatch-charts.git +cd pgwatch-chart/helm/pgwatch + + +# Install helm-Chart +helm install pgwatch -n pgwatch -f custom-values.yaml . + +# Upgrade Helm-Chart +helm upgrade pgwatch -n pgwatch -f custom-values.yaml . + +``` + +## customisation +The Helm chart currently supports PostgreSQL and Prometheus as a sink. This can be controlled via the [values](https://github.com/cybertec-postgresql/pgwatch-charts/blob/pgwatch-3-helm-chart/helm/pgwatch/values.yaml) file. +- PostgreSQL + - Use an existing configuration and metric database + - Create a new PostgreSQL-Instance in the same namespace +- Prometheus + - Use an existing Prometheus as Sink (enables Sink-Connect on Port 9188) + - Create a new Prometheus-Instance in the same namespace +- Grafana + - Deploy Grafana with the dashboards for PostgreSQL as a sink + + +## Limitation +Please note that the Grafana dashboard was developed for use with PostgreSQL as a sink. If you decide to use Prometheus as a sink, you will need to build your own dashboards and configure Prometheus as a data source in Grafana yourself. If you want to use your own systems behind Prometheus, you can use Yaml to easily prevent Grafana from being deployed. diff --git a/helm/pgwatch/templates/alertmanager_deployment b/helm/pgwatch/templates/alertmanager_deployment new file mode 100644 index 0000000..4cf83d1 --- /dev/null +++ b/helm/pgwatch/templates/alertmanager_deployment @@ -0,0 +1,77 @@ +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_alertmanager "true" }} +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/name: pgwatch + vendor: opensource.cybertec + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-alertmanager +spec: + selector: + matchLabels: + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-alertmanager + template: + metadata: + creationTimestamp: null + labels: + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-alertmanager + spec: + containers: + - image: {{ .Values.pgwatch.prometheus.new_prometheus.image }} + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /-/healthy + port: 9090 + scheme: HTTP + initialDelaySeconds: 15 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 1 + name: pgwatch-alertmanager + ports: + - containerPort: 9090 + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /-/ready + port: 9090 + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + args: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--storage.tsdb.path=/prometheus" + - "--storage.tsdb.retention.time={{ .Values.pgwatch.prometheus.new_prometheus.settings.retention_days }}d" + volumeMounts: + - mountPath: /etc/prometheus + name: prometheus-cm + - mountPath: /prometheus + name: prometheus-volume + securityContext: {} + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + terminationGracePeriodSeconds: 30 + volumes: + - configMap: + defaultMode: 420 + name: pgwatch-prometheus-cm + name: prometheus-cm + - name: prometheus-volume + persistentVolumeClaim: + claimName: prometheus-pvc + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + strategy: + type: Recreate +{{ end }} diff --git a/helm/pgwatch/templates/grafana-dashboards-basics.yaml b/helm/pgwatch/templates/grafana-dashboards-basics.yaml new file mode 100644 index 0000000..c601102 --- /dev/null +++ b/helm/pgwatch/templates/grafana-dashboards-basics.yaml @@ -0,0 +1,18464 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + application: pgwatch + name: grafana-dashboards-basics + namespace: {{ .Release.Namespace }} +data: + db-overview-developer.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Only \"pg_stat_statements\" extension expected", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Last 5m data", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 0, + "y": 0 + }, + "hideTimeOverride": true, + "id": 1, + "interval": "", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'in_recovery_int')::int\nFROM\n wal\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "5m", + "title": "Instance state", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "PRIMARY", + "value": "0" + }, + { + "op": "=", + "text": "REPLICA", + "value": "1" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Last 5min data", + "editable": true, + "error": false, + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 3, + "y": 0 + }, + "hideTimeOverride": true, + "id": 17, + "interval": "", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'postmaster_uptime_s')::int\nFROM\n wal\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "5m", + "title": "Instance uptime", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Current Transaction Per Second (10m avg) + last 6h history", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 6, + "y": 0 + }, + "hideTimeOverride": true, + "id": 18, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "TPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Queries Per Second based on pg_stat_statements.calls. Last 10m avg. + last 6h history", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 9, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 2, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "QPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as qps\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "QPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Approximate value based on pg_stat_statements total_time / calls. Last 10min avg. + last 6h history", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 12, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 3, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": " ms", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "avg_query_runtime_per_db", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Query runtime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Based on pg_stat_database.numbackends. Last 10m avg + 6h history", + "editable": true, + "error": false, + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 15, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 5, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "10m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg(nb) as \"# Sessions ($agg_interval avg)\"\nfrom (\n select \n (data->>'numbackends')::int8 as nb,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n) x\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "numbackends" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Sessions", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": null, + "description": "", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 18, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 6, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "10m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, '1h'),\n avg( ((tb-tb_lag)*3600) / (etime - lag_etime)) as \"Temp bytes (1h rate)\"\nfrom (\n select \n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere tb >= tb_lag and etime > lag_etime\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temp_bytes" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Temp bytes 1h avg. rate", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Percentage of rows touched by queries that are actually returned to the client. Low numbers (< 10%) for an OLTP workload can hint at missing indexes. Last 10m avg + 6h history.", + "editable": true, + "error": false, + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 21, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 4, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "db_size_change_last_hour", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n 100 * avg((fetched - fetched_lag)::numeric / (returned - returned_lag)) as fetched_vs_returned_pct\nFROM (\n\nSELECT\n time,\n (data->'tup_fetched')::int8 as fetched,\n lag((data->'tup_fetched')::int8) over w as fetched_lag,\n (data->'tup_returned')::int8 as returned,\n lag((data->'tup_returned')::int8) over w as returned_lag\nFROM\n db_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nWINDOW w AS (ORDER BY time)\n) x \nWHERE returned > returned_lag AND fetched >= fetched_lag\nGROUP BY 1\nORDER BY 1\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Tuples fetched vs returned", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 2 + }, + "id": 7, + "interval": "", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "db_stats.mean", + "yaxis": 2 + }, + { + "alias": "DB size", + "yaxis": 2 + }, + { + "alias": "blk_read_time", + "yaxis": 2 + }, + { + "alias": "blk_write_time", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "INSERT", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((ins-ins_lag) * (extract(epoch from '$agg_interval'::interval)) / extract(epoch from time - time_lag)) as \"INSERT\",\n avg((upd-upd_lag) * (extract(epoch from '$agg_interval'::interval)) / extract(epoch from time - time_lag)) as \"UPDATE\",\n avg((del-del_lag) * (extract(epoch from '$agg_interval'::interval)) / extract(epoch from time - time_lag)) as \"DELETE\"\nfrom (\n select \n (data->>'tup_inserted')::int8 as ins, lag((data->>'tup_inserted')::int8) over w as ins_lag,\n (data->>'tup_updated')::int8 as upd, lag((data->>'tup_updated')::int8) over w as upd_lag,\n (data->>'tup_deleted')::int8 as del, lag((data->>'tup_deleted')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere ins >= ins_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Tuple Ins. / Upd. / Del. statistics ($agg_interval rate)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "TX rollback ratio": "#890F02" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 2 + }, + "id": 8, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Shared buffers hit ratio", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag)))*100 as \"Shared buffers hit ratio\",\n avg((roll-roll_lag)::numeric / ((roll-roll_lag) + (comm-comm_lag)))*100 as \"TX rollback ratio\"\nfrom (\n select \n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere (hit > hit_lag or read > read_lag) and (roll > roll_lag or comm > comm_lag)\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Buffer hit ratio + Rollback ratio", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": "105", + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "avg_query_runtime": "#ef843c", + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Approximate value based on pg_stat_statements total_time / calls", + "fill": 1, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 12, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "avg_query_runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(case when c=c_lag then null else (tt-tt_lag)::numeric / (c-c_lag) end) as \"avg_query_runtime\"\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c >= c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. query runtime ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "DB Size": "#2F575E", + "WAL rate": "#0A50A1" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 6 + }, + "height": "", + "id": 10, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "DB Size", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "WAL rate", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "wal", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((wal-wal_lag) / (etime-etime_lag)) as \"WAL rate\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n extract(epoch from time) as etime,\n time, lag(extract(epoch from time)) over w as etime_lag\n from wal\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere wal >= wal_lag and etime > etime_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xlog_location_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "alias": "DB Size", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_size", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(size_b) as \"DB Size\"\nfrom (\n select \n (data->>'size_b')::int8 as size_b,\n time\n from db_size\n where dbname = '$dbname' and $__timeFilter(time)\n) x\ngroup by 1\norder by 1", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "WAL rate + DB size ($agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "/Deadlocks/": "dark-red", + "/Sessions/": "dark-yellow", + "/Temp bytes/": "light-blue" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 10 + }, + "id": 9, + "interval": "5m", + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/Temp bytes/", + "color": "#3274D9", + "yaxis": 2 + }, + { + "alias": "/Deadlocks/", + "color": "#C4162A" + }, + { + "alias": "/Sessions/", + "color": "#E0B400" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "# Sessions", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(nb) as \"# Sessions ($agg_interval avg)\",\n avg(((dl-dl_lag) * extract(epoch from '$agg_interval'::interval)) / (etime - etime_lag)) as \"Deadlocks ($agg_interval rate)\"\nfrom (\n select \n (data->>'numbackends')::int8 as nb,\n (data->>'deadlocks')::int8 as dl, lag((data->>'deadlocks')::int8) over w as dl_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as etime_lag,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere dl >= dl_lag and etime > etime_lag\ngroup by 1\norder by 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "numbackends" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "alias": "Deadlocks (1h rate)", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((tb-tb_lag) / (etime - lag_etime)) as \"Temp bytes ($agg_interval avg)\"\nfrom (\n select \n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere tb >= tb_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Sessions + Deadlocks + Temp bytes", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Transactions per Second / Queries per Second", + "fill": 1, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 10 + }, + "id": 15, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "TPS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "alias": "QPS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TPS / QPS ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "fill": 1, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 16, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "seq_scan", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n sum(seq_scan) as seq_scan\nfrom (\n select\n $__timeGroup(time, $agg_interval),\n table_full_name,\n avg((((scan - scan_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag))) as seq_scan\n from (\n select \n (data->>'seq_scan')::int8 as scan, lag((data->>'seq_scan')::int8) over w as scan_lag,\n time, lag(time) over w as time_lag,\n tag_data->>'table_full_name' as table_full_name\n from table_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and (data->>'table_size_b')::int8 > 10000000\n window w as (partition by tag_data->>'table_full_name' order by time) \n ) x\n where scan >= scan_lag and time > time_lag\n group by 1, 2\n) y\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "seq_scan" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Seq. scans ($agg_interval rate, >10MB tables)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "fill": 1, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 14 + }, + "id": 11, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_lockmode", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "lockmode" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "locks_mode", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n lockmode,\n max(lock_count) as lock_count\nfrom (\n select \n (data->>'count')::int8 as lock_count,\n tag_data->>'lockmode' as lockmode,\n time\n from locks_mode\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data->>'lockmode' LIKE '%Exclusive%'\n) x\ngroup by 1, 2\norder by 1, 2\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "count" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "lockmode", + "operator": "=~", + "value": "/Exclusive/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Exclusive locks ($agg_interval max.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 14, + "links": [], + "mode": "html", + "options": {}, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 19, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "", + "value": "" + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "tags": [], + "text": "5m", + "value": "5m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": true, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1s,1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "DB overview Unprivileged / Developer mode", + "uid": "db-overview-developer", + "version": 1 + } + db-overview-time-lag.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Active + idle in transaction user sessions", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 12, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n coalesce(avg((data->>'active')::int8 + (data->>'idleintransaction')::int8), 0) as active\nfrom backends\n where dbname = '$dbname'\n and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n coalesce(avg(active), 0) as \"active -$lag_interval\"\nfrom (\nselect\n time + '$lag_interval'::interval as time,\n (data->>'active')::int8 + (data->>'idleintransaction')::int8 as active\nfrom backends\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Active sessions", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 8 + }, + "hiddenSeries": false, + "id": 2, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag + r - r_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag + r - r_lag) / extract(epoch from time - time_lag)) as \"TPS-$lag_interval\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TPS", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 16 + }, + "hiddenSeries": false, + "id": 3, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag + r - r_lag) / extract(epoch from time - time_lag)) as \"QPS-$lag_interval\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "QPS", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_stat_statements data", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 24 + }, + "hiddenSeries": false, + "id": 4, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n time,\n avg(avg) as \"avg_query_runtime\"\nfrom (\n\nselect\n$__timeGroup(time, $agg_interval),\nqueryid,\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n tag_data->>'queryid' as queryid,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time)\n and not tag_data->>'query' like '%$2)::int8 as epoch_ns,%' /*trying to not include queries by pgwatch itself*/\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n time,\n avg(avg) as \"avg_query_runtime-$lag_interval\"\nfrom (\n\nselect\n$__timeGroup(time, $agg_interval),\nqueryid,\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n tag_data->>'queryid' as queryid,\n time + '$lag_interval'::interval as time\n from stat_statements\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and not tag_data->>'query' like '%$2)::int8 as epoch_ns,%' /*trying to not include queries by pgwatch itself*/\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. query runtime", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 32 + }, + "hiddenSeries": false, + "id": 5, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((wal-wal_lag) / (etime-lag_etime)) as \"WAL rate\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n extract(epoch from time) as etime,\n lag(extract(epoch from time)) over w as lag_etime,\n time\n from wal\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere wal >= wal_lag and etime - lag_etime > 0\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((wal-wal_lag) / (etime-lag_etime)) as \"WAL rate-$lag_interval\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n extract(epoch from time + '$lag_interval'::interval) as etime,\n lag(extract(epoch from time + '$lag_interval'::interval)) over w as lag_etime,\n time + '$lag_interval'::interval as time\n from wal\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere wal >= wal_lag and etime - lag_etime > 0\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "WAL rate", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Temp tables not included", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 40 + }, + "hiddenSeries": false, + "id": 6, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((ins-ins_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"INSERT\"\nfrom (\n select \n (data->>'tup_inserted')::int8 as ins, lag((data->>'tup_inserted')::int8) over w as ins_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((ins-ins_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"INSERT-$lag_interval\"\nfrom (\n select \n (data->>'tup_inserted')::int8 as ins, lag((data->>'tup_inserted')::int8) over w as ins_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "INSERT-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Temp tables not included", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 48 + }, + "hiddenSeries": false, + "id": 7, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((upd-upd_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"UPDATE\"\nfrom (\n select \n (data->>'tup_updated')::int8 as upd, lag((data->>'tup_updated')::int8) over w as upd_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((upd-upd_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"UPDATE-$lag_interval\"\nfrom (\n select \n (data->>'tup_updated')::int8 as upd, lag((data->>'tup_updated')::int8) over w as upd_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "UPDATE-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Temp tables not included", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 56 + }, + "hiddenSeries": false, + "id": 8, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((del-del_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"delATE\"\nfrom (\n select \n (data->>'tup_deleted')::int8 as del, lag((data->>'tup_deleted')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((del-del_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"DELETE-$lag_interval\"\nfrom (\n select \n (data->>'tup_deleted')::int8 as del, lag((data->>'tup_deleted')::int8) over w as del_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "DELETE-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 64 + }, + "hiddenSeries": false, + "id": 9, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n time,\n sum(seq_scan) as seq_scan\nfrom (\n select\n $__timeGroup(time, $agg_interval),\n table_full_name,\n avg((((scan - scan_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag))) as seq_scan\n from (\n select \n (data->>'seq_scan')::int8 as scan, lag((data->>'seq_scan')::int8) over w as scan_lag,\n time, lag(time) over w as time_lag,\n tag_data->>'table_full_name' as table_full_name\n from table_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and (data->>'table_size_b')::int8 > 1e8\n window w as (partition by tag_data->>'table_full_name' order by time) \n ) x\n where scan >= scan_lag and time > time_lag\n group by 1, 2\n) y\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n time,\n sum(seq_scan) as \"seq_scan-$lag_interval\"\nfrom (\n select\n $__timeGroup(time, $agg_interval),\n table_full_name,\n avg((((scan - scan_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag))) as seq_scan\n from (\n select \n (data->>'seq_scan')::int8 as scan, lag((data->>'seq_scan')::int8) over w as scan_lag,\n time + '$lag_interval'::interval as time, lag(time) over w + '$lag_interval'::interval as time_lag,\n tag_data->>'table_full_name' as table_full_name\n from table_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and (data->>'table_size_b')::int8 > 1e8\n window w as (partition by tag_data->>'table_full_name' order by time) \n ) x\n where scan >= scan_lag and time > time_lag\n group by 1, 2\n) y\ngroup by 1\norder by 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Seq. scans on tables > 100MB", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 72 + }, + "hiddenSeries": false, + "id": 10, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(tb-tb_lag) as \"Temp bytes\"\nfrom (\n select \n time,\n lag(time) over w as time_lag, \n (data->>'temp_bytes')::int8 as tb,\n lag((data->>'temp_bytes')::int8) over w as tb_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere tb >= tb_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(tb-tb_lag) as \"Temp bytes -$lag_interval\"\nfrom (\n select \n time + '$lag_interval'::interval as time,\n (data->>'temp_bytes')::int8 as tb,\n lag((data->>'temp_bytes')::int8) over w as tb_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere tb >= tb_lag\ngroup by 1\norder by 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Temp bytes", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "i.e. the Postgres cache ratio", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 80 + }, + "hiddenSeries": false, + "id": 11, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag)))*100 as \"SB hit ratio\"\nfrom (\n select\n time,\n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere hit > hit_lag or read > read_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag)))*100 as \"SB hit ratio -$lag_interval\"\nfrom (\n select\n time + '$lag_interval'::interval as time,\n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag\n from db_stats\n where dbname = '$dbname' and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n) x\nwhere hit > hit_lag or read > read_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared buffers hit ratio", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 88 + }, + "id": 14, + "mode": "html", + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": "test", + "value": "test" + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": true, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1s,1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "1d", + "value": "1d" + }, + "hide": 0, + "label": null, + "name": "lag_interval", + "options": [ + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": true, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "DB overview time lag comparison", + "uid": "db-overview-time-lag", + "variables": { + "list": [] + }, + "version": 1 + } + db-overview.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Last 5min data", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 0, + "y": 0 + }, + "hideTimeOverride": true, + "id": 16, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'in_recovery_int')::int\nFROM\n wal\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "5m", + "title": "Instance state", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "PRIMARY", + "value": "0" + }, + { + "op": "=", + "text": "REPLICA", + "value": "1" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Last 5min data", + "editable": true, + "error": false, + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 3, + "y": 0 + }, + "hideTimeOverride": true, + "id": 15, + "interval": "", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'postmaster_uptime_s')::int\nFROM\n wal\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "5m", + "title": "Instance uptime", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Current Transaction Per Second (10min avg.) + 6h history", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 6, + "y": 0 + }, + "hideTimeOverride": true, + "id": 1, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "TPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Queries Per Second based on pg_stat_statements.calls. 10min avg. + 6h history", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 9, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 2, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "QPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as qps\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "QPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "10min avg. + 6h history. Requires pg_stat_statements extension and the \"get_stat_statements\" helper function from the \"sql/metric_fetching_helpers\" folder on the monitored DB. Not including pgwatch generated metrics fetching queries.", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 12, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 3, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ms", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "avg_query_runtime_per_db", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n avg(avg) as \"avg_query_runtime\"\nfrom (\n\nselect\n$__timeGroup(time, $__interval),\nqueryid,\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n tag_data->>'queryid' as queryid,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time)\n and not tag_data->>'query' like '%$2)::int8 as epoch_ns,%' /*trying to not include queries by pgwatch itself*/\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Query runtime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 15, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 4, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "db_size_change_last_hour", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n time,\n last_value - first_value\nfrom (\nselect\n time,\n max(first_value) as first_value,\n max(last_value) as last_value\nfrom (\n select\n date_trunc('hour', time) as time,\n first_value((data->>'size_b')::int8) over w,\n last_value((data->>'size_b')::int8) over w\n from\n db_size\n where \n dbname = '$dbname' and $__timeFilter(time)\n window w as (\n partition by date_trunc('hour', time) order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n )\n) x\ngroup by 1\nhaving count(*) > 1 -- if only 1 entry in time block, diff will be always 0\n) y\norder by 1;", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "DB size ch. 1h", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Based on a pure SQL based estimate for fast results. Re-check with \"pgstattuple\" if numbers look suspicious!", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 18, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 5, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Bloat size", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_bloat_approx_summary", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n time,\n avg((data->'approx_table_bloat_b')::int8)\nFROM\n table_bloat_approx_summary_sql\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1\nORDER BY\n 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "approx_free_space_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Approx Table Bloat", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Percentage of rows touched by queries that are actually returned to the client. Low numbers (< 10%) for an OLTP workload can hint at missing indexes", + "editable": true, + "error": false, + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 21, + "y": 0 + }, + "height": "150", + "hideTimeOverride": true, + "id": 6, + "interval": "10m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "load_5", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n 100 * avg((fetched - fetched_lag)::numeric / (returned - returned_lag)) as fetched_vs_returned_pct\nFROM (\n\nSELECT\n time,\n (data->'tup_fetched')::int8 as fetched,\n lag((data->'tup_fetched')::int8) over w as fetched_lag,\n (data->'tup_returned')::int8 as returned,\n lag((data->'tup_returned')::int8) over w as returned_lag\nFROM\n db_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nWINDOW w AS (ORDER BY time)\n) x \nWHERE returned > returned_lag AND fetched >= fetched_lag\nGROUP BY 1\nORDER BY 1\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Tuples fetched vs returned", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 2 + }, + "hiddenSeries": false, + "id": 7, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "db_stats.mean", + "yaxis": 2 + }, + { + "alias": "DB size", + "yaxis": 2 + }, + { + "alias": "blk_read_time", + "yaxis": 2 + }, + { + "alias": "blk_write_time", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "DELETE", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((ins-ins_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"INSERT\",\n avg(((upd-upd_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"UPDATE\",\n avg(((del-del_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag)) as \"DELETE\"\nfrom (\n select \n (data->>'tup_inserted')::int8 as ins, lag((data->>'tup_inserted')::int8) over w as ins_lag,\n (data->>'tup_updated')::int8 as upd, lag((data->>'tup_updated')::int8) over w as upd_lag,\n (data->>'tup_deleted')::int8 as del, lag((data->>'tup_deleted')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere ins >= ins_lag and upd >= upd_lag and del >= del_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "tup_deleted" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Tuple ins. / upd. / del. statistics ($agg_interval avg. rate, log. scale)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "TX rollback ratio": "#890F02" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 2 + }, + "hiddenSeries": false, + "id": 8, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Shared buffers hit ratio", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag)))*100 as \"Shared buffers hit ratio\",\n avg((roll-roll_lag)::numeric / ((roll-roll_lag) + (comm-comm_lag)))*100 as \"TX rollback ratio\"\nfrom (\n select \n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere (hit > hit_lag or read > read_lag) and (roll > roll_lag or comm > comm_lag)\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared Buffers hit ratio + Rollback ratio ($agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": "105", + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "# Sessions": "#cca300", + "#Backends": "#F9E2D2", + "Deadlocks": "dark-red", + "Deadlocks (1h rate)": "#BF1B00", + "QPS": "dark-green", + "TPS": "dark-orange", + "Temp bytes (1h rate)": "#6ed0e0" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 8 + }, + "hiddenSeries": false, + "id": 9, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "# Sessions", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag + r - r_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere time > time_lag and c >= c_lag\ngroup by 1\norder by 1", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "numbackends" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere time > time_lag and c >= c_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TPS / QPS ($agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "DB Size": "#2F575E", + "WAL rate": "#0A50A1" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 8 + }, + "height": "", + "hiddenSeries": false, + "id": 10, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "DB Size", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "WAL rate", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "wal", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((wal-wal_lag) / (etime-lag_etime)) as \"WAL rate\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n extract(epoch from time) as etime,\n lag(extract(epoch from time)) over w as lag_etime,\n time\n from wal\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere wal >= wal_lag and etime - lag_etime > 0\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xlog_location_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(size_b) as \"DB Size\"\nfrom (\n select \n (data->>'size_b')::int8 as size_b,\n time\n from db_size\n where dbname = '$dbname' and $__timeFilter(time)\n) x\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "WAL rate + DB size ($agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "idle in transaction": "#bf1b00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Based on get_stat_activity() helper", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 14 + }, + "hiddenSeries": false, + "id": 11, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "hideEmpty": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "idle", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((data->>'idle')::int8) as idle,\n avg((data->>'idleintransaction')::int8) as \"idle in transaction\",\n avg((data->>'waiting')::int8) as waiting,\n avg((data->>'active')::int8) as active,\n avg((data->>'av_workers')::int8) as av_workers\nfrom backends\n where dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "idle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Sessions by state ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Requires according \"metric fetching helpers\" on the monitored server. Not including pgwatch generated metrics fetching queries.", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 14 + }, + "hiddenSeries": false, + "id": 12, + "interval": "10m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "avg_query_runtime", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "load_5", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->>'load_5min')::numeric) as \"load_5\"\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "alias": "avg_query_runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n avg(avg) as \"avg_query_runtime\"\nfrom (\n\nselect\n$__timeGroup(time, $agg_interval),\nqueryid,\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n tag_data->>'queryid' as queryid,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time)\n and not tag_data->>'query' like '%$2)::int8 as epoch_ns,%' /*trying to not include queries by pgwatch itself*/\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU load + avg. query runtime ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 20 + }, + "hiddenSeries": false, + "id": 18, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n time,\n sum(seq_scan) as seq_scan,\n sum(idx_scan) as idx_scan\nfrom (\n select\n $__timeGroup(time, $agg_interval),\n table_full_name,\n avg((((scan - scan_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag))) as seq_scan,\n avg((((idx_scan - idx_scan_lag) * (extract(epoch from '$agg_interval'::interval))) / extract(epoch from time - time_lag))) as idx_scan\n from (\n select \n (data->>'seq_scan')::int8 as scan, lag((data->>'seq_scan')::int8) over w as scan_lag,\n (data->>'idx_scan')::int8 as idx_scan, lag((data->>'idx_scan')::int8) over w as idx_scan_lag,\n time, lag(time) over w as time_lag,\n tag_data->>'table_full_name' as table_full_name\n from table_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and (data->>'table_size_b')::int8 > 10000000\n window w as (partition by tag_data->>'table_full_name' order by time) \n ) x\n where scan >= scan_lag and time > time_lag\n group by 1, 2\n) y\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Seq. / Idx. scans ($agg_interval avg. rate., >10MB tables, log. scale)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "Temp bytes": "light-red", + "Temp bytes (1h rate)": "light-red", + "Temp bytes (5m avg)": "light-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 0, + "description": "Appears when larger groupings / sortings don't fit into 'work_mem'", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 20 + }, + "hiddenSeries": false, + "id": 19, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(((tb-tb_lag)*extract(epoch from '$agg_interval'::interval)) / (etime - lag_etime)) as \"Temp bytes\"\nfrom (\n select \n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere tb >= tb_lag\ngroup by 1\norder by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Temp bytes ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": 1, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 26 + }, + "id": 14, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": false, + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "5m", + "value": "5m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": true, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1s,1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "DB overview", + "uid": "db-overview", + "version": 1 + } + global-health.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": null, + "description": "Please adjust the markers as needed! Also the default query assumes that all DBs are separate instances. If not so change the query to add some filters or groupings based on the wal.sys_id column for example or the configured_dbs.continuous_discovery_prefix if using the DB auto-discovery modes. The same applies also for the below \"top\" table panels.", + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "fieldOptions": { + "calcs": [ + "last" + ], + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 10, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-green", + "value": 10 + } + ] + } + }, + "overrides": [], + "values": false + }, + "orientation": "auto", + "showThresholdLabels": true, + "showThresholdMarkers": true + }, + "pluginVersion": "6.6.1", + "targets": [ + { + "format": "time_series", + "group": [ + { + "params": [ + "dbname" + ], + "type": "column" + } + ], + "metricColumn": "dbname", + "rawQuery": true, + "rawSql": "SELECT\n 0 AS \"time\",\n count(distinct dbname)\nFROM wal\nWHERE\n $__timeFilter(\"time\")\n AND (data->'in_recovery_int')::int = 0", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + }, + { + "params": [ + "avg" + ], + "type": "aggregate" + }, + { + "params": [ + "value" + ], + "type": "alias" + } + ] + ], + "table": "db_stats", + "timeColumn": "\"time\"", + "timeColumnType": "timestamptz", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Monitored primary DB-s ", + "type": "gauge" + }, + { + "datasource": null, + "description": "Please adjust the markers as needed! Also the default query assumes that all DBs are separate instances. If not so change the query to add some filters or groupings based on the wal.sys_id column for example or the configured_dbs.continuous_discovery_prefix if using the DB auto-discovery modes. The same applies also for the below \"top\" table panels.", + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 0 + }, + "id": 3, + "options": { + "fieldOptions": { + "calcs": [ + "last" + ], + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 10, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "dark-orange", + "value": 9 + }, + { + "color": "dark-green", + "value": 10 + } + ] + } + }, + "overrides": [], + "values": false + }, + "orientation": "auto", + "showThresholdLabels": true, + "showThresholdMarkers": true + }, + "pluginVersion": "6.6.1", + "targets": [ + { + "format": "time_series", + "group": [ + { + "params": [ + "dbname" + ], + "type": "column" + } + ], + "metricColumn": "dbname", + "rawQuery": true, + "rawSql": "SELECT\n 0 AS \"time\",\n count(distinct dbname)\nFROM\n wal\nWHERE\n $__timeFilter(\"time\")\n AND (data->'in_recovery_int')::int = 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + }, + { + "params": [ + "avg" + ], + "type": "aggregate" + }, + { + "params": [ + "value" + ], + "type": "alias" + } + ] + ], + "table": "db_stats", + "timeColumn": "\"time\"", + "timeColumnType": "timestamptz", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Monitored replica DB-s", + "type": "gauge" + }, + { + "columns": [], + "datasource": null, + "description": "Configured to be monitored but no recent data", + "fontSize": "110%", + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 5, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "row", + "colors": [ + "#FA6400", + "#E02F44", + "#C4162A" + ], + "decimals": null, + "pattern": "last_seen", + "thresholds": [ + "600", + "3600" + ], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "last_seen_uptime", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to Overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n (SELECT case when data->>'in_recovery_int' = '0' then 'primary' else 'replica' end from wal where time > now() - '15min'::interval and dbname = c.dbname order by time desc limit 1) as last_role,\n (SELECT (extract(epoch from now() - time))::int from db_stats where dbname = c.dbname order by time desc limit 1) as last_seen,\n (SELECT (data->'postmaster_uptime_s')::int from db_stats where dbname = c.dbname order by time desc limit 1) as last_seen_uptime\nFROM\n (select dbname, max(time) from configured_dbs where time between now() - '15min'::interval and now() group by dbname) c /* 10min ping interval hardcoded in collector */\nWHERE\n NOT EXISTS (\n select dbname from db_stats where $__timeFilter(\"time\") and dbname = c.dbname union \n select dbname from pgbouncer_stats where $__timeFilter(\"time\") and dbname = c.dbname \n)", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Offline nodes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Last $__interval average. 2 /5 % threshold defaults.", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 7 + }, + "id": 7, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "decimals": 1, + "pattern": "rollback_ratio", + "thresholds": [ + "2", + "5" + ], + "type": "number", + "unit": "none" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to 'Overview' dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select * from (\nselect\n dbname,\n avg((roll-roll_lag)::numeric / ((roll-roll_lag) + (comm-comm_lag)))*100 as \"rollback_ratio\"\nfrom (\n select\n dbname,\n time,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(\"time\")\n window w as (partition by dbname order by time)\n) x\nWHERE comm > comm_lag or roll > roll_lag\nGROUP BY 1\n) y\nWHERE rollback_ratio > 0\nORDER BY 2 DESC\nLIMIT $top_limit\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by TX rollback %", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Includes \"idle in transaction\" TX. 5 / 10 min default thresholds", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 7 + }, + "id": 10, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "longest_tx_seconds", + "thresholds": [ + "300", + "600" + ], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to 'Overview' dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT * FROM (\nSELECT\n dbname,\n max((data->'longest_tx_seconds')::int) AS longest_tx_seconds\nFROM\n backends\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n dbname\n) x\nWHERE longest_tx_seconds > 0\nORDER BY 2 DESC\nLIMIT $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by longest TX time", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Assumes get_stat_activity() helper for non-privileged monitoring users", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 7 + }, + "id": 6, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Go to Overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "waiting", + "thresholds": [ + "1", + "5" + ], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n max((data->'waiting')::int) AS \"waiting\"\nFROM\n backends\nWHERE\n $__timeFilter(\"time\")\n AND (data->'waiting')::int > 0\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by blocked sessions", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Assumes get_stat_activity() helper for non-privileged monitoring users", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 12 + }, + "id": 14, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Go to Overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "waiting", + "thresholds": [ + "1", + "5" + ], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n round(100 * instance_total::numeric / max_connections, 1) AS \"pct_used\",\n instance_total AS used_connections,\n max_connections\nFROM\n (\n select\n distinct on (dbname)\n dbname,\n (data->'max_connections')::int as max_connections,\n (data->'instance_total')::int as instance_total\n FROM\n backends\n WHERE\n $__timeFilter(time)\n order by dbname, time desc\n ) x\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by used connections", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "100 MB / 1 GB default threshold", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 12 + }, + "id": 9, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "temp_bytes_per_minute", + "thresholds": [ + "100000000", + "1000000000" + ], + "type": "number", + "unit": "bytes" + }, + { + "alias": "Go to 'Overview' dash", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to 'Overview' dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select * from (\nselect\n dbname,\n avg((tb-tb_lag) / (etime - lag_etime))*60 as \"temp_bytes_per_minute\"\nfrom (\n select\n dbname,\n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime\n from db_stats\n where $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere\n tb >= tb_lag and etime > lag_etime\ngroup by\n dbname\n) y\nwhere temp_bytes_per_minute > 0\norder by 2 desc\nlimit $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by temp. files", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "1 / 16 MB default thresholds", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 12 + }, + "id": 8, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "replay_lag_b", + "thresholds": [ + "1000000", + "16000000" + ], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to 'Replication' dash", + "linkUrl": "/d/replication?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select * from (\nselect \n dbname,\n max((data->'replay_lag_b')::int8) as replay_lag_b\nfrom\n replication\nwhere\n (data->'replay_lag_b')::int8 > 0\ngroup by\n dbname\n) x\norder by 2 desc\nlimit $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by replication lag", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Assumes \"psutil_disk\" helper. 10 / 5% default warning thresholds", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 17 + }, + "id": 11, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "used_percent", + "thresholds": [ + "80", + "90" + ], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to 'System Stats' dash", + "linkUrl": "/d/system-stats?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select * from (\nselect \n dbname,\n max((data->'percent')::float) as used_percent\nfrom\n psutil_disk\nwhere\n $__timeFilter(\"time\")\n and (data->'percent')::float > 0\ngroup by\n dbname\n) x\norder by 2 desc nulls last\nlimit $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Lowest $top_limit by free disk %", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Assumes \"psutil_cpu\" helpers are installed and configured", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 17 + }, + "id": 15, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Go to Overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "cpu_utilization", + "thresholds": [ + "30", + "60" + ], + "type": "number", + "unit": "percent" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n round(max((data->'cpu_utilization')::numeric), 1) AS \"cpu_utilization\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by CPU utilization %", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Needs \"get_wal_size\" helper for unprivileged monitoring users", + "fontSize": "90%", + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 17 + }, + "id": 16, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Go to Overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "wal_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n max((data->'wal_size_b')::int8) as wal_size\nFROM\n wal_size\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top $top_limit by WAL folder size", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 13, + "mode": "html", + "options": {}, + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": "1m", + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": false, + "text": "3", + "value": "3" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top_limit", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": true, + "text": "3", + "value": "3" + }, + { + "selected": false, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + } + ], + "query": "1,3,5,10", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Global Health", + "uid": "global-health", + "version": 1 + } + health-check.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Current and avg. KPI-s. Expects 'get_load_average' and 'backends' helpers to be installed on the monitored DB.", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "PRIMARY - accepting writes, REPLICA - read-only", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 0 + }, + "hideTimeOverride": true, + "id": 28, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'in_recovery_int')::int\nFROM\n wal\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,2", + "timeFrom": "$online_interval", + "title": "Instance state", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "REPLICA", + "value": "1" + }, + { + "op": "=", + "text": "PRIMARY", + "value": "0" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": null, + "decimals": 0, + "description": "Time from last Postgres process restart. < 5m Error, < 30m Warn thresholds by default", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 0 + }, + "hideTimeOverride": true, + "id": 18, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'postmaster_uptime_s')::int\nFROM\n wal\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "postmaster_uptime_s" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "300, 1800", + "timeFrom": "$online_interval", + "title": "Instance uptime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#C4162A", + "#FA6400", + "#299c46" + ], + "datasource": null, + "decimals": 0, + "description": "\"SHOW server_version_num;\"\n110005 => 11.5", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 0 + }, + "hideTimeOverride": true, + "id": 44, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "Postgres Version Overview", + "url": "/d/postgres-version-overview?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select time, (data->'server_version_num')::int8 as value from settings where dbname = '$dbname' and $__timeFilter(time) order by time desc limit 1;", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "active" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "90400,90600", + "timeFrom": "6h", + "title": "PG version num.", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Longest query duration during last $online_interval", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 0 + }, + "hideTimeOverride": true, + "id": 32, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 AS time,\n max((data->'longest_query_seconds')::int)\nFROM\n backends\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "longest_query_seconds" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "30,300", + "timeFrom": "$online_interval", + "title": "Longest query runtime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "rgba(237, 129, 40, 0.89)", + "#299c46", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Connected sessions, including Postgres internal processes like Autovacuum. < 1 Warn / > 300 Error thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 2 + }, + "hideTimeOverride": true, + "id": 15, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview :: backends' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=11&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'numbackends')::int\nFROM\n db_stats\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "numbackends" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,300", + "timeFrom": "$online_interval", + "title": "Active connections", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "#FA6400", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "\"max_connections\" configuration setting. Changing requires re-start. 500/1000 Warn / Error thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 2 + }, + "hideTimeOverride": true, + "id": 45, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview :: backends' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=11&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'max_connections')::int\nFROM\n settings\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "numbackends" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "500,1000", + "timeFrom": "6h", + "title": "Max. connections", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Max number of queries waiting on resources locked by other sessions. 1 Warn / 5 Err thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 2 + }, + "hideTimeOverride": true, + "id": 34, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Lock details' dashboard", + "url": "/d/lock-details?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'waiting')::int)\nFROM\n backends\nWHERE\n $__timeFilter(time, $online_interval)\n AND dbname = '$dbname'", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "waiting" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,5", + "timeFrom": "$online_interval", + "title": "Blocked sessions", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": null, + "decimals": 1, + "description": "Shared Buffers is the Postgres -managed file cache and 90%+ is what you normally want to see for best performance.", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 2 + }, + "hideTimeOverride": true, + "id": 21, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "Open 'DB overview :: share'd buffers ' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=8&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n ((hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag)))*100 as \"Shared buffers hit ratio\"\nfrom (\n select \n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag,\n time\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere hit > hit_lag or read > read_lag\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "50,80", + "timeFrom": null, + "title": "Shared Buffers hit pct.", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "0", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "0.5% Warn / 1% Error thresholds by default", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 4 + }, + "hideTimeOverride": true, + "id": 13, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview :: Rollback Ratio' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=8&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $online_interval),\n max((roll-roll_lag)::numeric / ((roll-roll_lag) + (comm-comm_lag)))*100 as \"TX rollback ratio\"\nfrom (\n select\n time,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n window w as (order by time)\n) x\nWHERE comm > comm_lag or roll > roll_lag\nGROUP BY 1\nORDER BY 1 DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xact_commit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "0.5, 1", + "timeFrom": null, + "title": "TX rollback pct. (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": null, + "decimals": 1, + "description": "Transactions per Second. Last $online_interval average. <0.1 % Error / < 1.0 Warn thresholds by default", + "format": "short", + "gauge": { + "maxValue": null, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": false + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 4 + }, + "hideTimeOverride": true, + "id": 7, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview Unprivileged / Developer :: TPS' panel", + "url": "/d/db-overview-developer?$__all_variables&viewPanel=15&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $online_interval),\n avg( ((roll-roll_lag) + (comm-comm_lag)) / extract(epoch from (time - time_lag)) )\nfrom (\n select\n time, lag(time) over w as time_lag,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n window w as (order by time)\n) x\nWHERE (comm > comm_lag or roll > roll_lag) and time > time_lag\nGROUP BY 1\nORDER BY 1 DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xact_commit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "0.1,1", + "timeFrom": null, + "title": "TPS (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": null, + "decimals": 1, + "description": "Queries per Second based on \"pg_stat_statements\" extension info. Last $online_interval avg. < 0.1 Error / < 1 Warning thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 4 + }, + "hideTimeOverride": true, + "id": 16, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview Unprivileged / Developer :: QPS' panel", + "url": "/d/db-overview-developer?$__all_variables&viewPanel=15&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $online_interval),\n avg( (c - c_lag) / extract(epoch from time - time_lag)) as qps\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1 desc\nlimit 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "0.1, 1", + "timeFrom": null, + "title": "QPS (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Transactions opened but where no queries are being executed.", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 4 + }, + "hideTimeOverride": true, + "id": 33, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview :: Backends' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=11&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "15m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'idleintransaction')::int)\nFROM\n backends\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "idleintransaction" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,5", + "timeFrom": "$online_interval", + "title": "\"Idle in TX\" count", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Size for selected DB only", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 6 + }, + "hideTimeOverride": true, + "id": 25, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "DB overview :: DB size panel", + "url": "/d/db-overview?$__all_variables&viewPanel=10&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'size_b')::int8\nFROM\n db_size\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "postmaster_uptime_s" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "DB size (last)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 6 + }, + "hideTimeOverride": true, + "id": 23, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "DB overview :: DB size panel", + "url": "/d/db-overview?$__all_variables&viewPanel=10&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n last_value-first_value as size_diff\nfrom (\n select\n time,\n first_value((data->>'size_b')::int8) over w,\n last_value((data->>'size_b')::int8) over w\n from\n db_size\n where \n dbname = '$dbname' and $__timeFilter(time)\n window w as (\n order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n )\n) x\norder by 1 desc\nlimit 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "postmaster_uptime_s" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "DB size change (diff.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": null, + "decimals": 1, + "description": "Assumes get_psutil_disk wrapper being installed. 10/50GB Warn/Error thresholds by default", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 6 + }, + "hideTimeOverride": true, + "id": 24, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "Open 'System Stats :: Free disk ' panel", + "url": "/d/system-stats?$__all_variables&viewPanel=8&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_changes", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n (data->'free')::int8\nfrom\n psutil_disk\nwhere \n dbname = '$dbname' and $__timeFilter(time)\n and tag_data->>'dir_or_tablespace' = 'data_directory'\norder by 1 desc\nlimit 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "event" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "10000000,50000000", + "timeFrom": null, + "title": "DATADIR disk space left", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "0", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Last $online_interval avg. based on \"pg_stat_statements\" info. > 0.5s Warning / > 5s Error thresholds by default", + "format": "ms", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 6 + }, + "hideTimeOverride": true, + "id": 17, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DB overview:: Query runtime' panel", + "url": "/d/db-overview?$__all_variables&viewPanel=12&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $online_interval),\navg(case when c = c_lag then 0 else (tt-tt_lag)::numeric / (c-c_lag) end) as \"avg_query_runtime\"\nfrom (\n\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c >= c_lag and tt >= tt_lag\ngroup by 1\norder by 1 desc\nlimit 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "500, 5000", + "timeFrom": null, + "title": "Query runtime (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Server configuration changes. >1 Warn thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 8 + }, + "hideTimeOverride": true, + "id": 22, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DDL / Config change events' dash", + "url": "/d/change-events?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_changes", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n count(*)\nFROM\n configuration_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "event" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1", + "timeFrom": null, + "title": "Config change events", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "0", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Number of DDL changes i.e. new or changed tables, columns, functions etc. >1 Warn thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 8 + }, + "hideTimeOverride": true, + "id": 20, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'DDL / Config change events' dash", + "url": "/d/change-events?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_changes", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n count(*)\nFROM\n table_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "event" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1", + "timeFrom": null, + "title": "Table changes", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "0", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Based on pg_stat_archiver. N/A when archiving is not enabled.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 8 + }, + "hideTimeOverride": true, + "id": 19, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "365d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "archiver", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'is_failing_int')::int\nFROM\n archiver\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "is_failing_int" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,2", + "timeFrom": "$online_interval", + "title": "WAL archiving status", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "OK", + "value": "0" + }, + { + "op": "=", + "text": "FAILING", + "value": "1" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Transaction Log Folder size. Assumes get_wal_size helper being installed. 1/10 GB Warn / 50 Error thresholds by default", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 8 + }, + "hideTimeOverride": true, + "id": 14, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "DB overview :: WAL panel", + "url": "/d/db-overview?$__all_variables&viewPanel=10&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'wal_size_b')::float8\nFROM\n wal_size\nWHERE\n time > now() - '$online_interval'::interval\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1000000000,10000000000", + "timeFrom": null, + "title": "WAL folder size", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Invalid indexes should be dropped as they're updated on DML operations but cannot be used for speeding up queries. In case multiple indexes of same structure Postgres will use the smallest so the others can be dropped. 'N/A' displayed both when no duplicate indexes or no metrics data for index_stats.", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 10 + }, + "hideTimeOverride": true, + "id": 29, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "\"Index overview\" dashboard", + "url": "/d/index-overview" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "WITH q_duplicates AS (\nSELECT\n coalesce(sum(count-1), 0) as extra\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n data->>'index_def' as index_def,\n count(*)\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats where $__timeFilter(time) AND dbname = '$dbname')\n AND dbname = '$dbname'\nGROUP BY 1, 2\nHAVING count(*) > 1\n) x\n)\nSELECT\n 0 as time,\n sum((data->'is_invalid_int')::int) + (select extra from q_duplicates)\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats where $__timeFilter(time) AND dbname = '$dbname')\n AND dbname = '$dbname'\nGROUP BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,2", + "timeFrom": null, + "title": "Invalid / duplicate indexes", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "i.e. AUTOVACUUM disabled globally or per table.", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 10 + }, + "hideTimeOverride": true, + "id": 30, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n sum(count)\nFROM (\n\nSELECT * FROM (\n\nSELECT\n case when data->>'autovacuum' = 'off' then 1 else 0 end as count\nFROM\n settings\nWHERE\n dbname = '$dbname'\n AND time > now() - '1d'::interval\nORDER BY time DESC LIMIT 1\n\n) a\n\nUNION ALL\n\nSELECT * FROM (\n\nSELECT\n count(*)\nFROM\n table_stats\nWHERE\n dbname = '$dbname'\n AND time = (select max(time) from table_stats where dbname = '$dbname')\n AND (data->'no_autovacuum')::int = 1\n\n) b\n\n) x;", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,10", + "timeFrom": null, + "title": "Autovacuum issues", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Checkpoints should normally be performed by the background \"Checkpointer\" process. If seeing high numbers then adjusting server configuration is recommended.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 10 + }, + "hideTimeOverride": true, + "id": 26, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "Checkpointer / Bgwriter / Block IO Stats", + "url": "/d/checkpointer-bgwriter-stats?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "365d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "bgwriter", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n coalesce(sum(req - req_lag), 0)\nFROM (\nSELECT\n (data->'checkpoints_req')::int as req,\n lag((data->'checkpoints_req')::int) over(order by time) as req_lag\nFROM\n bgwriter\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n) x\nWHERE req > req_lag\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "checkpoints_req" + ], + "type": "field" + }, + { + "params": [], + "type": "spread" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,2", + "timeFrom": null, + "title": "Checkpoints requested", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "diff" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Estimated extra space held by tables (excluding indexes) that would disappear after \"compacting\".", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 10 + }, + "hideTimeOverride": true, + "id": 27, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'approx_table_bloat_b')::int8\nFROM\n table_bloat_approx_summary_sql\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY 1 DESC\nLIMIT 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "1d", + "title": "Approx. table bloat", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Transaction logs generation velocity.", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 12 + }, + "hideTimeOverride": true, + "id": 36, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "DB overview :: WAL panel", + "url": "/d/db-overview?$__all_variables&viewPanel=10&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "wal", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n 0 as time,\n avg((wal-wal_lag) / (etime-lag_etime)) as \"WAL rate\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n extract(epoch from time) as etime,\n lag(extract(epoch from time)) over w as lag_etime,\n time\n from wal\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere wal >= wal_lag and etime > lag_etime", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xlog_location_b" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1000000,16000000", + "timeFrom": null, + "title": "WAL per second (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Postgres writes temporary files to disk when sorting / grouping big amounts of data that doesn't fit into \"work_mem\". 10/100 MB Warn / Error by default", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 12 + }, + "hideTimeOverride": true, + "id": 37, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "DB overview", + "url": "/d/db-overview?$__all_variables&viewPanel=19&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n 0 as time,\n avg(case when tb-tb_lag > 0 then (tb-tb_lag) / (etime - lag_etime) else 0 end) as \"Temp bytes (1h rate)\"\nfrom (\n select \n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere tb >= tb_lag and etime > lag_etime\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temp_bytes" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "10000000,100000000", + "timeFrom": null, + "title": "Temp. bytes per second (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Long running AUTOVACUUM processes can hint at workload or configuration problems", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 12 + }, + "hideTimeOverride": true, + "id": 35, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "15m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'longest_autovacuum_seconds')::int8) as longest_autovacuum_seconds\nFROM\n backends\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "seconds_since_last_vacuum" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "60,300", + "timeFrom": null, + "title": "Longest AUTOVACUUM duration", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Frequent sequential scans on bigger tables should usually be avoided. Warn / Error thresholds: 10 / 100", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 12 + }, + "hideTimeOverride": true, + "id": 39, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Tables Top :: Most scans' panel", + "url": "/d/tables-top?$__all_variables&viewPanel=4&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n sum((scan-scan_lag) * 60 / extract(epoch from (time-time_lag)))\nFROM (\n SELECT\n time, lag(time) over w as time_lag,\n (data->'seq_scan')::int8 as scan, lag((data->'seq_scan')::int8) over w as scan_lag\n FROM\n table_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND (data->'table_size_b')::int8 > 100000000\n WINDOW w AS (partition by tag_data->>'table_full_name' order by time)\n) x\nWHERE scan > scan_lag and time > time_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "seq_scan" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "10,100", + "timeFrom": null, + "title": "Seq. scans on >100 MB tables per minute (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "On non-temporary tables", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 14 + }, + "hideTimeOverride": true, + "id": 38, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Tables Top :: Inserts' panel", + "url": "/d/tables-top?$__all_variables&viewPanel=6&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n avg(((ins-ins_lag) * 60) / extract(epoch from time - time_lag))\nfrom (\n select \n (data->>'tup_inserted')::int8 as ins, lag((data->>'tup_inserted')::int8) over w as ins_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere ins >= ins_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "tup_updated" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "INSERT-s per minute (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "On non-temporary tables", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 14 + }, + "hideTimeOverride": true, + "id": 40, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Tables Top :: Updates' panel", + "url": "/d/tables-top?$__all_variables&viewPanel=7&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n avg(((upd-upd_lag) * 60) / extract(epoch from time - time_lag))\nfrom (\n select \n (data->'tup_updated')::int8 as upd, lag((data->'tup_updated')::int8) over w as upd_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere upd >= upd_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "tup_updated" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "UPDATE-s per minute (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "On non-temporary tables", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 14 + }, + "hideTimeOverride": true, + "id": 41, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Tables Top :: Deletes' panel", + "url": "/d/tables-top?$__all_variables&viewPanel=8&fullscreen" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n time,\n avg(((del-del_lag) * 60) / extract(epoch from time - time_lag))\nfrom (\n select \n (data->'tup_deleted')::int8 as del, lag((data->'tup_deleted')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere del >= del_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "tup_updated" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "DELETE-s per minute (avg.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Based on db_stats.backup_duration_s / pg_backup_start_time() [9.3+] function. N/A if no backup in progress.", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 14 + }, + "hideTimeOverride": true, + "id": 42, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'backup_duration_s')::int8)\nFROM\n db_stats\nWHERE\n $__timeFilter(time)\n and dbname = '$dbname'", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "max_xmin_age_tx" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "3600,36000", + "timeFrom": "$online_interval", + "title": "Backup duration", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Max. age since last VACUUM FREEZE. Could hint at problems when going into 100s of millions", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 0, + "y": 16 + }, + "hideTimeOverride": true, + "id": 47, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "365d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'tx_freeze_age')::int8)\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n and dbname = '$dbname'", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "max_xmin_age_tx" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "100000000,500000000", + "timeFrom": null, + "title": "Max. table FREEZE age", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "In TX. Holds back VACUUM", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 16 + }, + "hideTimeOverride": true, + "id": 43, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Replication lag' dashboard", + "url": "/d/replication?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "365d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n 0 as time,\n max(xmin) from (\nSELECT\n max((data->'xmin_age_tx')::int8) as xmin\nFROM\n replication_slots\nWHERE\n time = (select max(time) from replication_slots where time > now() - '$online_interval'::interval AND dbname = '$dbname')\n and dbname = '$dbname' \nUNION ALL\nSELECT\n max((data->'max_xmin_age_tx')::int8) as xmin\nFROM\n backends\nWHERE\n time = (select max(time) from backends where time > now() - '$online_interval'::interval AND dbname = '$dbname')\n and dbname = '$dbname'\n) x", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "max_xmin_age_tx" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "10000,100000", + "timeFrom": null, + "title": "Max. XMIN horizon age", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "#bf1b00", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Inactive repl. slots accumulate WAL files until disk space runs out. Re-animate the replica or use pg_drop_replication_slot() to remove the slot so that Postgres can delete the un-needed WALs.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 16 + }, + "hideTimeOverride": true, + "id": 4, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Replication lag' dashboard", + "url": "/d/replication?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n sum((data->'non_active_int')::int)\nFROM\n replication_slots\nWHERE\n time = (select max(time) from replication_slots where time > now() - '$online_interval'::interval AND dbname = '$dbname')\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "active" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,1000", + "timeFrom": "$online_interval", + "title": "Inactive repl. slots", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "#FA6400", + "#d44a3a" + ], + "datasource": null, + "decimals": null, + "description": "\"Apply\" (data made visible to queries on replica) lag in bytes", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 18, + "y": 16 + }, + "hideTimeOverride": true, + "id": 46, + "interval": null, + "links": [ + { + "targetBlank": true, + "title": "'Replication lag' dashboard", + "url": "/d/replication?$__all_variables" + } + ], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'replay_lag_b')::int8)\nFROM\n replication\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "active" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1000000,10000000", + "timeFrom": "$online_interval", + "title": "Max. replication lag", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "content": "Brought to you by: \"Cybertec", + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 12, + "links": [], + "mode": "html", + "options": {}, + "title": "", + "transparent": true, + "type": "text" + }, + { + "content": "

The preset threshold values (green / yellow / red) should be reviewed / adjusted!

", + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 48, + "links": [], + "mode": "html", + "options": {}, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 19, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": "Max. age for 'online' metrics", + "name": "online_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "3m", + "value": "3m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + } + ], + "query": "1m,3m,5m,10m,15m", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Health-check", + "uid": "health-check", + "version": 1 + } + index-overview.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 8, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "index_def_hash", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "max_index_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard", + "linkUrl": "/d/table-details?var-dbname=${__cell_1}&var-table_full_name=${__cell}", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "count", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select \"index_def\", \"max_index_size\", \"count\" from (select mode(\"index_def\") as \"index_def\", count(distinct(\"index_full_name_val\")), max(\"index_size_b\") as \"max_index_size\" from index_stats where \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"table_full_name\", \"index_def_hash\", \"dbname\") where \"count\" > 1 group by \"table_full_name\", \"index_def_hash\", \"dbname\"", + "rawQuery": true, + "rawSql": "--select \"index_def\", \"max_index_size\", \"count\" from (select mode(\"index_def\") as \"index_def\", count(distinct(\"index_full_name_val\")), max(\"index_size_b\") as \"max_index_size\" \n-- from index_stats where \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"table_full_name\", \"index_def_hash\", \"dbname\") where \"count\" > 1 \n--group by \"table_full_name\", \"index_def_hash\", \"dbname\"\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n data->>'index_def' as index_def,\n max((data->'index_size_b')::int8) as max_index_size,\n count(*)\nFROM\n index_stats\nWHERE\n time in (select max(time) from index_stats where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2, 3\nHAVING\n count(*) > 1", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": "15m", + "title": "Duplicate indexes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Before dropping indexes make sure they are not used on replicas, if having any. FYI - one could also adjust the default 0 threshold so that \"little used\" indexes are shown", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 10, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard", + "linkUrl": "/d/table-details?var-dbname=${__cell_1}&var-table_full_name=${__cell}", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "index_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select \"index_size\", \"idx_scans_from_last_reset\" from (select last(\"index_size_b\") as \"index_size\", last(\"idx_scan\") as \"idx_scans_from_last_reset\", last(\"is_pk\") as \"is_pk\" from index_stats where \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"table_full_name\", \"index_full_name\", \"dbname\") where \"idx_scans_from_last_reset\" = 0 and \"is_pk\" = false group by \"table_full_name\", \"index_full_name\", \"dbname\"", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'index_size_b')::int8) as index_size,\n max((data->'idx_scan')::int8) as idx_scans_from_last_reset\nFROM\n index_stats\nWHERE\n time in (select max(time) from index_stats where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n AND (data->'idx_scan')::int8 = 0\n AND (data->'is_pk_int')::int8 = 0\n AND coalesce((data->'is_uq_or_exc')::int8, 0) = 0\nGROUP BY\n 1, 2, 3\nORDER BY\n 4 desc", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": "15m", + "title": "Unused indexes (Non-PK)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 11, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard", + "linkUrl": "/d/table-details?var-dbname=${__cell_1}&var-table_full_name=${__cell}", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "index_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select \"index_size\" from (select last(\"index_size_b\") as \"index_size\", last(\"is_invalid_int\") as \"is_invalid_int\" from index_stats where \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"table_full_name\", \"index_full_name\", \"dbname\") where \"is_invalid_int\" = 1 group by \"table_full_name\", \"index_full_name\", \"dbname\"", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'index_size_b')::int8) as index_size\nFROM\n index_stats\nWHERE\n time in (select max(time) from index_stats where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n AND (data->'is_invalid_int')::int8 = 1\nGROUP BY\n 1, 2, 3\nORDER BY\n 4 desc", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": "15m", + "title": "Invalid indexes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 9, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard", + "linkUrl": "/d/table-details?var-dbname=${__cell_1}&var-table_full_name=${__cell}", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "index_size", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "idx_scans_from_last_reset", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select \"dbname\", \"index_full_name\", \"table_full_name\", top(\"index_size_b\", 20), \"idx_scans_from_last_reset\" from (select last(\"index_size_b\") as \"index_size_b\", last(\"idx_scan\") as idx_scans_from_last_reset from index_stats where \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"table_full_name\", \"index_full_name\", \"dbname\")", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'index_size_b')::int8) as top,\n max((data->'idx_scan')::int8) as scans_from_last_reset\nFROM\n index_stats\nWHERE\n time in (select max(time) from index_stats where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2, 3\nORDER BY\n 4 DESC\nLIMIT\n 20", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": "15m", + "title": "Top 20 biggest indexes", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 6, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": "$__all" + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'index_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Index overview", + "uid": "index-overview", + "version": 1 + } + postgres-version-overview.json: |- + { + "annotations": { + "list": [ + { + "$hashKey": null, + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "As per \"settings\" metric.", + "fontSize": "130%", + "gridPos": { + "h": 14, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 1, + "desc": false + }, + "styles": [ + { + "alias": "", + "colorMode": "row", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "server_version_num", + "thresholds": [ + "90400", + "90600" + ], + "type": "number", + "unit": "none" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"total_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "SELECT\n split_part(data->>'server_version'::text, ' ', 1) as server_version,\n (data->'server_version_num')::int8 as server_version_num,\n string_agg(DISTINCT dbname, ', ') as dbname \nFROM\n settings\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\n AND (data->>'server_version_num')::int8 <= $lower_than_server_version_num\nGROUP BY 1, 2\nORDER BY 1", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Monitored DBs by version", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 8, + "links": [], + "mode": "html", + "options": {}, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": false, + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 20, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'settings' ORDER BY 1;", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'settings' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT (data->'server_version_num')::int FROM settings WHERE time > now() - '24h'::interval ORDER BY 1 DESC", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "lower_than_server_version_num", + "options": [], + "query": "SELECT DISTINCT (data->'server_version_num')::int FROM settings WHERE time > now() - '24h'::interval ORDER BY 1 DESC", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Postgres Version Overview", + "uid": "postgres-version-overview", + "version": 1 + } + recommendations.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Needs \"recommendations\" metric to be enabled", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "More than 10 superusers is already suspicious", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 3, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'superuser_count'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Overusage of SUPERUSER", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 4, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n '-' AS pg_major_ver,\n '-' AS object_name,\n 'long running queries block autovacuum and thereby cause bloat' AS recommendation,\n 'longest_query_seconds: '|| max((data->'longest_query_seconds')::int)::text AS extra_info\nFROM\n backends\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\n AND (data->'longest_query_seconds')::int > 6\nGROUP BY\n dbname\nORDER BY\n max((data->'longest_query_seconds')::int) DESC NULLS LAST, dbname", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Overly long queries", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 10, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n (select data->>'server_version' from settings s where s.dbname = x.dbname order by time desc limit 1) AS pg_major_ver,\n 'autovacuum_max_workers' as object_name,\n 'if most / all autovacuum worker slots are busy or AV runs for hourse then this could hint at incorrect AV params or too much workload' as recommendation,\n 'max. active autovacuum workers: ' || max_av_workers || ' (of total ' || (select (data->'autovacuum_max_workers')::int from settings s where s.dbname = x.dbname order by time desc limit 1) || '); max. AV duration (seconds): ' || longest_autovacuum_seconds as extra_info\nFROM (\nSELECT\n dbname,\n max((data->'av_workers')::int) as max_av_workers,\n coalesce(max((data->'longest_autovacuum_seconds')::int), 0) as longest_autovacuum_seconds\nFROM\n backends\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\nGROUP BY\n dbname\n) x\nWHERE\n (max_av_workers > 1 AND max_av_workers::numeric / (select (data->'autovacuum_max_workers')::int from settings s where s.dbname = x.dbname order by time desc limit 1) >= 0.6)\n OR\n (longest_autovacuum_seconds > 1800)", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Possible AUTOVACUUM problems", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 15 + }, + "id": 5, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'sprocs_wo_search_path'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "SECURITY DEFINER without fixed \"search_path\"", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 6, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'default_public_schema_privs'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "PUBLIC schemas with default privileges", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Assumes that \"pg_qualstats\" extension and superuser or according access grants on the monitored host", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 7, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'create_index'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Possibly missing indexes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Unused indexes bigger than 0.5% of total DB size", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 8, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'drop_index'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Unused indexes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "A lot of space / performance can be won on replacing columns that contain mostly NULL-s but are fully indexed with partial indexes, leaving out NULL-s", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 12, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'partial_index_candidates'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Partial index suggestions", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 40 + }, + "id": 2, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'overly_nested_views'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Deeply nested views", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "More often than checkpoint_timeout / 2. To improve increase checkpoint_timeout or max_wal_size, which will reduce total IO amount done due to the way how Full Page Writes are handled.", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 45 + }, + "id": 11, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n (select data->>'server_version' from settings s where s.dbname = y.dbname order by s.time desc limit 1) as pg_major_ver,\n 'global server settings' as object_name,\n 'Increase checkpoint_timeout or max_wal_size for more infrequent checkpoints, thereby reducing total IO' AS recommendation,\n 'avg. seconds between checkpoint requests: ' || avg_seconds_between_checkpoints_reqs::int8 as extra_info\nFROM (\nSELECT\n dbname,\n round((extract(epoch from max_time - min_time) / (max_req - min_req))::numeric, 1) as avg_seconds_between_checkpoints_reqs\nFROM (\n SELECT\n dbname,\n min(time) as min_time,\n max(time) as max_time,\n min((data->'checkpoints_req')::int8) as min_req,\n max((data->'checkpoints_req')::int8) as max_req\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\nGROUP BY\n dbname\nHAVING\n max((data->'checkpoints_req')::int8) > min((data->'checkpoints_req')::int8)\n) x\n) y\nWHERE\n avg_seconds_between_checkpoints_reqs < (select extract(epoch from (data->>'checkpoint_timeout')::interval) / 2.0 from settings s where s.dbname = y.dbname order by s.time desc limit 1)\nORDER BY\n avg_seconds_between_checkpoints_reqs\nLIMIT\n 25", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Checkpoints requested too often", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "description": "", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 50 + }, + "id": 9, + "mode": "html", + "options": {}, + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n data->>'major_ver' AS pg_major_ver,\n tag_data->>'object_name' AS object_name,\n data->>'recommendation' AS recommendation,\n data->>'extra_info' AS extra_info\nFROM\n recommendations\nWHERE\n time IN (SELECT max(time) FROM recommendations WHERE $__timeFilter(time) GROUP BY dbname)\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' = 'drop_index'\nORDER BY\n dbname, object_name", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 20, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM recommendations WHERE time > now() - '2d'::interval ORDER BY 1;", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM recommendations WHERE time > now() - '2d'::interval ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-24h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Recommendations", + "uid": "recommendations", + "version": 1 + } + replication.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "#bf1b00", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Based on last 5m data. > 1 ~ Error. Causes WAL accumulation on the master and possibly autovacuum inefficiencies", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 0, + "y": 0 + }, + "hideTimeOverride": true, + "id": 4, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select sum(\"last\") from (select last(\"non_active_int\") FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"dbname\", \"slot_name\")", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n sum((data->'non_active_int')::int)\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "active" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,1000", + "timeFrom": "5m", + "title": "Inactive repl. slots", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "#bf1b00", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Based on last 5m data. FYI - no thresholds defined", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 3, + "y": 0 + }, + "hideTimeOverride": true, + "id": 13, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select count(\"active\") from (select last(\"active\") as \"active\" FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"dbname\", \"slot_name\") WHERE \"active\" = true", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n count(*) filter (where data->>'non_active_int' = '0')\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "active" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,1000", + "timeFrom": "5m", + "title": "Active repl. slots", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Data is available only on connected replicas. No thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 6, + "y": 0 + }, + "hideTimeOverride": true, + "id": 14, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select count(\"last\") from (SELECT last(\"state\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time(1d), dbname, client_info fill(none)) where \"last\" = 'streaming'", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n count(*)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "replay_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "100000000,1000000000", + "timeFrom": "5m", + "title": "Active replicas", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 0, + "description": "Data is available only on connected replicas. No thresholds by default", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 9, + "y": 0 + }, + "hideTimeOverride": true, + "id": 15, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select sum(\"last\") from (SELECT last(\"is_sync_int\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time(1d), dbname, client_info fill(none))", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n count(*) filter (where data->>'is_sync_int' = '1') \nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "replay_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "5m", + "title": "Active \"sync\" replicas", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Based on last 5m of \"pg_replication_slots.restart_lsn\" and translates to \"overhead\" WAL folder size", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 12, + "y": 0 + }, + "hideTimeOverride": true, + "id": 7, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"restart_lsn_lag_b\") FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1d) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'restart_lsn_lag_b')::int8)\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "restart_lsn_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "16000000,1000000000", + "timeFrom": "5m", + "title": "Slot max. restart_lsn lag", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Data is available only on connected replicas! Based on last 5m data.", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 15, + "y": 0 + }, + "hideTimeOverride": true, + "id": 6, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"write_lag_b\") FROM \"replication\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'write_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "write_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "100000000,1000000000", + "timeFrom": "5m", + "title": "Max. write lag", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Data is available only on connected replicas! Based on last 5m data.", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 18, + "y": 0 + }, + "hideTimeOverride": true, + "id": 16, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"write_lag_b\") FROM \"replication\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'flush_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "flush_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "100000000,1000000000", + "timeFrom": "5m", + "title": "Max. flush lag", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": 1, + "description": "Data is available only on connected replicas! Based on last 5m data.", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 21, + "y": 0 + }, + "hideTimeOverride": true, + "id": 9, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1d" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"replay_lag_b\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n max((data->'replay_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "replay_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "100000000,1000000000", + "timeFrom": "5m", + "title": "Max. replay lag", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_replication_slots. Primary only", + "fill": 1, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 2 + }, + "id": 2, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dbname]] slot=[[tag_slot_name]]", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dbname" + ], + "type": "tag" + }, + { + "params": [ + "slot_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n max((data->'restart_lsn_lag_b')::int8)\nFROM\n replication_slots\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2\n\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "restart_lsn_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Replication slot restart_lsn lag (primary extra WAL size)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_stat_replication on primaries. Data is available only on connected replicas!", + "fill": 1, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 6 + }, + "id": 17, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dbname]] [[tag_application_name]] [[tag_client_info]]", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dbname" + ], + "type": "tag" + }, + { + "params": [ + "client_info" + ], + "type": "tag" + }, + { + "params": [ + "application_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"write_lag_b\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time($__interval), \"dbname\", \"client_info\", \"application_name\" fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->'flush_lag_b')::int8)\nFROM\n replication\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n \n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "flush_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Replication flush lag", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_stat_replication on primaries. Data is available only on connected replicas!", + "fill": 1, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 8, + "interval": "15m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dbname]] [[tag_application_name]] [[tag_client_info]]", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dbname" + ], + "type": "tag" + }, + { + "params": [ + "client_info" + ], + "type": "tag" + }, + { + "params": [ + "application_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->'replay_lag_b')::int8)\nFROM\n replication\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n \n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "replay_lag_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Replication replay lag", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on \"pg_replication_slots.xmin\". The oldest transaction that this slot needs the database to retain. VACUUM cannot remove tuples deleted by any later transaction.", + "fill": 1, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 10, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dbname]] [[tag_slot_name]]", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dbname" + ], + "type": "tag" + }, + { + "params": [ + "plugin" + ], + "type": "tag" + }, + { + "params": [ + "slot_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "replication_slots", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->'xmin_age_tx')::int8)\nFROM\n replication_slots\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xmin_age_tx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Repl. slot XMIN age (in transactions)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 12, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": false, + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric IN ('replication', 'replication_slots') ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Replication", + "uid": "replication", + "version": 1 + } + server-log-events.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Assumes local (on DB server) setup and CSVLOG output format", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": { + "fatal": "super-light-red", + "panic": "dark-purple" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "description": "Based on 'server_log_event_counts' metric. Assumes local (on DB server) setup and CSVLOG output format", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "interval": "", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum((data->'debug')::int8) as debug,\n sum((data->'log')::int8) as log,\n sum((data->'notice')::int8) as notice, \n sum((data->'warning')::int8) as warning,\n sum((data->'error')::int8) as error,\n sum((data->'fatal')::int8) as fatal,\n sum((data->'panic')::int8) as panic\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Server log events (DB)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "fatal": "super-light-red", + "panic": "dark-purple" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "description": "Based on 'server_log_event_counts' metric. Assumes local (on DB server) setup and CSVLOG output format", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 10 + }, + "hiddenSeries": false, + "id": 3, + "interval": "", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum((data->'debug_total')::int8) as debug,\n sum((data->'log_total')::int8) as log,\n sum((data->'notice_total')::int8) as notice, \n sum((data->'warning_total')::int8) as warning,\n sum((data->'error_total')::int8) as error,\n sum((data->'fatal_total')::int8) as fatal,\n sum((data->'panic_total')::int8) as panic\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Server log events (whole instance)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 20 + }, + "id": 5, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": null, + "pattern": "/ERROR|FATAL/", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to DB overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n sum((data->'error')::int8) as \"ERROR\",\n sum((data->'error_total')::int8) as \"ERROR_TOTAL\",\n sum((data->'fatal')::int8) as \"FATAL\", \n sum((data->'fatal_total')::int8) as \"FATAL_TOTAL\"\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT\n 20\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top ERROR generating DBs", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 20 + }, + "id": 6, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 1, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": null, + "pattern": "/ERROR|FATAL/", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to DB overview dash", + "linkUrl": "/d/db-overview?var-dbname=${__cell}", + "mappingType": 1, + "pattern": "dbname", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n dbname,\n sum((data->'fatal_total')::int8) as \"FATAL_TOTAL\",\n sum((data->'fatal')::int8) as \"FATAL\",\n sum((data->'error_total')::int8) as \"ERROR_TOTAL\",\n sum((data->'error')::int8) as \"ERROR\"\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT\n 20\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Top FATAL generating instances", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 28 + }, + "id": 8, + "mode": "html", + "options": {}, + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 20, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'server_log_event_counts' ORDER BY 1;", + "hide": 0, + "includeAll": true, + "index": -1, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'server_log_event_counts' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "5m", + "value": "5m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": true, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Server Log Events", + "uid": "server-log-events", + "version": 1 + } + sessions-overview.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "interval": "", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Max. TPS / QPS", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "avg_query": "super-light-purple", + "longest_query": "dark-orange" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 6 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'longest_query_seconds')::int8) as longest_query,\n max((data->'avg_query_seconds')::float) as avg_query\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Longest query duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "longest_waiting": "dark-red", + "longest_waiting_seconds": "light-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 12 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "avg": false, + "current": false, + "max": true, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'longest_waiting_seconds')::int8) as longest_waiting,\n max((data->'avg_waiting_seconds')::float) as avg_waiting\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Longest wait duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "avg_tx": "light-blue", + "longest_tx": "dark-purple", + "longest_tx_seconds": "dark-purple" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "avg": false, + "current": false, + "max": true, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'longest_tx_seconds')::int8) as longest_tx,\n max((data->'avg_tx_seconds')::float) as avg_tx\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Longest TX duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "longest_session_seconds": "dark-orange" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 24 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "avg": false, + "current": false, + "max": true, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'longest_session_seconds')::int8) as longest_session,\n max((data->'avg_session_seconds')::float) as avg_session\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Longest session duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "longest_autovacuum_seconds": "light-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 30 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": true, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "longest_autovacuum_seconds", + "yaxis": 1 + }, + { + "alias": "max_av_workers", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'longest_autovacuum_seconds')::int8) as longest_autovacuum_seconds\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'av_workers')::int8) as max_av_workers\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Longest Autovacuum duration / # AV workers", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 0, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Max. value per $agg_interval", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 36 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'active')::int8) as active,\n max((data->'total')::int8) as total_db,\n max((data->'idleintransaction')::int8) as idleintransaction,\n max((data->'waiting')::int8) as waiting\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Sessions by state", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "max_connections": "dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 0, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 42 + }, + "hiddenSeries": false, + "id": 11, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->'instance_total')::int8) as instance_total,\n max((data->'max_connections')::int8) as max_connections\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Instance total connections", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 3, + "w": 9, + "x": 0, + "y": 48 + }, + "id": 13, + "mode": "html", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": false, + "rawSql": "SELECT\n $__time(time_column),\n value1\nFROM\n metric_table\nWHERE\n $__timeFilter(time_column)\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": "", + "value": "" + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'backends' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'backends' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "tags": [], + "text": "5m", + "value": "5m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": true, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "1s,1m,5m,10m,15m,30m,1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Sessions overview", + "uid": "sessions-overview", + "variables": { + "list": [] + }, + "version": 1 + } diff --git a/helm/pgwatch/templates/grafana-deployment.yaml b/helm/pgwatch/templates/grafana-deployment.yaml new file mode 100644 index 0000000..5f91801 --- /dev/null +++ b/helm/pgwatch/templates/grafana-deployment.yaml @@ -0,0 +1,173 @@ +{{- if eq .Values.pgwatch.grafana.enable_grafana "true" }} +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + application: pgwatch + pgwatch.pods.role: grafana + name: grafana + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + application: pgwatch + pgwatch.pods.role: grafana + strategy: + type: Recreate + template: + metadata: + labels: + application: pgwatch + pgwatch.pods.role: grafana + spec: + containers: + - env: + - name: GF_AUTH_ANONYMOUS_ENABLED + value: "true" + - name: GF_AUTH_ANONYMOUS_ORG_ROLE + value: Admin + - name: GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH + value: /var/lib/grafana/dashboards/1-global-db-overview.json + # - name: GF_INSTALL_PLUGINS + # value: marcusolsson-treemap-panel + {{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} + - name: GF_DATABASE_TYPE + value: postgres + - name: GF_DATABASE_HOST + value: postgres-svc:5432 + - name: GF_DATABASE_NAME + value: pgwatch_grafana + - name: GF_DATABASE_SSL_MODE + value: disable + - name: GF_DATABASE_USER + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: username + - name: GF_DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: password + {{- else }} + - name: GF_DATABASE_TYPE + value: postgres + - name: GF_DATABASE_HOST + value: {{ .Values.pgwatch.postgres.use_existing_database.endpoint }} + - name: GF_DATABASE_NAME + value: {{ .Values.pgwatch.postgres.use_existing_database.database }} + - name: GF_DATABASE_SSL_MODE + value: {{ .Values.pgwatch.postgres.use_existing_database.sslmode }} + - name: GF_DATABASE_USER + value: {{ .Values.pgwatch.postgres.use_existing_database.username }} + - name: GF_DATABASE_PASSWORD + value: {{ .Values.pgwatch.postgres.use_existing_database.password }} + {{ end }} + image: grafana/grafana:10.4.7 + name: grafana + ports: + - containerPort: 3000 + protocol: TCP + volumeMounts: + - mountPath: /etc/grafana/provisioning/datasources/pg_ds.yml + name: grafana-datasources + subPath: pg_ds.yml + - mountPath: /etc/grafana/provisioning/dashboards/pg_db.yml + name: grafana-config + subPath: pg_db.yml + - mountPath: /var/lib/grafana/dashboards + name: grafana-dashboards + restartPolicy: Always + volumes: + - configMap: + items: + - key: postgres_datasource.yml + path: pg_ds.yml + name: grafana-datasources + name: grafana-datasources + - configMap: + items: + - key: postgres_dashboard.yml + path: pg_db.yml + name: grafana-config + name: grafana-config + - name: grafana-dashboards + projected: + sources: + - configMap: + name: grafana-dashboards-basics + optional: true + - configMap: + name: grafana-dashboards-others + optional: true + defaultMode: 416 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + application: pgwatch + name: grafana-datasources + namespace: {{ .Release.Namespace }} +data: + {{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} + postgres_datasource.yml: | + apiVersion: 1 + datasources: + - name: pg-metrics + type: postgres + url: postgres-svc:5432 + access: proxy + password: pgwatchadmin + user: pgwatch + database: pgwatch_metrics + basicAuth: true + isDefault: true + jsonData: + sslmode: disable + postgresVersion: 1700 + version: 1 + editable: true + {{- else }} + postgres_datasource.yml: | + apiVersion: 1 + datasources: + - name: pg-metrics + type: postgres + url: {{ .Values.pgwatch.postgres.use_existing_database.endpoint }}:{{ .Values.pgwatch.postgres.use_existing_database.port }} + access: proxy + password: {{ .Values.pgwatch.postgres.use_existing_database.password }} + user: {{ .Values.pgwatch.postgres.use_existing_database.username }} + database: {{ .Values.pgwatch.postgres.use_existing_database.database }} + basicAuth: true + isDefault: true + jsonData: + sslmode: {{ .Values.pgwatch.postgres.use_existing_database.sslmode | default "disable" }} + version: 1 + editable: true + {{ end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + application: pgwatch + name: grafana-config + namespace: {{ .Release.Namespace }} +data: + postgres_dashboard.yml: | + apiVersion: 1 + + providers: + - name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: false + updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards + options: + path: /var/lib/grafana/dashboards +{{ end }} diff --git a/helm/pgwatch/templates/grafana_dashboard_others.yaml b/helm/pgwatch/templates/grafana_dashboard_others.yaml new file mode 100644 index 0000000..ed9e078 --- /dev/null +++ b/helm/pgwatch/templates/grafana_dashboard_others.yaml @@ -0,0 +1,22972 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + application: pgwatch + name: grafana-dashboards-others + namespace: {{ .Release.Namespace }} +data: + 1-global-db-overview.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Avg. of all DBs over the whole selected period", + "editable": true, + "error": false, + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 0 + }, + "id": 1, + "interval": "15m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select mean(tx) from (SELECT non_negative_derivative(mean(\"xact_commit\"), 1s) + non_negative_derivative(mean(\"xact_rollback\"), 1s) as tx FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time(5m) fill(none))", + "rawQuery": true, + "rawSql": "select\n time,\n sum(avg) as tps\nfrom (\nselect\n $__timeGroup(time, $__interval),\n dbname,\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag))\nfrom (\n select\n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag,\n dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "TPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Avg. of all DBs over the whole selected period", + "editable": true, + "error": false, + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 4, + "y": 0 + }, + "height": "150", + "id": 2, + "interval": "15m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "QPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(calls) FROM (SELECT non_negative_derivative(mean(\"calls\"), 1s) AS calls FROM \"stat_statements_calls\" WHERE $timeFilter AND \"dbname\" =~ /^$dbname/ GROUP BY dbname, time(5m) fill(none))", + "rawQuery": true, + "rawSql": "select\n time,\n sum(avg) as qps\nfrom (\nselect\n $__timeGroup(time, $__interval),\n dbname,\n avg((c - c_lag) / extract(epoch from time - time_lag))\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag,\n dbname\n from stat_statements_calls\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\n) y\ngroup by 1\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "title": "QPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "description": "Avg. of all DBs over the whole selected period for regular (>10 calls) queries", + "editable": true, + "error": false, + "format": "ms", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 8, + "y": 0 + }, + "height": "150", + "id": 3, + "interval": "15m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "avg_query_runtime_per_db", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select mean(runtime) from (select non_negative_derivative(mean(\"total_time\")) / non_negative_derivative(mean(\"calls\")) as runtime from \"stat_statements\" WHERE \"dbname\" =~ /^$dbname/ AND $timeFilter AND calls > 100 GROUP BY dbname, time($__interval) fill(none))", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((tt-tt_lag)::numeric / (c-c_lag))\nfrom (\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, dbname\n from stat_statements_calls\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere c > c_lag and tt >= tt_lag and c > 100\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Query runtime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Sum of all DB changes over the whole selected period", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 12, + "y": 0 + }, + "height": "150", + "id": 4, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "db_size_change_last_hour", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select sum(diff) from (SELECT last(\"size_b\") - first(\"size_b\") as diff FROM \"db_size\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time(3650d) fill(none))", + "rawQuery": true, + "rawSql": "select\n time,\n sum(last_db_size) as total_size\nfrom (\nselect\n time,\n dbname,\n max(last_value) as last_db_size\nfrom (\n select\n date_trunc('hour', time) as time,\n dbname,\n last_value((data->'size_b')::int8) over w\n from\n db_size\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n window w as (\n partition by dbname, date_trunc('hour', time) order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n )\n) x\ngroup by 1, 2\n) y\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Total DB size ch.", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "diff" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Sum of all DBs. Based on a SQL based approximate.", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 16, + "y": 0 + }, + "height": "150", + "id": 5, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Bloat size", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_bloat_approx_summary", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select sum(bloat) from (SELECT last(\"approx_free_space_b\") - first(\"approx_free_space_b\") as bloat FROM \"table_bloat_approx_summary\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time(3650d) fill(none))", + "rawQuery": true, + "rawSql": "select\n $__unixEpochFrom() as time,\n sum(bloat) from\n(\n\n select distinct on (dbname)\n dbname,\n time,\n (data->'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time\n\n) a \n\nunion all\n\nselect\n $__unixEpochTo() as time,\n sum(bloat)\nfrom (\n\n select distinct on (dbname)\n dbname,\n time,\n (data->'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time desc\n \n) b", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "approx_free_space_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Total table bloat ch. (approx.)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "diff" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Avg. of all selected DB-s for the whole period", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 20, + "y": 0 + }, + "height": "150", + "id": 6, + "interval": "15m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "CPU Load Avg.", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 2 + }, + "hiddenSeries": false, + "id": 18, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select non_negative_derivative(mean(\"xact_commit\")) + non_negative_derivative(mean(\"xact_rollback\")) from \"db_stats\" WHERE \"dbname\" =~ /^$dbname/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->'xact_commit')::int8 as c, lag((data->'xact_commit')::int8) over w as c_lag,\n (data->'xact_rollback')::int8 as r, lag((data->'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1, 2\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TPS", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Based on pg_stat_statements.calls", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 10 + }, + "hiddenSeries": false, + "id": 17, + "interval": "", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, dbname\n from stat_statements_calls\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Queries per Second", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Requires \"pg_stat_statements\" on server. For regular queries (calls >10)", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 15, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select non_negative_derivative(last(\"total_time\")) / non_negative_derivative(last(\"calls\")) from \"stat_statements\" WHERE \"dbname\" =~ /^$dbname/ AND $timeFilter AND calls > 100 GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((tt-tt_lag)::numeric / (c-c_lag)) as avg_query_runtime\nfrom (\n select \n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, dbname\n from stat_statements_calls\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. query runtime", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "TX rollback ratio": "#890F02" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 26 + }, + "hiddenSeries": false, + "id": 8, + "interval": "5m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT (non_negative_derivative(mean(\"xact_rollback\")) / (non_negative_derivative(mean(\"xact_commit\")) + non_negative_derivative(mean(\"xact_rollback\"))) * 100) FROM \"db_stats\" WHERE $timeFilter GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(case when c = c_lag and r = r_lag then 0 else (((r - r_lag)::numeric * 100) / ((c - c_lag) + (r - r_lag)) ) end) as tx_err_ratio\nfrom (\n select \n (data->'xact_commit')::int8 as c, lag((data->'xact_commit')::int8) over w as c_lag,\n (data->'xact_rollback')::int8 as r, lag((data->'xact_rollback')::int8) over w as r_lag,\n time, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag\ngroup by 1, 2\norder by 1, 2", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TX error ratio", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 34 + }, + "hiddenSeries": false, + "id": 19, + "interval": "30m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT last(\"size_b\") FROM \"db_size\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval) as time,\n dbname,\n avg((data->'size_b')::int8) db_size\nfrom\n db_size\nwhere \n dbname in ($dbname)\n and $__timeFilter(time)\ngroup by\n 1, 2\norder by\n 1, 2", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "DB size", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Requires according \"metric fetching helpers\" on the monitored server", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 42 + }, + "hiddenSeries": false, + "id": 12, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "avg_query_runtime", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU load", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "#Backends": "#F9E2D2", + "Deadlocks (1h rate)": "#BF1B00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 49 + }, + "hiddenSeries": false, + "id": 9, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n sum(tb-tb_lag) as temp_bytes\nfrom (\n select \n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n time, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere tb >= tb_lag\ngroup by 1, 2\norder by 1, 2\n", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Temp bytes written", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "bytes", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "DB Size": "#2F575E", + "WAL rate": "#0A50A1" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 56 + }, + "height": "", + "hiddenSeries": false, + "id": 10, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "wal", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((wal-wal_lag) / extract(epoch from (time - time_lag))) as \"WAL rate\"\nfrom (\n select \n (data->>'xlog_location_b')::int8 as wal, lag((data->>'xlog_location_b')::int8) over w as wal_lag,\n time, lag(time) over w as time_lag, dbname\n from wal\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere wal >= wal_lag and time > time_lag\ngroup by 1, 2\norder by 1, 2", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "xlog_location_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "WAL rate", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "Bps", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 0, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 64 + }, + "hiddenSeries": false, + "id": 16, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": false, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT ( non_negative_derivative(mean(\"blks_hit\")) / (non_negative_derivative(mean(\"blks_hit\")) + non_negative_derivative(mean(\"blks_read\")))) * 100 FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg( case when hit=hit_lag and read=read_lag then null else (hit-hit_lag)::numeric / ((hit-hit_lag) + (read-read_lag))*100 end) as \"Shared buffers hit ratio\"\nfrom (\n select \n (data->>'blks_hit')::int8 as hit, lag((data->>'blks_hit')::int8) over w as hit_lag,\n (data->>'blks_read')::int8 as read, lag((data->>'blks_read')::int8) over w as read_lag,\n time, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere hit >= hit_lag or read >= read_lag\ngroup by 1, 2\norder by 1, 2", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared buffer hit ratio", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "percent", + "label": null, + "logBase": 1, + "max": "105", + "min": null, + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Based on pg_stat_activity info", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 73 + }, + "hiddenSeries": false, + "id": 11, + "interval": "15m", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "avg", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_dbname", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "0" + ], + "type": "fill" + } + ], + "measurement": "backends", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"idleintransaction\") + mean(\"waiting\") + mean(\"active\") FROM \"backends\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->'idleintransaction')::int + (data->'waiting')::int + (data->'active')::int) as sessions\nFROM\n backends\nWHERE\n $__timeFilter(time)\n and dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "idle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Non-idle sessions", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 81 + }, + "id": 14, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": false, + "tags": [], + "text": "yes", + "value": "yes" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "current_primaries_only", + "options": [ + { + "selected": true, + "text": "yes", + "value": "yes" + }, + { + "selected": false, + "text": "no", + "value": "no" + } + ], + "query": "yes,no", + "skipUrlSync": false, + "type": "custom" + }, + { + "allValue": null, + "current": { + "selected": false, + "text": "All", + "value": "$__all" + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;", + "hide": 0, + "includeAll": true, + "index": -1, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "15m", + "value": "15m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": true, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Global DB overview", + "uid": "global-db-overview", + "variables": { + "list": [] + }, + "version": 1 + } + aws-cloudwatch.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "decimals": 1, + "description": "The percentage of CPU utilization.\n\nUnits: Percent", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 0, + "y": 0 + }, + "height": "150", + "id": 1, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "CPU %", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "CPUUtilization", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "600", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"xact_commit\"), 1s) + non_negative_derivative(mean(\"xact_rollback\"), 1s) FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($interval) fill(none)", + "rawQuery": true, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "CPU load %", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "decimals": 0, + "description": "The average number of bytes written to disk per second.", + "editable": true, + "error": false, + "format": "bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 4, + "y": 0 + }, + "height": "150", + "id": 2, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Write bytes/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "WriteThroughput", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "600", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"calls\"), 1s) FROM \"stat_statements_calls\" WHERE $timeFilter AND \"dbname\" =~ /^$dbname$/ GROUP BY time(1s) fill(none)", + "rawQuery": true, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": "6h", + "title": "Write IO", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "decimals": 1, + "description": "The average number of bytes read from disk per second.", + "editable": true, + "error": false, + "format": "Bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 8, + "y": 0 + }, + "height": "150", + "id": 4, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Read bytes/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "ReadThroughput", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "600", + "policy": "default", + "query": "SELECT last(\"size_b\") - first(\"size_b\") FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h) fill(none)", + "rawQuery": true, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Read IO", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "description": "", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 12, + "y": 0 + }, + "height": "150", + "id": 3, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Connections", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "DatabaseConnections", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "600", + "policy": "default", + "query": "SELECT non_negative_derivative(last(\"total_time\"), 1h) / non_negative_derivative(last(\"calls\"), 1h) FROM \"stat_statements\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($interval) fill(none)", + "rawQuery": true, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Connections", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "decimals": 0, + "description": "The amount of available random access memory.", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 16, + "y": 0 + }, + "height": "150", + "id": 5, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Free mem", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "measurement": "table_bloat_approx_summary", + "metricName": "FreeableMemory", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "600", + "policy": "default", + "query": "SELECT \"load_5\" FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h) fill(none)", + "rawQuery": false, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "approx_free_space_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Free RAM", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "aws", + "decimals": 1, + "description": "The amount of available storage space.", + "editable": true, + "error": false, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 20, + "y": 0 + }, + "height": "150", + "id": 6, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "alias": "Free storage", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "measurement": "cpu_load", + "metricName": "FreeStorageSpace", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "1800", + "policy": "default", + "query": "SELECT \"load_5\" FROM \"db_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h) fill(none)", + "rawQuery": false, + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ] + } + ], + "thresholds": "", + "timeFrom": "6h", + "timeShift": null, + "title": "Free disk", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "decimals": 1, + "description": "Credit balance/usage apply only to T2 instances", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 4 + }, + "id": 7, + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "db_stats.mean", + "yaxis": 2 + }, + { + "alias": "DB size", + "yaxis": 2 + }, + { + "alias": "blk_read_time", + "yaxis": 2 + }, + { + "alias": "blk_write_time", + "yaxis": 2 + }, + { + "alias": "CPU credit usage", + "yaxis": 2 + }, + { + "alias": "CPU credit balance", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "CPU load", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "CPUUtilization", + "namespace": "AWS/RDS", + "period": "300", + "refId": "B", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "CPU credit balance", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "CPUCreditBalance", + "namespace": "AWS/RDS", + "period": "300", + "refId": "A", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "CPU credit usage", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "CPUCreditUsage", + "namespace": "AWS/RDS", + "period": "300", + "refId": "C", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU details", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "decimals": 0, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "IO queue depth": "#bf1b00", + "TX rollback ratio": "#890F02" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 4 + }, + "id": 8, + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "IO queue depth", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Write ops/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "WriteIOPS", + "namespace": "AWS/RDS", + "period": "300", + "refId": "A", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "Read ops/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "ReadIOPS", + "namespace": "AWS/RDS", + "period": "300", + "refId": "B", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "IO queue depth", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "DiskQueueDepth", + "namespace": "AWS/RDS", + "period": "300", + "refId": "C", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IOPS details", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "#Backends": "#F9E2D2", + "Deadlocks (1h rate)": "#BF1B00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 11 + }, + "id": 9, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "Deadlocks (1h rate)", + "yaxis": 1 + }, + { + "alias": "Temp bytes written", + "yaxis": 2 + }, + { + "alias": "Free RAM", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Free disk space", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "FreeStorageSpace", + "namespace": "AWS/RDS", + "period": "300", + "refId": "B", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "WAL size", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "TransactionLogsDiskUsage", + "namespace": "AWS/RDS", + "period": "300", + "refId": "C", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + }, + { + "alias": "Free RAM", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "FreeableMemory", + "namespace": "AWS/RDS", + "period": "300", + "refId": "A", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk/RAM details", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 0, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "DB Size": "#2F575E", + "WAL rate": "#0A50A1" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 11 + }, + "height": "", + "id": 10, + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "WAL rate (bytes/h)", + "yaxis": 2 + }, + { + "alias": "DB Size", + "yaxis": 2 + }, + { + "alias": "WAL bytes/s", + "yaxis": 1 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Write bytes/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "WriteThroughput", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "300", + "policy": "default", + "refId": "A", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + }, + { + "alias": "Read bytes/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "ReadThroughput", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "300", + "policy": "default", + "refId": "B", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + }, + { + "alias": "WAL bytes/s", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "dsType": null, + "expression": "", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "highResolution": false, + "id": "", + "metricName": "TransactionLogsGeneration", + "namespace": "AWS/RDS", + "orderByTime": "ASC", + "period": "300", + "policy": "default", + "refId": "C", + "region": "$region", + "resultFormat": "time_series", + "returnData": false, + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "statistics": [ + "Average" + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IO throughput", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 0, + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 15, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Connections", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "DatabaseConnections", + "namespace": "AWS/RDS", + "period": "300", + "refId": "B", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "aws", + "description": "For replicas only!", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 16, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Replication lag", + "dimensions": { + "DBInstanceIdentifier": "$dbname" + }, + "expression": "", + "highResolution": false, + "id": "", + "metricName": "ReplicaLag", + "namespace": "AWS/RDS", + "period": "300", + "refId": "B", + "region": "$region", + "returnData": false, + "statistics": [ + "Average" + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Replication lag", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 14, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": "aws", + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "region", + "options": [], + "query": "regions()", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": "aws", + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "dimension_values($region,AWS/RDS,CPUUtilization,DBInstanceIdentifier)", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "AWS CloudWatch overview", + "uid": "aws-cloudwatch-overview", + "version": 1 + } + biggest-relations.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "Depends on the \"Heatmap\" plugin. Based on latest \"table/index_stats\" data", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "iteration": 1703497578925, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "postgres" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "separator": "." + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 3, + "links": [], + "maxDataPoints": 100, + "options": { + "sizeField": "total_relation_size_b", + "textField": "table_name", + "tiling": "treemapSquarify" + }, + "targets": [ + { + "alias": "$tag_table_name", + "datasource": { + "type": "postgres" + }, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n (data->'total_relation_size_b')::int8 as total_relation_size_b,\n tag_data->>'table_full_name'::text as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest by total relation size", + "type": "marcusolsson-treemap-panel" + }, + { + "datasource": { + "type": "postgres" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "separator": "." + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 1, + "links": [], + "maxDataPoints": 100, + "options": { + "sizeField": "table_size_b", + "textField": "table_name", + "tiling": "treemapSquarify" + }, + "targets": [ + { + "alias": "$tag_table_name", + "datasource": { + "type": "postgres" + }, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "table_full_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n (data->'table_size_b')::int8 + coalesce((data->'toast_size_b')::int8, 0) as table_size_b,\n tag_data->>'table_full_name' as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=", + "value": "$dbname" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest tables (w/o indexes)", + "type": "marcusolsson-treemap-panel" + }, + { + "datasource": { + "type": "postgres" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "separator": "." + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 2, + "links": [], + "maxDataPoints": 100, + "options": { + "sizeField": "index_size_b", + "textField": "index_full_name", + "tiling": "treemapSquarify" + }, + "targets": [ + { + "alias": "$tag_index_name", + "datasource": { + "type": "postgres" + }, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n (data->'index_size_b')::int8 as index_size_b,\n tag_data->>'index_full_name' as index_full_name\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest indexes", + "type": "marcusolsson-treemap-panel" + }, + { + "datasource": { + "type": "postgres" + }, + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 29 + }, + "id": 4, + "links": [], + "options": { + "content": "Brought to you by: \"Cybertec", + "mode": "html" + }, + "pluginVersion": "8.5.20", + "transparent": true, + "type": "text" + } + ], + "refresh": "1m", + "schemaVersion": 36, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "postgres" + }, + "definition": "", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'table_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Biggest relations treemap", + "uid": "biggest-relations", + "version": 1, + "weekStart": "" + } + change-events.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + }, + { + "datasource": null, + "enable": true, + "iconColor": "rgba(255, 96, 96, 1)", + "limit": 100, + "name": "changes summary", + "query": "select details from object_changes where $timeFilter AND dbname = '$dbname'", + "rawQuery": "SELECT\n time,\n data->>'details' as text\nFROM\n object_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n", + "showIn": 0, + "type": "alert" + } + ] + }, + "description": "use change_events metric for capturing table/index/sproc/postgresql.conf changes", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": { + "Rollback ratio": "#BF1B00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "If there are no vertical red stripes then no changes were detected for that time period", + "fill": 1, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "rollback ratio", + "yaxis": 2 + }, + { + "alias": "Rollback ratio", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "CPU load", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "cpu_load", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->'load_5min')::float8) as \"load_5min\"\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [] + ], + "table": "cpu_load", + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "\"time\"", + "timeColumnType": "timestamptz", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "alias": "Rollback ratio", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "auto" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg( case when (xc = xc_lag and xr = xr_lag) then null else ( ((xr - xr_lag)::numeric*100) / ((xc - xc_lag) + (xr - xr_lag)) ) end ) as \"Rollback ratio\"\nfrom (\n select\n (data->'xact_rollback')::float8 as xr, lag((data->'xact_rollback')::float8) over w as xr_lag,\n (data->'xact_commit')::float8 as xc, lag((data->'xact_rollback')::float8) over w as xc_lag,\n time\n from db_stats\n where dbname = '$dbname'\n and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere xc >= xc_lag\ngroup by 1\norder by 1\n\n\n\n\n\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_5min" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "DDL / config change events", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": null, + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 7 + }, + "id": 2, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "1s" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "object_changes", + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n data->>'event' as event,\n tag_data->>'table' as table\nFROM\n table_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "details" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Table changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 7 + }, + "id": 3, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "1s" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "object_changes", + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n data->>'event' as event,\n tag_data->>'index' as index,\n data->>'table' as table\nFROM\n index_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "details" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Index changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 12 + }, + "id": 4, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time::time,\n data->>'event' as event,\n tag_data->>'sproc' as sproc\nFROM\n sproc_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Sproc changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "postgresql.conf settings changes", + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 12 + }, + "id": 5, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time::time,\n tag_data->>'setting' as event,\n data->>'value' as value\nFROM\n configuration_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Config changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Instance level", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 17 + }, + "id": 8, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n tag_data->>'role' as role,\n data->>'event' as event, \n data->>'privilege_type' as privilege_type\nFROM\n privilege_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND (data->>'privilege_type' = 'LOGIN'\n OR data->>'privilege_type' = 'SUPERUSER') \nORDER BY\n time, tag_data->>'role', data->>'privilege_type'", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Login and superuser role changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Per database", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "filterNull": false, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 17 + }, + "id": 9, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n tag_data->>'role' as role,\n data->>'event' as event, \n data->>'privilege_type' as privilege_type,\n tag_data->>'object' as object\nFROM\n privilege_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND data->>'privilege_type' != 'LOGIN'\n AND data->>'privilege_type' != 'SUPERUSER'\nORDER BY\n time, tag_data->>'role', data->>'privilege_type', data->>'object'", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Privilege changes", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 7, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 1, + "desc": false + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "date" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n (select time from settings where $__timeFilter(time) order by time desc limit 1) as \"Time\",\n key,\n value::text as value\nfrom (\n select * from jsonb_each((select data from settings where $__timeFilter(time) order by time desc limit 1))\n) x;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Settings", + "transform": "table", + "type": "table" + } + ], + "refresh": false, + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Change events", + "uid": "change-events", + "version": 1 + } + checkpointer-bgwriter-stats.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": { + "checkpoints_req": "semi-dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": true, + "values": true + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 3, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "checkpoints_timed", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "bgwriter", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, '$agg_interval'),\n sum(nullif(ct - ct_lag, 0)) as \"checkpoints_timed\",\n sum(nullif(cr - cr_lag, 0)) as \"checkpoints_req\"\nFROM (\n SELECT\n time,\n (data->'checkpoints_timed')::int8 as ct, lag((data->'checkpoints_timed')::int8) over w as ct_lag,\n (data->'checkpoints_req')::int8 as cr, lag((data->'checkpoints_req')::int8) over w as cr_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE ct >= ct_lag and cr >= cr_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "checkpoints_timed" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Checkpoints", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 5 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "checkpoint_write_time", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "1h" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "bgwriter", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, '$agg_interval'),\n sum(wt-wt_lag) as \"checkpoint_write_time\",\n sum(st-st_lag) as \"checkpoint_sync_time\"\nFROM (\n\n SELECT\n time,\n (data->'checkpoint_write_time')::int8 as wt, lag((data->'checkpoint_write_time')::int8) over w as wt_lag,\n (data->'checkpoint_sync_time')::int8 as st, lag((data->'checkpoint_sync_time')::int8) over w as st_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE wt >= wt_lag or st >= st_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "checkpoint_write_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Checkpointer Write / Sync durations", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 10 + }, + "hiddenSeries": false, + "id": 5, + "interval": "60m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "buffers_checkpoint", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "bgwriter", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n 8192 * sum(buffers_checkpoint-buffers_checkpoint_lag) as \"buffers_checkpoint\",\n 8192 * sum(buffers_clean-buffers_clean_lag) as \"buffers_clean\",\n 8192 * sum(buffers_backend-buffers_backend_lag) as \"buffers_backend\"\nFROM (\n SELECT\n time,\n (data->'buffers_checkpoint')::int8 as buffers_checkpoint, lag((data->'buffers_checkpoint')::int8) over w as buffers_checkpoint_lag,\n (data->'buffers_clean')::int8 as buffers_clean, lag((data->'buffers_clean')::int8) over w as buffers_clean_lag,\n (data->'buffers_backend')::int8 as buffers_backend, lag((data->'buffers_backend')::int8) over w as buffers_backend_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE buffers_checkpoint >= buffers_checkpoint_lag and buffers_clean >= buffers_clean_lag and buffers_backend >= buffers_backend_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "buffers_checkpoint" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Bgwriter Stats", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_stat_database. Requires \"track_io_timing=on\"", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 15 + }, + "hiddenSeries": false, + "id": 6, + "interval": "15m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "blk_read_time (backend)", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "5m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(rt-rt_lag) as \"blk_read_time\",\n sum(wt-wt_lag) as \"blk_write_time\"\nFROM (\n SELECT\n time,\n (data->'blk_read_time')::float8 as rt, lag((data->'blk_read_time')::float8) over w as rt_lag,\n (data->'blk_write_time')::float8 as wt, lag((data->'blk_write_time')::float8) over w as wt_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE rt >= rt_lag and wt >= wt_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blk_read_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Backend Read / Write times", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Reads could still be served by the Linux file system cache so they don't necessarily have to come from disk", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "hiddenSeries": false, + "id": 7, + "interval": "", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "heap_blks_read", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "15m" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_io_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n 8192 * sum(heap-heap_lag) as \"heap_blks_read\",\n 8192 * sum(idx-idx_lag) as \"idx_blks_read\",\n 8192 * sum(tidx-tidx_lag) as \"tidx_blks_read\",\n 8192 * sum(toast-toast_lag) as \"toast_blks_read\"\nFROM (\n SELECT\n time,\n (data->'heap_blks_read')::float8 as heap, lag((data->'heap_blks_read')::float8) over w as heap_lag,\n (data->'idx_blks_read')::float8 as idx, lag((data->'idx_blks_read')::float8) over w as idx_lag,\n (data->'tidx_blks_read')::float8 as tidx, lag((data->'tidx_blks_read')::float8) over w as tidx_lag,\n (data->'toast_blks_read')::float8 as toast, lag((data->'toast_blks_read')::float8) over w as toast_lag\n FROM\n table_io_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (partition by tag_data->>'table_full_name' order by time)\n) x\nWHERE heap >= heap_lag and idx >= idx_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "heap_blks_read" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Table / Index / Toast Blocks Read", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 10, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 9, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'bgwriter' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "tags": [], + "text": "1h", + "value": "1h" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": true, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "3h", + "value": "3h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "1s,1m,5m,10m,15m,30m,1h,3h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-24h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Checkpointer / Bgwriter / Block IO Stats", + "uid": "checkpointer-bgwriter-stats", + "version": 1 + } + documentation.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "content": "# Available metric tables overview\n\n### Metrics that are actually gathered need to be configured for every DB separately - for that open the Web UI config page [here](http://0.0.0.0:8080/dbs) or modify the \"pgwatch.monitored_host\" table directly in the \"pgwatch\" database\n\n* **archiver** - WAL archiving status/progress\n* **backends** - active, total, waiting sessions\n* **bgwriter** - pg_stat_bgwriter snapshots\n* **blocking_locks** - detailed info on sessions that are waiting\n* **change_events** - summary on object (DDL) and server configuration changes\n* **cpu_load** - CPU load info acquired via a plpython sproc (/pgwatch/sql/metric_fetching_helpers/)\n* **db_stats** - pg_stat_database snapshots\n* **db_size** - DB size info\n* **index_stats** - pg_stat_user_indexes snapshots\n* **kpi** - most important high level metrics\n* **locks** - different locktype (page, tuple, ...) counts. for usable data one should set the polling interval very low\n* **locks_mode** - different lock-mode (exclusive, share) counts. for usable data one should set the polling interval very low\n* **replication** - pg_stat_replication info (including replica lag)\n* **replication_slots** - pg_replication_slots info\n* **sproc_stats** - pg_stat_user_functions snapshots\n* **table_io_stats** - pg_statio_user_tables snapshots\n* **pgbouncer_stats** - pgbouncer (1.8+) statistics\n* **pgpool_stats** - pgpool-II (3.0+) statistics\n* **recommendations** - suggestion on possible security / performance issues\n* **stat_activity_realtime** - realtime view on pg_stat_activity\n* **stat_statements** - pg_stat_statements snapshots (requires the extension)\n* **stat_statements_calls** - total query count according to pg_stat_statements\n* **table_bloat_approx_summary** - bloat summary for the whole DB (needs *pgstattuple* extension)\n* **table_stats** - pg_stat_user_tables snapshots\n* **wal** - pg_current_(xlog_location|wal_lsn) values\n* **wal_receiver** - pg_stat_wal_receiver data on replica side\n* **wal_size** - WAL folder size\n\n# For getting started with Grafana in general start [here](http://docs.grafana.org/guides/getting_started/)\n\n\n# When stuck then additional support and consultations are available from Cybertec [here](https://www.cybertec-postgresql.com/en/contact/)", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 21, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "links": [], + "mode": "markdown", + "title": "Documentation", + "type": "text" + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 2, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Documentation", + "uid": "documentation", + "version": 1 + } + lock-details.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "Based on pg_locks", + "fill": 1, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_lockmode", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "lockmode" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "locks_mode", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n lockmode,\n avg(count)\nFROM (\nSELECT\n time,\n tag_data->>'lockmode' as lockmode,\n (data->'count')::int8 as count\nFROM\n locks_mode\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n) x\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "count" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Locking details (exp. scale)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 10, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric IN ('locks', 'locks_mode') ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Lock details", + "uid": "lock-details", + "version": 1 + } + pgbouncer-stats.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "#614d93", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Current \"Transaction Per Second\" based on total_xact_count", + "editable": true, + "error": false, + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 0, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 1, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_xact_count" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "15m", + "title": "TPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "#629e51", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Current \"Queries Per Second\" based on total_query_count", + "editable": true, + "error": false, + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 4, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 2, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "QPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_query_count" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "15m", + "title": "QPS", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Current value based on derivative of total_query_time / total_query_count", + "editable": true, + "error": false, + "format": "µs", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 8, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 3, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "avg_query_runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(last(\"total_query_time\"), 1h) / non_negative_derivative(last(\"total_query_count\"), 1h) FROM \"pgbouncer_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "15m", + "timeShift": null, + "title": "Avg. query runtime", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "#890f02", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Current avg. wait time to get a connection, per query", + "editable": true, + "error": false, + "format": "µs", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 12, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 4, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "db_size_change_last_hour", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(last(\"total_wait_time\")) / non_negative_derivative(last(\"total_query_count\")) FROM \"pgbouncer_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_wait_time" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "1h", + "timeShift": null, + "title": "Pool wait time", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#052b51", + "#64b0c8", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Current Incoming traffic based on total_received.", + "editable": true, + "error": false, + "format": "Bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 16, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 5, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "alias": "bytes_received", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_received" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "15m", + "timeShift": null, + "title": "Incoming traffic", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "#e24d42", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": null, + "decimals": 1, + "description": "Based on total_sent", + "editable": true, + "error": false, + "format": "Bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 20, + "y": 0 + }, + "height": "100", + "hideTimeOverride": true, + "id": 6, + "interval": "2m", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": " ", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_sent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "", + "timeFrom": "15m", + "timeShift": null, + "title": "Outgoing traffic", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "aliasColors": { + "TPS": "#584477" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "decimals": null, + "description": "Based on total_query_count", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 3 + }, + "id": 7, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "TPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_xact_count" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "TPS", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "Pool wait time": "#890f02", + "TX rollback ratio": "#890F02" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "decimals": null, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 3 + }, + "id": 8, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Pool wait time", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "db_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"total_wait_time\")) / non_negative_derivative(mean(\"total_query_count\")) FROM \"pgbouncer_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Pool wait time\"\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Pool wait time per Query", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "µs", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "#Backends": "#F9E2D2", + "Deadlocks (1h rate)": "#BF1B00", + "QPS": "#508642" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "decimals": null, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 9 + }, + "id": 9, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "Deadlocks (1h rate)", + "yaxis": 1 + }, + { + "alias": "Temp bytes written", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "QPS", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_query_count" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "QPS", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "DB Size": "#2F575E", + "Incoming byterate": "#65c5db", + "Incoming rate": "#6ed0e0", + "WAL rate": "#0A50A1" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "decimals": null, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 9 + }, + "height": "", + "id": 10, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Incoming rate", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Incoming rate\"\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_received" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Incoming traffic rate", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "Avg. runtime": "#ef843c" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "decimals": null, + "description": "", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 15 + }, + "id": 11, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "alias": "Avg. runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"total_query_time\"), 1h) / non_negative_derivative(mean(\"total_query_count\"), 1h) FROM \"pgbouncer_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\n\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. query runtime", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "µs", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "Outgoing byterate": "#e24d42", + "Outgoing rate": "#e24d42", + "load_5": "#BA43A9" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "description": "", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 15 + }, + "id": 12, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Outgoing rate", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "pgbouncer_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Outgoing rate\"\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_sent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Outgoing traffic rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 21 + }, + "id": 14, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": false, + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'pgbouncer_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "PgBouncer stats", + "uid": "pgbouncer-stats", + "version": 1 + } + pgpool-stats.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "Based on \"SHOW POOL_NODES\" and \"SHOW POOL_PROCESSES\".", + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "pageSize": null, + "showHeader": true, + "sort": { + "col": null, + "desc": false + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colorMode": "row", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "status_num", + "thresholds": [ + "1", + "1" + ], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "replication_delay", + "thresholds": [], + "type": "number", + "unit": "bytes" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n dbname,\n tag_data->>'node_id' as node_id,\n data->>'role' as role,\n data->>'status' as status,\n case when data->>'status' = 'up' then 1 else 0 end as status_num,\n data->>'hostname' as hostname,\n data->>'port' as port,\n data->>'lb_weight' as lb_weight,\n data->>'load_balance_node' as load_balance_node,\n data->>'replication_delay' as replication_delay,\n data->>'select_cnt' as select_cnt,\n data->>'processes_total' as processes_total,\n data->>'processes_active' as processes_active, \n data->>'last_status_change' as last_status_change, \n date_trunc('second', time::timestamp)::time as time\nfrom\n pgpool_stats\nwhere\n time = (select max(time) from pgpool_stats where dbname in ($dbname) and $__timeFilter(time) group by dbname)\n and dbname in ($dbname)\norder by\n dbname,\n node_id,\n time desc\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Pool node status", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 8 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n (max((data->'select_cnt')::int8) - min((data->'select_cnt')::int8))::int8 as select_cnt,\n dbname || ' (node: ' || (tag_data->>'node_id')::text || ')' as node_id\nFROM\n pgpool_stats\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 3\nORDER BY\n 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "SELECT load balancing per node ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 19 + }, + "id": 4, + "mode": "html", + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "tags": [], + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": null, + "definition": "select distinct dbname from admin.all_distinct_dbname_metrics where metric = 'pgpool_stats';", + "hide": 0, + "includeAll": true, + "index": -1, + "label": null, + "multi": true, + "name": "dbname", + "options": [], + "query": "select distinct dbname from admin.all_distinct_dbname_metrics where metric = 'pgpool_stats';", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "2m", + "value": "2m" + }, + { + "selected": false, + "text": "3m", + "value": "3m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,2m,3m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Pgpool Stats", + "uid": "pgpool-stats", + "variables": { + "list": [] + }, + "version": 1 + } + show-plans-realtime.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Based on the pg_show_plans extension", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "Based on the \"pg_show_plans\" extension and \"pg_stat_activity\" infos", + "fontSize": "100%", + "gridPos": { + "h": 22, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "/duration/", + "thresholds": [], + "type": "number", + "unit": "s" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "plan", + "preserveFormat": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "query", + "preserveFormat": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n (data->'max_s')::int AS max_duration,\n (data->'avg_s')::int AS avg_duration,\n (data->'count')::int AS count,\n data->>'users' AS users,\n data->>'query' AS query,\n data->>'plan' AS plan\nFROM\n show_plans_realtime\nWHERE\n time = (select max(time) from show_plans_realtime where $__timeFilter(time) and dbname = '$dbname' group by dbname)\n AND dbname = '$dbname'\nORDER BY\n max_duration DESC\nLIMIT\n 25\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Realtime execution plans", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 4, + "mode": "html", + "options": {}, + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": "5s", + "schemaVersion": 20, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'show_plans_realtime' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'show_plans_realtime' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Realtime execution plans", + "uid": "realtime-execution-plans", + "version": 1 + } + single-query-details.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "datasource": null, + "description": "For one query", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 3, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "avg_runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"total_time\")) / non_negative_derivative(mean(\"calls\")) FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(case when c = c_lag then null else (tt - tt_lag) / (c - c_lag) end) as avg_runtime\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n time\n from stat_statements\n where dbname = '$dbname' and tag_data @> '{\"queryid\": \"$queryid\"}' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. runtime ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 2, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "calls", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "queryid" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(c - c_lag) as \"calls\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where dbname = '$dbname' and tag_data @> '{\"queryid\": \"$queryid\"}' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "calls" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "$rate_unit" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Calls ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 1, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "total_runtime", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "queryid" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(case when tt = tt_lag then null else tt - tt_lag end) as \"total_time\"\nfrom (\n select\n time,\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag\n from stat_statements\n where dbname = '$dbname' and tag_data @> '{\"queryid\": \"$queryid\"}'and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere tt >= tt_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "$rate_unit" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total runtime ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 15 + }, + "id": 4, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "sb_hit_ratio", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"shared_blks_hit\")) / (non_negative_derivative(mean(\"shared_blks_hit\")) + non_negative_derivative(mean(\"shared_blks_read\"))) * 100 FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(case when hit = hit_lag and read = read_lag then null else ((hit-hit_lag)::numeric * 100) / ((hit-hit_lag) + (read-read_lag)) end) as \"sb_hit_ratio\"\nfrom (\n select \n (data->'shared_blks_hit')::int8 as hit, lag((data->'shared_blks_hit')::int8) over w as hit_lag,\n (data->'shared_blks_read')::int8 as read, lag((data->'shared_blks_read')::int8) over w as read_lag,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time) and tag_data @> '{\"queryid\": \"$queryid\"}'\n window w as (order by time)\n) x\nwhere hit >= hit_lag and read >= read_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shared_blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared Buffers Hit Ratio", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 5, + "interval": "5m", + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "temp_blks_written", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "queryid" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(read-read_lag) as \"temp_blks_read\",\n sum(written-written_lag) as \"temp_blks_written\"\nfrom (\n select \n (data->'temp_blks_read')::int8 as read, lag((data->'temp_blks_read')::int8) over w as read_lag,\n (data->'temp_blks_written')::int8 as written, lag((data->'temp_blks_written')::int8) over w as written_lag,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time) and tag_data @> '{\"queryid\": \"$queryid\"}'\n window w as (order by time)\n) x\nwhere read >= read_lag and written >= written_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temp_blks_written" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "$rate_unit" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Temp Blocks Read/Written ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "FYI - blk_write_time can easily be 0 as normally changes happen only in the shared buffers and are written out by the checkpointer / background writer.", + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 6, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "blk_read_time", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "queryid" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "stat_statements", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(read-read_lag) as \"blk_read_time\",\n sum(write-write_lag) as \"blk_write_time\"\nfrom (\n select \n (data->'blk_read_time')::int8 as read, lag((data->'blk_read_time')::int8) over w as read_lag,\n (data->'blk_write_time')::int8 as write, lag((data->'blk_write_time')::int8) over w as write_lag,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time) and tag_data @> '{\"queryid\": \"$queryid\"}'\n window w as (order by time)\n) x\nwhere read >= read_lag and write>= write_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "blk_read_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "$rate_unit" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "queryid", + "operator": "=~", + "value": "/^$queryid$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Backend block Read/Write time ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 8, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "io_time_pct", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT ((non_negative_derivative(mean(\"blk_read_time\")) + non_negative_derivative(mean(\"blk_write_time\"))) / non_negative_derivative(mean(\"total_time\"))) * 100 FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg(case when tt = tt_lag then null else (read-read_lag+write-write_lag)::numeric*100 / (tt-tt_lag) end) as \"io_time_pct\"\nfrom (\n select \n (data->'blk_read_time')::int8 as read, lag((data->'blk_read_time')::int8) over w as read_lag,\n (data->'blk_write_time')::int8 as write, lag((data->'blk_write_time')::int8) over w as write_lag,\n (data->'total_time')::int8 as tt, lag((data->'total_time')::int8) over w as tt_lag,\n time\n from stat_statements\n where dbname = '$dbname' and $__timeFilter(time) and tag_data @> '{\"queryid\": \"$queryid\"}'\n window w as (order by time)\n) x\nwhere read >= read_lag and write>= write_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "% of total_time spent in direct IO ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 9, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "Metric", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "Value", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "dsType": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n tag_data->>'query' as \"Value\"\nfrom stat_statements\nwhere dbname = '$dbname' and tag_data @> '{\"queryid\": \"$queryid\"}'\norder by time desc\nlimit 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "SQL", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 40 + }, + "id": 7, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "refresh": false, + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "select distinct tag_data->>'queryid' from stat_statements WHERE time > current_date -3 and dbname = '$dbname' order by 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "queryid", + "options": [], + "query": "select distinct tag_data->>'queryid' from stat_statements WHERE time > current_date -3 and dbname = '$dbname' order by 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "tags": [], + "text": "30m", + "value": "30m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": true, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Single query details", + "uid": "single-query-details", + "version": 1 + } + sproc-details.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "calls", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n time,\n sum(calls - calls_lag) as calls\nFROM (\nSELECT\n $__timeGroup(time, $agg_interval),\n (data->'sp_calls')::int8 as calls,\n lag((data->'sp_calls')::int8) OVER(order by time) as calls_lag\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> '{\"function_full_name\": \"$sproc_name\"}'\n) x\nWHERE calls >= calls_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "sp_calls" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "function_full_name", + "operator": "=~", + "value": "/^$sproc_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Calls ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 3, + "fill": 1, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 2, + "interval": "2m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null as zero", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "total_time", + "dsType": null, + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "auto" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg( case when calls = calls_lag then null else (total_time - total_time_lag) / (calls - calls_lag) end) as total_time,\n avg( case when calls = calls_lag then null else (self_time - self_time_lag) / (calls - calls_lag) end) as self_time\nFROM (\n SELECT\n (data->'sp_calls')::int8 as calls, lag((data->'sp_calls')::int8) over w as calls_lag,\n (data->'self_time')::float as self_time, lag((data->'self_time')::float) over w as self_time_lag,\n (data->'total_time')::float as total_time, lag((data->'total_time')::float) over w as total_time_lag,\n time, lag(time) over w as time_lag\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('function_full_name', '$sproc_name')\n WINDOW w AS (order by time)\n) x\nWHERE time > time_lag AND calls >= calls_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1h" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "function_full_name", + "operator": "=~", + "value": "/^$sproc_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Avg. runtime ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 3, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "schemaVersion": 19, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'sproc_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "select distinct tag_data->>'function_full_name' from sproc_stats where time > current_date-7 and dbname = '$dbname' and tag_data ? 'function_full_name' order by 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "sproc_name", + "options": [], + "query": "select distinct tag_data->>'function_full_name' from sproc_stats where time > current_date-7 and dbname = '$dbname' and tag_data ? 'function_full_name' order by 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "tags": [], + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Sproc details", + "uid": "sproc-details", + "version": 1 + } + sprocs-top.json: |- + { + "annotations": { + "list": [ + { + "$hashKey": null, + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.", + "fontSize": "100%", + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "$hashKey": null, + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "$hashKey": null, + "alias": "total_runtime", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "$hashKey": null, + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Sproc details' dashboard for that sproc", + "linkUrl": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__cell&from=$__from&to=$__to", + "pattern": "function_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "calls", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "oid", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"total_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "SELECT\n max((data->'total_time')::float8) - min((data->'total_time')::float8) as top,\n max((data->'sp_calls')::int8) - min((data->'sp_calls')::int8) as calls,\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "By Total Runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.", + "fontSize": "100%", + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 6 + }, + "id": 5, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "$hashKey": null, + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "$hashKey": null, + "alias": "total_runtime", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "$hashKey": null, + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Sproc details' dashboard for that sproc", + "linkUrl": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__cell&from=$__from&to=$__to", + "pattern": "function_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "calls", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "oid", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"self_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "SELECT\n max((data->'self_time')::float8) - min((data->'self_time')::float8) as top,\n max((data->'sp_calls')::int8) - min((data->'sp_calls')::int8) as calls, \n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "By Total Self Runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.", + "fontSize": "100%", + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 4, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "$hashKey": null, + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "$hashKey": null, + "alias": "calls", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "$hashKey": null, + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Sproc details' dashboard for that sproc", + "linkUrl": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__cell&from=$__from&to=$__to", + "pattern": "function_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_time", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "oid", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"sp_calls\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "SELECT\n max((data->'sp_calls')::int8) - min((data->'sp_calls')::int8) as top,\n max((data->'total_time')::float8) - min((data->'total_time')::float8) as total_time,\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "By Calls", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.", + "fontSize": "100%", + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 3, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "$hashKey": null, + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "$hashKey": null, + "alias": "avg_runtime", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "$hashKey": null, + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Sproc details' dashboard for that sproc", + "linkUrl": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__cell&from=$__from&to=$__to", + "pattern": "function_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "calls", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "oid", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select top(avg, \"function_full_name\", \"oid\", $top) AS top from (select mean(t) / mean(c) AS avg from (SELECT spread(\"total_time\") AS t, spread(\"sp_calls\") AS c FROM \"sproc_stats\" WHERE $timeFilter AND dbname = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) where $timeFilter AND c > 0 group by time(3650d), \"function_full_name\", \"oid\" )", + "rawQuery": true, + "rawSql": "SELECT\n total_time / calls as top,\n calls,\n function_full_name,\n oid\nFROM (\n SELECT\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid,\n max((data->'total_time')::float8) - min((data->'total_time')::float8) as total_time,\n max((data->'sp_calls')::int8) - min((data->'sp_calls')::int8) as calls\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1, 2\n) x\nWHERE calls > 0\nORDER BY 1 DESC NULLS LAST\nLIMIT $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "By Avg. Runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.", + "fontSize": "100%", + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 6, + "links": [], + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "$hashKey": null, + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "$hashKey": null, + "alias": "avg_runtime", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "$hashKey": null, + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Sproc details' dashboard for that sproc", + "linkUrl": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__cell&from=$__from&to=$__to", + "pattern": "function_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "calls", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "oid", + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "$hashKey": null, + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "sproc_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select top(avg, \"function_full_name\", \"oid\", $top) AS top from (select mean(t) / mean(c) AS avg from (SELECT spread(\"self_time\") AS t, spread(\"sp_calls\") AS c FROM \"sproc_stats\" WHERE $timeFilter AND dbname = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) where $timeFilter AND c > 0 group by time(3650d), \"function_full_name\", \"oid\" )", + "rawQuery": true, + "rawSql": "SELECT\n total_time / calls as top,\n calls,\n function_full_name,\n oid\nFROM (\n SELECT\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid,\n max((data->'self_time')::float8) - min((data->'self_time')::float8) as total_time,\n max((data->'sp_calls')::int8) - min((data->'sp_calls')::int8) as calls\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1, 2\n) x\nWHERE calls > 0\nORDER BY 1 DESC NULLS LAST\nLIMIT $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_time" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "By Avg. Self Runtime", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 30 + }, + "id": 8, + "links": [], + "mode": "html", + "options": {}, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": false, + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "text": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'sproc_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top", + "options": [ + { + "$hashKey": null, + "selected": false, + "text": "1", + "value": "1" + }, + { + "hashKey": null, + "selected": false, + "text": "3", + "value": "3" + }, + { + "$hashKey": null, + "selected": true, + "text": "5", + "value": "5" + }, + { + "$hashKey": null, + "selected": false, + "text": "10", + "value": "10" + }, + { + "$hashKey": null, + "selected": false, + "text": "15", + "value": "15" + }, + { + "$hashKey": null, + "selected": false, + "text": "20", + "value": "20" + }, + { + "$hashKey": null, + "selected": false, + "text": "30", + "value": "30" + }, + { + "$hashKey": null, + "selected": false, + "text": "40", + "value": "40" + }, + { + "$hashKey": null, + "selected": false, + "text": "50", + "value": "50" + } + ], + "query": "1,3,5,10,15,20,30,40,50", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Top Sprocs", + "uid": "top-sprocs", + "version": 1 + } + stat-activity-realtime.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "Top 25 longest running queries from pg_stat_activity. Query texts are compacted", + "fontSize": "100%", + "gridPos": { + "h": 24, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": {}, + "pageSize": null, + "showHeader": true, + "sort": { + "col": null, + "desc": false + }, + "styles": [ + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "pid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "rgba(237, 129, 40, 0.89)", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "duration", + "thresholds": [ + "60", + "300" + ], + "type": "number", + "unit": "s" + }, + { + "alias": "", + "colorMode": "value", + "colors": [ + "rgba(50, 172, 45, 0.97)", + "#C4162A", + "rgba(245, 54, 54, 0.9)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "waiting", + "thresholds": [ + "1", + "2" + ], + "type": "string", + "unit": "short", + "valueMaps": [ + { + "text": "no", + "value": "0" + }, + { + "text": "yes", + "value": "1" + } + ] + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "blocking_pids", + "thresholds": [], + "type": "string", + "unit": "short", + "valueMaps": [] + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n tag_data->>'pid' AS pid,\n data->>'user' AS user,\n data->>'appname' AS appname,\n data->>'ip' AS ip,\n (data->'duration_s')::int AS duration,\n data->>'waiting' AS waiting,\n coalesce(data->>'blocking_pids', '') AS blocking_pids,\n data->>'query' AS query\nFROM\n stat_activity_realtime\nWHERE\n dbname = '$dbname'\n AND time = (SELECT max(time) FROM stat_activity_realtime WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND (data->'duration_s')::int > $min_duration_s\nORDER BY\n duration DESC\nLIMIT 25\n\n\n\n\n\n\n\n\n\n\n\n\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Stat Activity", + "transform": "table", + "type": "table" + } + ], + "refresh": "5s", + "schemaVersion": 21, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_activity_realtime' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_activity_realtime' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "current": { + "text": "1", + "value": "1" + }, + "hide": 0, + "label": null, + "name": "min_duration_s", + "options": [ + { + "text": "1", + "value": "1" + } + ], + "query": "1", + "skipUrlSync": false, + "type": "textbox" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "1s", + "2s", + "3s", + "4s", + "5s", + "10s", + "30s", + "1m", + "5m", + "15m" + ] + }, + "timezone": "", + "title": "Stat Activity Realtime", + "uid": "stat-activity-realtime", + "version": 1 + } + stat-activity.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 1697, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": null, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 1, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 4, + "options": { + "legend": { + "calcs": [ + "firstNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": null, + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum((data->>'count')::integer) as \" \",\n data->>'query' as \"query\"\nfrom stat_activity\nwhere dbname = '$dbname' and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then\n not data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/'\n else\n true\n end\ngroup by 1,3\norder by 1;\n\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Active sessions detail", + "type": "timeseries" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "displayMode": "auto", + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "count" + }, + "properties": [ + { + "id": "custom.width", + "value": 61 + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 6, + "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "9.1.4", + "targets": [ + { + "datasource": null, + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select sum((data->>'count')::integer) as count, data->>'query' as query\nfrom stat_activity\nwhere dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then\n not data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/'\n else\n true\n end\ngroup by 2\norder by 1 desc;", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Queries", + "type": "table" + } + ], + "refresh": false, + "schemaVersion": 37, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_activity' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_activity' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "1m", + "value": "1m" + }, + "hide": 0, + "name": "agg_interval", + "options": [ + { + "selected": true, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "queryValue": "", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "current": { + "selected": false, + "text": "yes", + "value": "yes" + }, + "hide": 0, + "includeAll": false, + "multi": false, + "name": "hide_pgwatch_generated", + "options": [ + { + "selected": true, + "text": "yes", + "value": "yes" + }, + { + "selected": false, + "text": "no", + "value": "no" + } + ], + "query": "yes,no", + "queryValue": "", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Stat Activity", + "uid": "stat-activity", + "version": 11, + "weekStart": "" + } + stat-statements-sql-search.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 16, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": {}, + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/time/", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "calls", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Go to Query Details dash", + "linkUrl": "/d/single-query-details?var-dbname=$dbname&var-queryid=$__cell", + "mappingType": 1, + "pattern": "/queryid/", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/last_exec/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n total_time, mean_time, calls as total_calls, seconds_since_last_exec, queryid, query\nFROM (\n\nSELECT\n DISTINCT ON (queryid) queryid, time, total_time, mean_time, calls, query\nFROM (\n\nSELECT\n time, (data->'total_time')::float as total_time, (data->'total_time')::float / (data->'calls')::int8 as mean_time, (data->'calls')::int8 as calls, tag_data->>'queryid' as queryid, tag_data->>'query' as query\nFROM stat_statements\nWHERE\n dbname = '$dbname'\n AND time > now() - '$calls_interval'::interval\n AND tag_data->>'query' ~* '$sql_fragment'\n AND CASE WHEN length('$sql_fragment') > 2 THEN true ELSE false END\n) x\nORDER BY queryid, time DESC, mean_time, calls, query\n\n) y\nJOIN LATERAL \n (select (extract(epoch from now() - prev.time))::int8 as seconds_since_last_exec\n from stat_statements prev\n where dbname = '$dbname' and time > now() - '$calls_interval'::interval\n and prev.time < y.time and (prev.data->'calls')::int8 != y.calls\n order by time desc limit 1\n) z on true\n\nORDER BY total_time DESC LIMIT 100", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Matching Queries", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 4, + "mode": "html", + "options": {}, + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 19, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "current": { + "text": "", + "value": "" + }, + "hide": 0, + "label": "SQL search fragment (case insensitive, 3 char min.)", + "name": "sql_fragment", + "options": [ + { + "text": "", + "value": "" + } + ], + "query": "", + "skipUrlSync": false, + "type": "textbox" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "text": "12h", + "value": "12h" + }, + "hide": 0, + "label": "Having some executions within last", + "name": "calls_interval", + "options": [ + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": true, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "30m,1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Stat Statements SQL Search", + "uid": "stat-statements-sql-search", + "version": 1 + } + stat-statements-top-fast.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Assumes no pg_stat_statements reset appeared in the selected time frame", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 16, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total runtime", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "approx_pct_db_total_time", + "thresholds": [], + "type": "number", + "unit": "percent" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Avg. runtime", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "Calls", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"total_time\") FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n tt as top,\n tt / calls as \"Avg. runtime\",\n calls as \"Calls\",\n 100 * tt / (select sum(tt_agg) from (select tag_data->>'queryid', max((data->'total_time')::float) - min((data->'total_time')::float) as tt_agg from stat_statements where dbname = '$dbname' and $__timeFilter(time) group by 1 having count(*) > 1) x) as approx_pct_db_total_time,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 250 then query::varchar(250) || '...' else query end as query\nfrom (\n\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query,\n max((data->>'total_time')::numeric) - min((data->>'total_time')::numeric) as tt,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n min(time) as min_time,\n max(time) as max_time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n group by\n 1, 2\n\n) x\nwhere calls > 0 and tt > 0\norder by 1 desc nulls last\nlimit $top\n\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by total runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 15, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Avg. runtime", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Total time", + "thresholds": [], + "type": "number", + "unit": "ms" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select top(avg, \"queryid\", \"query\", $top) AS top from (select mean(t) / mean(c) AS avg from (SELECT spread(\"total_time\") AS t, spread(\"calls\") AS c FROM \"stat_statements\" WHERE $timeFilter AND dbname = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) where $timeFilter AND c > 0 group by time(3650d), \"queryid\", \"query\" )", + "rawQuery": true, + "rawSql": "select\n tt / calls as top,\n tt as \"Total time\",\n calls as \"Calls\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query,\n max((data->>'total_time')::numeric) - min((data->>'total_time')::numeric) as tt,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n group by\n 1, 2\n) x\nwhere calls > 0 and tt > 0\norder by 1 desc nulls last\nlimit $top\n\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by avg. runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 14, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Calls ", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Total time", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Avg. runtime", + "thresholds": [], + "type": "number", + "unit": "ms" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"calls\") FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n calls as top,\n total_time as \"Total time\",\n total_time / calls as \"Avg. runtime\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n max((data->>'total_time')::numeric) - min((data->>'total_time')::numeric) as total_time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n group by\n 1, 2\n) x\nwhere calls > 0\norder by 1 desc nulls last\nlimit $top\n\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by calls", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "total_time - blk_read_time -blk_write_time. Requires track_io_timing=on", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 13, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "CPU time", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Avg. runtime", + "thresholds": [], + "type": "number", + "unit": "ms" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n (tt - wt - rt)::int8 as top,\n calls as \"Calls\",\n tt / calls as \"Avg. runtime\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query,\n max((data->>'total_time')::float8) - min((data->>'total_time')::float8) as tt,\n max((data->>'blk_read_time')::float8) - min((data->>'blk_read_time')::float8) as rt,\n max((data->>'blk_write_time')::float8) - min((data->>'blk_write_time')::float8) as wt,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n group by\n 1, 2\n) x\nwhere tt - wt - rt > 0 and calls > 0\norder by 1 desc nulls last\nlimit $top\n\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by CPU time", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Does not include Shared Buffer activities. Same as 'By total runtime' if no direct IO was performed. Requires track_io_timing=on", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 12, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "IO time", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Total time", + "thresholds": [], + "type": "number", + "unit": "ms" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n wt + rt as top,\n tt as \"Total time\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, max(tag_data->>'query') as query,\n max((data->>'blk_read_time')::float8) - min((data->>'blk_read_time')::float8) as rt,\n max((data->>'blk_write_time')::float8) - min((data->>'blk_write_time')::float8) as wt,\n max((data->>'total_time')::float8) - min((data->>'total_time')::float8) as tt\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n group by\n 1\n) x\nwhere rt + wt > 0.1\norder by 1 desc nulls last\nlimit $top\n\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by direct (backend) IO", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Shared buffer + temp buffer reading / writing", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 11, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Block bandwith", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "decbytes" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Per call", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Avg. runtime", + "thresholds": [], + "type": "number", + "unit": "ms" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n (shared_blks_hit + shared_blks_read + shared_blks_dirtied + shared_blks_written)*8192 /*assuming default 8k block size*/ as top,\n (shared_blks_hit + shared_blks_read + shared_blks_dirtied + shared_blks_written)*8192 / calls as \"Per call\",\n calls as \"Calls\",\n total_time / calls as \"Avg. runtime\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid,\n tag_data->>'query' as query,\n max((data->>'shared_blks_hit')::int8) - min((data->>'shared_blks_hit')::int8) as shared_blks_hit,\n max((data->>'shared_blks_read')::int8) - min((data->>'shared_blks_read')::int8) as shared_blks_read,\n max((data->>'shared_blks_dirtied')::int8) - min((data->>'shared_blks_dirtied')::int8) as shared_blks_dirtied,\n max((data->>'shared_blks_written')::int8) - min((data->>'shared_blks_written')::int8) as shared_blks_written,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n max((data->>'total_time')::float) - min((data->>'total_time')::float) as total_time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n group by\n 1, 2\n) x\nwhere calls > 0\norder by 1 desc nulls last\nlimit $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top by block bandwith (assuming 8K blocks)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Based on pg_stat_statements.temp_blks_written", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 42 + }, + "id": 17, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Temp blocks written", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "decbytes" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Per call", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "/runtime/", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "Temp blocks read", + "thresholds": [], + "type": "number", + "unit": "bytes" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n temp_blks_written * 8192 /*assuming default 8k block size*/ as top,\n (temp_blks_read * 8192) / calls as \"Temp blocks read\",\n total_time as \"Total runtime\",\n calls as \"Calls\",\n total_time / calls as \"Avg. runtime\",\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\", \n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid,\n tag_data->>'query' as query,\n max((data->>'temp_blks_read')::int8) - min((data->>'temp_blks_read')::int8) as temp_blks_read,\n max((data->>'temp_blks_written')::int8) - min((data->>'temp_blks_written')::int8) as temp_blks_written,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n max((data->>'total_time')::float) - min((data->>'total_time')::float) as total_time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n group by\n 1, 2\n) x\nwhere temp_blks_written > 0\norder by 1 desc nulls last\nlimit $top", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top by temp blocks (assuming 8K blocks)", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 3, + "w": 12, + "x": 0, + "y": 49 + }, + "id": 4, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 12, + "x": 12, + "y": 49 + }, + "id": 18, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n0 as time,\ncoalesce ((\n\nselect 1 from (\nselect\n (data->'xact_commit')::int8 as xact_commit,\n lag((data->'xact_commit')::int8) over (order by time) as xact_commit_lag\nfrom\n db_stats\nwhere\n $__timeFilter(time)\n and dbname = '$dbname'\n) x\nwhere xact_commit_lag > xact_commit\nlimit 1\n\n), 0) as was_reset", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,1", + "title": "", + "transparent": true, + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "", + "value": "0" + }, + { + "op": "=", + "text": "WARNING: global stats reset detected for selected time range, results are unreliable - use the slower \"Stat Statements Top\" dashboard", + "value": "1" + } + ], + "valueName": "avg" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "tags": [], + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": false, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + }, + { + "selected": false, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "40", + "value": "40" + }, + { + "selected": true, + "text": "50", + "value": "50" + } + ], + "query": "1,3,5,10,15,20,30,40,50", + "skipUrlSync": false, + "type": "custom" + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "yes", + "value": "yes" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "hide_pgwatch_generated", + "options": [ + { + "selected": true, + "text": "yes", + "value": "yes" + }, + { + "selected": false, + "text": "no", + "value": "no" + } + ], + "query": "yes,no", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Stat statements Top (Fast)", + "uid": "stat-statements-top-fast", + "variables": { + "list": [] + }, + "version": 1 + } + stat-statements-top-visual.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "description": "Assumes that pg_stat_statement data has not been reset in the selected time frame. Click on the graph data links for the 'Query details' view.", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "interval": "", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "show": true, + "sort": "max", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [ + { + "targetBlank": true, + "title": "Query details", + "url": "/d/single-query-details?$__all_variables&var-queryid=${__series.name}&${__url_time_range}" + } + ] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n tag_data->>'queryid' as queryid\nFROM\n stat_statements\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data->>'queryid' IN (\n select tag_data->>'queryid'\n from stat_statements\n where $__timeFilter(time) and dbname = '$dbname'\n group by tag_data->>'queryid'\n having max((data->>'calls')::int8) - min((data->>'calls')::int8) > 0\n order by max((data->>'calls')::int8) - min((data->>'calls')::int8) desc\n limit $top\n )\nGROUP BY 1, 3\nORDER by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Top $top queries by calls", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "description": "Assumes that pg_stat_statement data has not been reset in the selected time frame. Click on the graph data links for the 'Query details' view.", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 12 + }, + "hiddenSeries": false, + "id": 3, + "interval": "", + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "show": true, + "sort": "max", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [ + { + "targetBlank": true, + "title": "Query details", + "url": "/d/single-query-details?$__all_variables&var-queryid=${__series.name}&${__url_time_range}" + } + ] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n max((data->>'total_time')::float) - min((data->>'total_time')::float) as total_time,\n tag_data->>'queryid' as queryid\nFROM\n stat_statements\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data->>'queryid' IN (\n select tag_data->>'queryid'\n from stat_statements\n where $__timeFilter(time) and dbname = '$dbname'\n group by tag_data->>'queryid'\n having max((data->>'total_time')::float) - min((data->>'total_time')::float) > 0\n order by max((data->>'total_time')::float) - min((data->>'total_time')::float) desc\n limit $top\n )\nGROUP BY 1, 3\nORDER by 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Top $top queries by total time", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 24 + }, + "id": 5, + "mode": "html", + "options": {}, + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "15m", + "value": "15m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": true, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "allValue": null, + "current": { + "selected": true, + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": true, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "7", + "value": "7" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + } + ], + "query": "1,3,5,7,10,15", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Stat Statements Top (Visual)", + "uid": "stat-statements-top-visual", + "version": 1 + } + stat-statements-top.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 5, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total runtime", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "approx_pct_db_total_time", + "thresholds": [], + "type": "number", + "unit": "percent" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n top,\n approx_pct_db_total_time,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n query\nfrom (\nselect\n (sum(tt - tt_lag))::int8 as top,\n round(((sum(tt - tt_lag))::int8 / total::numeric)*100, 1) as approx_pct_db_total_time,\n queryid,\n case when length(query) > 250 then query::varchar(250) || '...' else query end as query\nfrom (\nselect\n *,\n sum(tt - tt_lag) over() as total\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query, data->>'users' as users,\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere tt >= tt_lag\n) y\ngroup by total,queryid,query\nhaving sum(tt - tt_lag) > 0\norder by 1 desc nulls last\nlimit $top\n) z\norder by 1 desc nulls last", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by total runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 6, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Avg. runtime", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n top,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n query\nfrom (\nselect\n (avg((tt - tt_lag)::numeric / (calls - calls_lag)))::int8 as top,\n queryid,\n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query, data->>'users' as users,\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n (data->>'calls')::int8 as calls, lag((data->>'calls')::int8) over w as calls_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end\n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere calls > calls_lag\ngroup by 2, 3\norder by 1 desc nulls last\nlimit $top\n) z\norder by 1 desc nulls last", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by avg. runtime", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "90%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 7, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "linkTargetBlank": true, + "linkTooltip": "", + "linkUrl": "", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "sanitize": false, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Calls ", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "alias": "ass", + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n top,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n query\nfrom (\nselect\n sum(calls - calls_lag)::int8 as top,\n queryid,\n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query, data->>'users' as users,\n (data->>'calls')::int8 as calls, lag((data->>'calls')::int8) over w as calls_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere calls > calls_lag\ngroup by 2, 3\norder by 1 desc nulls last\nlimit $top\n) z\norder by 1 desc nulls last", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by calls", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Does not include Shared Buffer activities. Same as 'By total runtime' if no direct IO was performed. Requires track_io_timing=on", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 8, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "IO time", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n top,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n query\nfrom (\nselect\n sum((wt - wt_lag) + (rt - rt_lag))::int8 as top,\n queryid,\n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query, data->>'users' as users,\n (data->>'blk_read_time')::float8 as rt, lag((data->>'blk_read_time')::float8) over w as rt_lag,\n (data->>'blk_write_time')::float8 as wt, lag((data->>'blk_write_time')::float8) over w as wt_lag, \n time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere rt > rt_lag or wt > wt_lag\ngroup by 2, 3\norder by 1 desc nulls last\nlimit $top\n) z\norder by 1 desc nulls last", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top queries by direct (backend) IO", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Shared buffer + temp buffer reading / writing", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 10, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Block bandwith", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "top", + "thresholds": [], + "type": "number", + "unit": "decbytes" + }, + { + "alias": "Query ID", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Single query details' dashboard for that queryid", + "linkUrl": "/d/single-query-details?orgId=1&var-dbname=$dbname&var-queryid=$__cell&from=$__from&to=$__to", + "pattern": "queryid", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Query", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": true, + "linkTooltip": "Use 'edit' mode to be able to copy the query text", + "linkUrl": "", + "pattern": "query", + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT top(\"spread\", \"queryid\", \"query\", $top) FROM (SELECT spread(\"blk_read_time\") + spread(\"blk_write_time\") AS spread FROM \"stat_statements\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"queryid\", \"query\" fill(none) ) WHERE spread > 0", + "rawQuery": true, + "rawSql": "select\n top,\n queryid,\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = queryid order by time desc limit 1) as \"Users\",\n query\nfrom (\nselect\n sum(blocks_touched - blocks_touched_lag)*8192 /*assuming default 8k block size*/ as top,\n queryid,\n case when length(query) > 200 then query::varchar(200) || '...' else query end as query\nfrom (\n select\n tag_data->>'queryid' as queryid, tag_data->>'query' as query, data->>'users' as users,\n (data->>'shared_blks_hit')::int8 + (data->>'shared_blks_read')::int8 + (data->>'shared_blks_dirtied')::int8 + (data->>'shared_blks_written')::int8\n + (data->>'temp_blks_read')::int8 + (data->>'temp_blks_written')::int8 as blocks_touched,\n lag((data->>'shared_blks_hit')::int8 + (data->>'shared_blks_read')::int8 + (data->>'shared_blks_dirtied')::int8 + (data->>'shared_blks_written')::int8\n + (data->>'temp_blks_read')::int8 + (data->>'temp_blks_written')::int8) over w as blocks_touched_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and case when '$hide_pgwatch_generated' = 'yes' then not tag_data->>'query' ~* E'\\\\(extract\\\\(\\\\$\\\\d+\\\\W*from\\\\W*now\\\\(\\\\)\\\\)\\\\W?\\\\*\\\\W*\\\\$\\\\d+\\\\).*::\\\\w+\\\\W+as\\\\W+epoch_ns\\\\W*,'\n and not tag_data->>'query' ~* E'/\\\\*\\\\W*pgwatch_generated\\\\W*\\\\*/' else true end \n window w as (partition by tag_data->>'queryid' order by time)\n) x\nwhere blocks_touched >= blocks_touched_lag\ngroup by 2, 3\nhaving sum(blocks_touched - blocks_touched_lag) > 0\norder by 1 desc nulls last\nlimit $top\n) z\norder by 1 desc nulls last", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Top by block bandwith (assuming 8K blocks)", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 4, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "test", + "value": "test" + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": true, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + }, + { + "selected": false, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "40", + "value": "40" + }, + { + "selected": false, + "text": "50", + "value": "50" + } + ], + "query": "1,3,5,10,15,20,30,40,50", + "skipUrlSync": false, + "type": "custom" + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "yes", + "value": "yes" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "hide_pgwatch_generated", + "options": [ + { + "selected": true, + "text": "yes", + "value": "yes" + }, + { + "selected": false, + "text": "no", + "value": "no" + } + ], + "query": "yes,no", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Stat statements Top", + "uid": "stat-statements-top", + "version": 1 + } + system-stats-time-lag.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'cpu_utilization')::float8) \"CPU utilization\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg(cpu_utilization) \"CPU utilization-$lag_interval\"\nFROM (\nSELECT\n time + '$lag_interval'::interval as time,\n (data->'cpu_utilization')::float8 as cpu_utilization\nFROM\n psutil_cpu\nWHERE\n dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU utilization", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "hiddenSeries": false, + "id": 3, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'iowait')::float8) as \"IOWait\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg(iowait) \"IOWait-$lag_interval\"\nFROM (\nSELECT\n time + '$lag_interval'::interval as time,\n (data->'iowait')::float8 as iowait\nFROM\n psutil_cpu\nWHERE\n dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IO Wait", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "(total - available) / total * 100", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 14 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'percent')::float8) as \"Mem. used\"\nFROM\n psutil_mem\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg(used) \"Mem. used-$lag_interval\"\nFROM (\nSELECT\n time + '$lag_interval'::interval as time,\n (data->'percent')::float8 as used\nFROM\n psutil_mem\nWHERE\n dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Memory used (%)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 21 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'available')::float8) as \"Mem. available\"\nFROM\n psutil_mem\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg(available) \"Mem. available-$lag_interval\"\nFROM (\nSELECT\n time + '$lag_interval'::interval as time,\n (data->'available')::float8 as available\nFROM\n psutil_mem\nWHERE\n dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Memory available", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 28 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'swap_percent')::float8) as \"Swap used\"\nFROM\n psutil_mem\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg(swap_percent) \"Swap used-$lag_interval\"\nFROM (\nSELECT\n time + '$lag_interval'::interval as time,\n (data->'swap_percent')::float8 as swap_percent\nFROM\n psutil_mem\nWHERE\n dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n) x\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Swap used (%)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 35 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((read_bytes_lag - read_bytes) / extract(epoch from time_lag - time))::int8 as \"read_bytes_s\"\nFROM (\n SELECT\n time,\n lag(time) over w as time_lag,\n (data->'read_bytes')::int8 as read_bytes,\n lag((data->'read_bytes')::int8) over w as read_bytes_lag\n FROM\n psutil_disk_io_total\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w AS (ORDER BY time)\n) x\nWHERE read_bytes >= read_bytes_lag and time > time_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((read_bytes_lag - read_bytes) / extract(epoch from time_lag - time))::int8 as \"read_bytes_s-$lag_interval\"\nFROM (\n SELECT\n time + '$lag_interval'::interval as time,\n lag(time) over w + '$lag_interval'::interval as time_lag,\n (data->'read_bytes')::int8 as read_bytes,\n lag((data->'read_bytes')::int8) over w as read_bytes_lag\n FROM\n psutil_disk_io_total\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n WINDOW w AS (ORDER BY time)\n) x\nWHERE read_bytes >= read_bytes_lag and time > time_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total bytes read per second", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 42 + }, + "hiddenSeries": false, + "id": 9, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((write_bytes_lag - write_bytes) / extract(epoch from time_lag - time))::int8 as \"write_bytes_s\"\nFROM (\n SELECT\n time,\n lag(time) over w as time_lag,\n (data->'write_bytes')::int8 as write_bytes,\n lag((data->'write_bytes')::int8) over w as write_bytes_lag\n FROM\n psutil_disk_io_total\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w AS (ORDER BY time)\n) x\nWHERE write_bytes >= write_bytes_lag and time > time_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((write_bytes_lag - write_bytes) / extract(epoch from time_lag - time))::int8 as \"write_bytes_s-$lag_interval\"\nFROM (\n SELECT\n time + '$lag_interval'::interval as time,\n lag(time) over w + '$lag_interval'::interval as time_lag,\n (data->'write_bytes')::int8 as write_bytes,\n lag((data->'write_bytes')::int8) over w as write_bytes_lag\n FROM\n psutil_disk_io_total\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n WINDOW w AS (ORDER BY time)\n) x\nWHERE write_bytes >= write_bytes_lag and time > time_lag\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total bytes written per second", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric LIKE 'psutil%' ORDER BY 1;", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric LIKE 'psutil%' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "30m", + "value": "30m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": true, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "1d", + "value": "1d" + }, + "hide": 0, + "label": null, + "name": "lag_interval", + "options": [ + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": true, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-24h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Systems stats time lag comparison", + "uid": "systems-stats-time-lag-comparison", + "variables": { + "list": [] + }, + "version": 1 + } + system-stats.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Needs according psutil_* helper stored procedures installed on monitored Postgres DBs", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": { + "load (1min) normalized to #CPU": "#890f02", + "load 1min norm.": "#bf1b00", + "load_1min_norm": "#bf1b00", + "normalized to #CPU": "#890f02", + "utilization": "#bf1b00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "a.k.a. CPU run queue length or Load Average, reported e.g. by the \"uptime\" command", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 4, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/normalized/", + "linewidth": 4 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "normalized to #CPU", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_cpu", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'load_1m_norm')::float8) \"normalized to #CPU\",\n avg((data->'load_1m')::float8) \"as reported by /proc/loadavg\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load_1m_norm" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "System load ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "none", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": null, + "format": "none", + "label": "As reported by /proc/loadavg ", + "logBase": 10, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "load_1min_norm": "#bf1b00", + "utilization": "#bf1b00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "System-wide CPU utilization as reported by psutil.cpu_percent()", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 6 + }, + "id": 3, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "utilization", + "yaxis": 1 + }, + { + "alias": "load_1min_norm", + "yaxis": 2 + }, + { + "alias": "load 1min norm.", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "utilization", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_cpu", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'cpu_utilization')::float8) \"utilization\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpu_utilization" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU utilization % ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 2, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "idle", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "psutil_cpu", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'idle')::float8) as \"idle\",\n avg((data->'user')::float8) as \"user\",\n avg((data->'system')::float8) as \"system\",\n avg((data->'iowait')::float8) as \"iowait\",\n avg((data->'other')::float8) as \"other\",\n avg((data->'irqs')::float8) as \"irqs\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "idle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU usage distribution ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Doesn't have to necessarily equal 100% to values reported by the \"free\" command - see [here](https://psutil.readthedocs.io/en/latest/#psutil.virtual_memory) for more", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 5, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "used", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_mem", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'used')::float8) as \"used\",\n avg((data->'total')::float8) as \"total\",\n avg((data->'available')::float8) as \"available\",\n avg((data->'free')::float8) as \"free\",\n avg((data->'buff_cache')::float8) as \"buff_cache\"\nFROM\n psutil_mem\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "used" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Memory usage ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Doesn't have to necessarily equal 100% to values reported by the \"free\" command - see [here](https://psutil.readthedocs.io/en/latest/#psutil.virtual_memory) for more", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 6, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "swap_used", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_mem", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'swap_used')::float8) as \"swap_used\",\n avg((data->'swap_total')::float8) as \"swap_total\"\nFROM\n psutil_mem\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1\n", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "swap_used" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Swap usage ($agg_interval avg.)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "For all disks on the host, not only Postgres related", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 11, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "read_bytes", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_disk_io_total", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT * FROM (\nSELECT\n $__timeGroup(time, $agg_interval),\n max((data->'read_bytes')::int8) - min((data->'read_bytes')::int8) as \"read_bytes\",\n max((data->'write_bytes')::int8) - min((data->'write_bytes')::int8) as \"write_bytes\"\nFROM\n psutil_disk_io_total\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\n) x WHERE read_bytes >= 0 and write_bytes >= 0\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "read_bytes" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Host disk IO Totals ($agg_interval aggregate)", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "For Postgres data / WAL / log folder partitions and user defined tablespace partitions", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 36 + }, + "id": 7, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dir_or_tablespace]] ([[tag_path]])", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dir_or_tablespace" + ], + "type": "tag" + }, + { + "params": [ + "path" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_disk", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n (tag_data->>'dir_or_tablespace') || ' (' || (tag_data->>'path') || ')',\n avg((data->'percent')::float8) as \"percent\"\nFROM\n psutil_disk\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1, 2\nORDER BY 1, 2", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "percent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk usage %", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "For Postgres data / WAL / log folder partitions and user defined tablespace partitions", + "fill": 1, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 42 + }, + "id": 8, + "interval": "2m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "[[tag_dir_or_tablespace]] ([[tag_path]])", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "dir_or_tablespace" + ], + "type": "tag" + }, + { + "params": [ + "path" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "psutil_disk", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n (tag_data->>'dir_or_tablespace') || ' (' || (tag_data->>'path') || ')',\n avg((data->'free')::float8) as \"free\"\nFROM\n psutil_disk\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1, 2\nORDER BY 1, 2", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "free" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk space available", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 1, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 48 + }, + "id": 10, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "text": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric LIKE 'psutil%' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "System Stats", + "uid": "system-stats", + "version": 1 + } + table-details-time-lag.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(ins-ins_lag) as \"INSERT\"\nfrom (\n select \n (data->'n_tup_ins')::int8 as ins,\n lag((data->'n_tup_ins')::int8) over w as ins_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(ins-ins_lag) as \"INSERT-$lag_interval\"\nfrom (\n select \n (data->'n_tup_ins')::int8 as ins,\n lag((data->'n_tup_ins')::int8) over w as ins_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "INSERT-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 3, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(upd-upd_lag) as \"UPDATE\"\nfrom (\n select \n (data->'n_tup_upd')::int8 as upd,\n lag((data->'n_tup_upd')::int8) over w as upd_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(upd-upd_lag) as \"UPDATE-$lag_interval\"\nfrom (\n select \n (data->'n_tup_upd')::int8 as upd,\n lag((data->'n_tup_upd')::int8) over w as upd_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "UPDATE-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(del-del_lag) as \"DELETE\"\nfrom (\n select \n (data->'n_tup_del')::int8 as del,\n lag((data->'n_tup_del')::int8) over w as del_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(del-del_lag) as \"DELETE-$lag_interval\"\nfrom (\n select \n (data->'n_tup_del')::int8 as del,\n lag((data->'n_tup_del')::int8) over w as del_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "DELETE-s", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 27 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(seq_scan-seq_scan_lag) as seq_scan\nFROM ( \n SELECT\n (data->'seq_scan')::int8 as seq_scan, lag((data->'seq_scan')::int8) over w as seq_scan_lag,\n time\n FROM\n table_stats\n WHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(seq_scan-seq_scan_lag) as \"seq_scan-$lag_interval\"\nFROM ( \n SELECT\n (data->'seq_scan')::int8 as seq_scan, lag((data->'seq_scan')::int8) over w as seq_scan_lag,\n time + '$lag_interval'::interval as time\n FROM\n table_stats\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag\nGROUP BY 1\nORDER BY 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Seq. Scan", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": null, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 36 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(idx_scan-idx_scan_lag) as idx_scan\nFROM ( \n SELECT\n (data->'idx_scan')::int8 as idx_scan, lag((data->'idx_scan')::int8) over w as idx_scan_lag,\n time\n FROM\n table_stats\n WHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE idx_scan >= idx_scan_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(idx_scan-idx_scan_lag) as \"idx_scan-$lag_interval\"\nFROM ( \n SELECT\n (data->'idx_scan')::int8 as idx_scan, lag((data->'idx_scan')::int8) over w as idx_scan_lag,\n time + '$lag_interval'::interval as time\n FROM\n table_stats\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE idx_scan >= idx_scan_lag\nGROUP BY 1\nORDER BY 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Idx. Scan", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "i.e. the main table excluding indexes and TOAST", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 45 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap hit\"\nfrom (\n select \n (data->'heap_blks_hit')::int8 as hh, lag((data->'heap_blks_hit')::int8) over w as hh_lag,\n (data->'heap_blks_read')::int8 as hr, lag((data->'heap_blks_read')::int8) over w as hr_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag and hr >= hr_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap hit-$lag_interval\"\nfrom (\n select \n (data->'heap_blks_hit')::int8 as hh, lag((data->'heap_blks_hit')::int8) over w as hh_lag,\n (data->'heap_blks_read')::int8 as hr, lag((data->'heap_blks_read')::int8) over w as hr_lag,\n time +'$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag and hr >= hr_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared buffers hit rate - Heap", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 54 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 100 * avg( case when tr = tr_lag and th = th_lag and tir = tir_lag and tih = tir_lag then null else (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0))::numeric / (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) end ) as \"Toast hit\"\nfrom (\n select \n (data->'toast_blks_read')::int8 as tr, lag((data->'toast_blks_read')::int8) over w as tr_lag,\n (data->'toast_blks_hit')::int8 as th, lag((data->'toast_blks_hit')::int8) over w as th_lag,\n (data->'tidx_blks_read')::int8 as tir, lag((data->'tidx_blks_read')::int8) over w as tir_lag,\n (data->'tidx_blks_hit')::int8 as tih, lag((data->'tidx_blks_hit')::int8) over w as tih_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 100 * avg( case when tr = tr_lag and th = th_lag and tir = tir_lag and tih = tir_lag then null else (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0))::numeric / (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) end ) as \"Toast hit-$lag_interval\"\nfrom (\n select \n (data->'toast_blks_read')::int8 as tr, lag((data->'toast_blks_read')::int8) over w as tr_lag,\n (data->'toast_blks_hit')::int8 as th, lag((data->'toast_blks_hit')::int8) over w as th_lag,\n (data->'tidx_blks_read')::int8 as tir, lag((data->'tidx_blks_read')::int8) over w as tir_lag,\n (data->'tidx_blks_hit')::int8 as tih, lag((data->'tidx_blks_hit')::int8) over w as tih_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared buffers hit rate - Toast", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Assuming 8k blocks. Hit + read", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 63 + }, + "hiddenSeries": false, + "id": 9, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(hh-hh_lag+hr-hr_lag) as \"Heap read\"\nfrom (\n select \n (data->'heap_blks_hit')::int8 as hh, lag((data->'heap_blks_hit')::int8) over w as hh_lag,\n (data->'heap_blks_read')::int8 as hr, lag((data->'heap_blks_read')::int8) over w as hr_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hr >= hr_lag and hh >= hh_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(hh-hh_lag+hr-hr_lag) as \"Heap read-$lag_interval\"\nfrom (\n select \n (data->'heap_blks_hit')::int8 as hh, lag((data->'heap_blks_hit')::int8) over w as hh_lag,\n (data->'heap_blks_read')::int8 as hr, lag((data->'heap_blks_read')::int8) over w as hr_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hr >= hr_lag and hh >= hh_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Block bandwidth - Heap", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Assuming 8k blocks. Hit + read", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 72 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(ih-ih_lag+ir-ir_lag) as \"Idx read\"\nfrom (\n select \n (data->'idx_blks_hit')::int8 as ih, lag((data->'idx_blks_hit')::int8) over w as ih_lag,\n (data->'idx_blks_read')::int8 as ir, lag((data->'idx_blks_read')::int8) over w as ir_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere ir >= ir_lag and ih >= ih_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(ih-ih_lag+ir-ir_lag) as \"Idx read-$lag_interval\"\nfrom (\n select \n (data->'idx_blks_hit')::int8 as ih, lag((data->'idx_blks_hit')::int8) over w as ih_lag,\n (data->'idx_blks_read')::int8 as ir, lag((data->'idx_blks_read')::int8) over w as ir_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere ir >= ir_lag and ih >= ih_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Block bandwidth - Indexes", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "description": "Assuming 8k blocks. Hit + read", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 81 + }, + "hiddenSeries": false, + "id": 11, + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) as \"Toast read\"\nfrom (\n select \n (data->'toast_blks_read')::int8 as tr, lag((data->'toast_blks_read')::int8) over w as tr_lag,\n (data->'toast_blks_hit')::int8 as th, lag((data->'toast_blks_hit')::int8) over w as th_lag,\n (data->'tidx_blks_read')::int8 as tir, lag((data->'tidx_blks_read')::int8) over w as tir_lag,\n (data->'tidx_blks_hit')::int8 as tih, lag((data->'tidx_blks_hit')::int8) over w as tih_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "format": "time_series", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) as \"Toast read-$lag_interval\"\nfrom (\n select \n (data->'toast_blks_read')::int8 as tr, lag((data->'toast_blks_read')::int8) over w as tr_lag,\n (data->'toast_blks_hit')::int8 as th, lag((data->'toast_blks_hit')::int8) over w as th_lag,\n (data->'tidx_blks_read')::int8 as tir, lag((data->'tidx_blks_read')::int8) over w as tir_lag,\n (data->'tidx_blks_hit')::int8 as tih, lag((data->'tidx_blks_hit')::int8) over w as tih_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1", + "refId": "B", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Block bandwidth - Toast", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "SELECT DISTINCT tag_data->>'table_full_name' FROM table_stats WHERE time > now() - '1d'::interval AND dbname = '$dbname' ORDER BY 1", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "table_full_name", + "options": [], + "query": "SELECT DISTINCT tag_data->>'table_full_name' FROM table_stats WHERE time > now() - '1d'::interval AND dbname = '$dbname' ORDER BY 1", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "2m", + "value": "2m" + }, + { + "selected": false, + "text": "3m", + "value": "3m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + } + ], + "query": "1s,1m,2m,3m,5m,10m,15m,30m,1h,6h,12h,1d,7d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "selected": false, + "text": "1d", + "value": "1d" + }, + "hide": 0, + "label": null, + "name": "lag_interval", + "options": [ + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": true, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Table details time lag comparison", + "uid": "table-details-time-lag", + "variables": { + "list": [] + }, + "version": 1 + } + table-details.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "total_relation_size", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"total_relation_size_b\") FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND \"table_full_name\" =~ /^$table_full_name$/ AND $timeFilter GROUP BY time($interval) fill(none)", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->'table_size_b')::int8) as table_size,\n avg((data->'total_relation_size_b')::int8) as total_relation_size,\n avg((data->'toast_size_b')::int8) as toast_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "table_full_name", + "operator": "=~", + "value": "/^$table_full_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Size", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + "idx_scans": "#629E51", + "seq_scans": "#BF1B00" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 2, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "seq_scans", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg( ((seq_scan-seq_scan_lag)::numeric*3600) / extract(epoch from time - time_lag) ) as seq_scan,\n avg( ((idx_scan-idx_scan_lag)::numeric*3600) / extract(epoch from time - time_lag) ) as idx_scan\nFROM ( \n SELECT\n (data->'seq_scan')::int8 as seq_scan, lag((data->'seq_scan')::int8) over w as seq_scan_lag,\n (data->'idx_scan')::int8 as idx_scan, lag((data->'idx_scan')::int8) over w as idx_scan_lag,\n time, lag(time) over w as time_lag \n FROM\n table_stats\n WHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag and time > time_lag\nGROUP BY 1\nORDER BY 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "seq_scan" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "table_full_name", + "operator": "=~", + "value": "/^$table_full_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Scans (1h rate, $agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 3, + "interval": "5m", + "legend": { + "avg": true, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "INS", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg((ins-ins_lag) * 3600 / extract(epoch from time - time_lag)) as \"INSERT\",\n avg((upd-upd_lag) * 3600 / extract(epoch from time - time_lag)) as \"UPDATE\",\n avg((del-del_lag) * 3600 / extract(epoch from time - time_lag)) as \"DELETE\"\nfrom (\n select \n (data->'n_tup_ins')::int8 as ins, lag((data->'n_tup_ins')::int8) over w as ins_lag,\n (data->'n_tup_upd')::int8 as upd, lag((data->'n_tup_upd')::int8) over w as upd_lag,\n (data->'n_tup_del')::int8 as del, lag((data->'n_tup_del')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from table_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n\n) x\nwhere ins >= ins_lag and time > time_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "n_tup_ins" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "table_full_name", + "operator": "=~", + "value": "/^$table_full_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "IUD (1h rate, $agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "decimals": 1, + "editable": true, + "error": false, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 15 + }, + "id": 4, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Heap", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "table_io_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT non_negative_derivative(mean(\"heap_blks_hit\"), 10s) / (non_negative_derivative(mean(\"heap_blks_hit\"), 10s) + non_negative_derivative(mean(\"heap_blks_read\"), 10s)) * 100 FROM \"table_io_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND \"table_full_name\" =~ /^$table_full_name$/ AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap\",\n avg( case when ih = ih_lag and ir = ir_lag then null else (ih-ih_lag)::numeric * 100 / (ih-ih_lag+ir-ir_lag) end ) as \"Indexes\" \nfrom (\n select \n (data->'heap_blks_hit')::int8 as hh, lag((data->'heap_blks_hit')::int8) over w as hh_lag,\n (data->'heap_blks_read')::int8 as hr, lag((data->'heap_blks_read')::int8) over w as hr_lag,\n (data->'idx_blks_hit')::int8 as ih, lag((data->'idx_blks_hit')::int8) over w as ih_lag,\n (data->'idx_blks_read')::int8 as ir, lag((data->'idx_blks_read')::int8) over w as ir_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag\ngroup by 1\norder by 1", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "heap_blks_hit" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "dbname", + "operator": "=~", + "value": "/^$dbname$/" + }, + { + "condition": "AND", + "key": "table_full_name", + "operator": "=~", + "value": "/^$table_full_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Shared Buffers hit rates ($agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percent", + "label": null, + "logBase": 1, + "max": "100", + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "description": "", + "editable": true, + "error": false, + "fill": 1, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "height": "175", + "id": 5, + "interval": "5m", + "legend": { + "alignAsTable": false, + "avg": true, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_index_name", + "format": "time_series", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "index_name" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "index_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "rawQuery": true, + "rawSql": "select\n $__timeGroup(time, $agg_interval),\n index_name,\n avg( ((idx_scan - idx_scan_lag)::numeric * 3600) / extract(epoch from time - time_lag) )\nfrom (\n select \n (data->'idx_scan')::int8 as idx_scan, lag((data->'idx_scan')::int8) over w as idx_scan_lag,\n tag_data->>'index_name' as index_name,\n time, lag(time) over w as time_lag\n from index_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere idx_scan >= idx_scan_lag and time > time_lag\ngroup by 1, 2\norder by 1, 2", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "idx_scan" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "1m" + ], + "type": "non_negative_derivative" + } + ] + ], + "tags": [ + { + "key": "table_full_name", + "operator": "=~", + "value": "/^$table_full_name$/" + } + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Index Scans per index (1h rate, $agg_interval avg.)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": null, + "description": "Including manual VACUUM and AUTOVACUUM. 1 month WARNING threshold / 2 month ERROR threshold by default", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 8, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n (data->'seconds_since_last_vacuum')::int8\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "2592000,5184000", + "title": "Time since last VACUUM", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "decimals": null, + "description": "Including manual ANALYZE and AUTOVACUUM induced. 1 month WARNING threshold / 2 month ERROR threshold by default", + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 12, + "x": 12, + "y": 25 + }, + "id": 9, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n 0 as time,\n (data->'seconds_since_last_analyze')::int8\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nORDER BY time DESC\nLIMIT 1\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "2592000,5184000", + "title": "Time since last ANALYZE", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "content": "Brought to you by: \"Cybertec", + "editable": true, + "error": false, + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 6, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + } + ], + "schemaVersion": 18, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'table_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": null, + "tags": [], + "tagsQuery": null, + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "tags": [], + "text": null, + "value": null + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "table_full_name", + "options": [], + "query": "SELECT DISTINCT tag_data->>'table_full_name' FROM table_stats WHERE time > current_date-3 AND dbname = '$dbname' ORDER BY 1", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "auto": false, + "auto_count": 30, + "auto_min": "10s", + "current": { + "tags": [], + "text": "10m", + "value": "10m" + }, + "hide": 0, + "label": null, + "name": "agg_interval", + "options": [ + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": true, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Table details", + "uid": "table-details", + "version": 1 + } + tables-top.json: |- + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "columns": [], + "datasource": null, + "description": "Most views here assume that there was no stats reset in the selected time range!", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 12, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "data_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": null, + "rawQuery": true, + "rawSql": "select\n x.*,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nfrom (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'total_relation_size_b')::int8) as total_relation_size,\n max((data->'table_size_b')::int8) as data_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1, 2\nORDER BY 3 DESC NULLS LAST\nLIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true\n/*idea: show only primaries? */", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest (total)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 13, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "data_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": null, + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'total_relation_size_b')::int8) as total_relation_size,\n max((data->'table_size_b')::int8) as data_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1, 2\nORDER BY 4 DESC NULLS LAST\nLIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest (data)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 5, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "growth", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select dbname, table_full_name, top(growth, $top) as growth from (SELECT spread(\"total_relation_size_b\") as growth FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, table_full_name fill(none))", + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\n SELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'total_relation_size_b')::int8) - min((data->'total_relation_size_b')::int8) as growth,\n max((data->'total_relation_size_b')::int8) as total_relation_size\n FROM\n table_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1, 2\n ORDER BY growth DESC NULLS LAST\n LIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true\n\n/*\n-- for fully correct but slow version:\nSELECT\n dbname,\n table_full_name,\n max(last_value) - max(first_value) as growth,\n max(last_value) as total_relation_size,\n max(last_vacuum) as last_vacuum,\n max(last_analyze) as last_analyze\nFROM (\n SELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n first_value((data->'total_relation_size_b')::int8) over w,\n last_value((data->'total_relation_size_b')::int8) over w,\n last_value((data->'seconds_since_last_vacuum')::int8) over w as last_vacuum,\n last_value((data->'seconds_since_last_analyze')::int8) over w as last_analyze\n FROM\n table_stats\n WHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\n WINDOW w AS (partition by dbname, tag_data->>'table_full_name' order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)\n) x\nGROUP BY 1, 2\nORDER BY 3 DESC NULLS LAST\nLIMIT $top\n*/", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Biggest growth (total relation size)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 4, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "seq_scan", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "table_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": null, + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'table_size_b')::int8 as table_size,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'seq_scan')::int8) - min((data->'seq_scan')::int8) as seq_scan\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND (data->'table_size_b')::int8 > 100000000\nGROUP BY\n 1, 2\nHAVING\n max((data->'seq_scan')::int8) > min((data->'seq_scan')::int8)\nORDER BY\n 3 DESC\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Most \"seq. scans\" (tables > 100MB )", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 6, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "ins", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select dbname, table_full_name, top(ins, $top) as \"ins\" from (select mean(ins) as \"ins\" from (SELECT non_negative_derivative(last(\"n_tup_ins\"), 1h) as \"ins\" FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h), dbname, table_full_name fill(0)) GROUP BY dbname, table_full_name)", + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'total_relation_size_b')::int8 as total_relation_size,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'n_tup_ins')::int8) - min((data->'n_tup_ins')::int8) as ins\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1, 2\nHAVING\n max((data->'n_tup_ins')::int8) > min((data->'n_tup_ins')::int8)\nORDER BY\n 3 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Most INSERT-s (aggregate over selected time period)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 7, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "upd", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select dbname, table_full_name, top(ins, $top) as \"upd\" from (select mean(ins) as \"ins\" from (SELECT non_negative_derivative(last(\"n_tup_upd\"), 1h) as \"ins\" FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h), dbname, table_full_name fill(0)) GROUP BY dbname, table_full_name)", + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'total_relation_size_b')::int8 as total_relation_size, \n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'n_tup_upd')::int8) - min((data->'n_tup_upd')::int8) as upd -- assumes no reset\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1, 2\nHAVING\n max((data->'n_tup_upd')::int8) > min((data->'n_tup_upd')::int8)\nORDER BY\n 3 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Most UPDATE-s (aggregate over selected time period)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 42 + }, + "id": 8, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "del", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select dbname, table_full_name, top(ins, $top) as \"del\" from (select mean(ins) as \"ins\" from (SELECT non_negative_derivative(last(\"n_tup_del\"), 1h) as \"ins\" FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h), dbname, table_full_name fill(0)) GROUP BY dbname, table_full_name)", + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'total_relation_size_b')::int8 as total_relation_size, \n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n max((data->'n_tup_del')::int8) - min((data->'n_tup_del')::int8) as del\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1, 2\nHAVING\n max((data->'n_tup_del')::int8) > min((data->'n_tup_del')::int8)\nORDER BY\n 3 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Most DELETE-s (aggregate over selected time period)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": null, + "description": "Based on pg_statio_user_tables. Assumes 8KB page size (change the query if not so). Also note that due to OS file system cache only some reads will hit the disk", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 49 + }, + "id": 11, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": true, + "linkTargetBlank": true, + "linkTooltip": "Opens 'Table details' dashboard for that table", + "linkUrl": "/d/table-details?var-dbname=${__cell_0}&var-table_full_name=${__cell}&from=$__from&to=$__to", + "mappingType": 1, + "pattern": "table_full_name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "total_relation_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "/^last_/", + "thresholds": [], + "type": "number", + "unit": "dtdurations" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 1, + "pattern": "blks_read", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 1, + "mappingType": 1, + "pattern": "data_size", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "", + "align": "auto", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": null, + "mappingType": 1, + "pattern": "seq_scan", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "format": "table", + "group": [], + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "table_stats", + "metricColumn": "none", + "orderByTime": "ASC", + "policy": "default", + "query": "select dbname, table_full_name, top(ins, $top) as \"del\" from (select mean(ins) as \"ins\" from (SELECT non_negative_derivative(last(\"n_tup_del\"), 1h) as \"ins\" FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1h), dbname, table_full_name fill(0)) GROUP BY dbname, table_full_name)", + "rawQuery": true, + "rawSql": "SELECT\n x.*,\n (data->'table_size_b')::int8 as data_size,\n (data->'seq_scan')::int8 - (select (data->'seq_scan')::int8 from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time limit 1) as seq_scan,\n (data->'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n dbname,\n tag_data->>'table_full_name' as table_full_name,\n 8192 * (coalesce(max((data->'heap_blks_read')::int8) - min((data->'heap_blks_read')::int8), 0) + coalesce(max((data->'toast_blks_read')::int8) - min((data->'toast_blks_read')::int8), 0) + coalesce(max((data->'tidx_blks_read')::int8) - min((data->'tidx_blks_read')::int8), 0)) as blks_read\nFROM\n table_io_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1, 2\nHAVING\n max((data->'heap_blks_read')::int8) > min((data->'heap_blks_read')::int8)\nORDER BY\n 3 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = x.dbname and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true\n", + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "total_relation_size_b" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Most block IO reads", + "transform": "table", + "type": "table" + }, + { + "content": "Brought to you by: \"Cybertec", + "datasource": null, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 56 + }, + "id": 10, + "links": [], + "mode": "html", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": false, + "rawSql": "SELECT\n $__time(time_column),\n value1\nFROM\n metric_table\nWHERE\n $__timeFilter(time_column)\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "", + "transparent": true, + "type": "text" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#56A64B", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": null, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 56 + }, + "id": 14, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "pluginVersion": "6.7.4", + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select\n0 as time,\ncoalesce ((\n\nselect 1 from (\nselect\n tag_data->>'table_full_name' as table_name,\n (data->'seq_scan')::int8 as seq_scan,\n lag((data->'seq_scan')::int8) over (partition by tag_data->>'table_full_name' order by time) as seq_scan_lag\nfrom\n table_stats\nwhere\n $__timeFilter(time)\n and not tag_data->>'schema' ~* 'temp'\n and tag_data->>'table_full_name' in (select tag_data->>'table_full_name' from table_stats where $__timeFilter(time) and dbname = '$dbname' limit 500)\n AND dbname = '$dbname'\n) x\nwhere seq_scan_lag > seq_scan\nlimit 1\n\n), 0) as was_reset", + "refId": "A", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "column" + } + ] + ], + "timeColumn": "time", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "thresholds": "1,1", + "title": "", + "transparent": true, + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "0" + }, + { + "op": "=", + "text": "WARNING - stats reset detected for selected time range, results are unreliable", + "value": "1" + }, + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "first" + } + ], + "schemaVersion": 22, + "style": "dark", + "tags": [ + "pgwatch" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": false, + "text": "", + "value": "" + }, + "datasource": null, + "definition": "", + "hide": 0, + "includeAll": false, + "index": -1, + "label": null, + "multi": false, + "name": "dbname", + "options": [], + "query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'table_stats' ORDER BY 1;", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "top", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": true, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "50", + "value": "50" + } + ], + "query": "1,3,5,10,20,50", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Tables Top", + "uid": "tables-top", + "version": 1 + } + diff --git a/helm/pgwatch/templates/pgwatch-config.yaml b/helm/pgwatch/templates/pgwatch-config.yaml new file mode 100644 index 0000000..9fd7749 --- /dev/null +++ b/helm/pgwatch/templates/pgwatch-config.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/name: postgres-operator-monitoring + vendor: opensource.cybertec + name: pgwatch-cm +data: + launcher.sh: | + #!/bin/sh + + CMD="/pgwatch/pgwatch --sources=postgresql://$PGWATCH_USER:$PGWATCH_USER_PASSWORD@$METRIC_DATABASE_ENDPOINT:$METRIC_DATABASE_PORT/$METRIC_DATABASE_DATABASE?sslmode=$METRIC_DATABASE_SSLMODE" + + if [[ "$PG_IS_SINK" == "true" ]]; then + CMD="$CMD --sink=postgresql://$PGWATCH_USER:$PGWATCH_USER_PASSWORD@$METRIC_DATABASE_ENDPOINT:$METRIC_DATABASE_PORT/$METRIC_DATABASE_DATABASE?sslmode=$METRIC_DATABASE_SSLMODE --retention=$PG_RETENTION_DAYS" + fi + + if [[ "$PROM_IS_SINK" == "true" ]]; then + CMD="$CMD --sink=prometheus://0.0.0.0:9188/pgwatch" + fi + + exec $CMD + diff --git a/helm/pgwatch/templates/pgwatch-deployment.yaml b/helm/pgwatch/templates/pgwatch-deployment.yaml new file mode 100644 index 0000000..e7beddb --- /dev/null +++ b/helm/pgwatch/templates/pgwatch-deployment.yaml @@ -0,0 +1,86 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + application: pgwatch + pgwatch.pods.role: pgwatch + name: pgwatch + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + application: pgwatch + pgwatch.pods.role: pgwatch + template: + metadata: + labels: + application: pgwatch + pgwatch.pods.role: pgwatch + spec: + containers: + - env: + {{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} + - name: PGWATCH_USER + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: username + - name: PGWATCH_USER_PASSWORD + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: password + - name: METRIC_DATABASE_ENDPOINT + value: "postgres-svc.{{ .Release.Namespace }}.svc.cluster.local" + - name: METRIC_DATABASE_PORT + value: "5432" + - name: METRIC_DATABASE_DATABASE + value: pgwatch_metrics + - name: METRIC_DATABASE_SSLMODE + value: disable + {{- else }} + - name: PGWATCH_USER + value: {{ .Values.pgwatch.postgres.use_existing_database.username }} + - name: PGWATCH_USER_PASSWORD + value: {{ .Values.pgwatch.postgres.use_existing_database.password }} + - name: METRIC_DATABASE_ENDPOINT + value: {{ .Values.pgwatch.postgres.use_existing_database.endpoint }} + - name: METRIC_DATABASE_PORT + value: "{{ .Values.pgwatch.postgres.use_existing_database.port }}" + - name: METRIC_DATABASE_DATABASE + value: {{ .Values.pgwatch.postgres.use_existing_database.database }} + - name: METRIC_DATABASE_SSLMODE + value: {{ .Values.pgwatch.postgres.use_existing_database.sslmode }} + {{ end }} + {{- if eq .Values.pgwatch.postgres.enable_pg_sink "true" }} + - name: PG_IS_SINK + value: "true" + - name: PG_RETENTION_DAYS + value: "{{ .Values.pgwatch.postgres.settings.retention_days }}" + {{ end }} + {{- if eq .Values.pgwatch.prometheus.enable_prom_sink "true" }} + - name: PROM_IS_SINK + value: "true" + {{ end }} + image: {{ .Values.pgwatch.image }} + volumeMounts: + - name: launcher + mountPath: /tmp/launcher.sh + subPath: launcher.sh + name: pgwatch + ports: + - containerPort: 8080 + protocol: TCP + {{- if eq .Values.pgwatch.prometheus.enable_prom_sink "true" }} + - containerPort: 9188 + protocol: TCP + {{ end }} + command: ["/tmp/launcher.sh"] + volumes: + - name: launcher + configMap: + name: pgwatch-cm + defaultMode: 0777 # Damit es direkt ausführbar ist + restartPolicy: Always + diff --git a/helm/pgwatch/templates/postgres-statefulset.yaml b/helm/pgwatch/templates/postgres-statefulset.yaml new file mode 100644 index 0000000..5d9c7ea --- /dev/null +++ b/helm/pgwatch/templates/postgres-statefulset.yaml @@ -0,0 +1,81 @@ +{{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: postgres + namespace: {{ .Release.Namespace }} +spec: + serviceName: "postgres-svc" + replicas: 1 + selector: + matchLabels: + application: pgwatch + pgwatch.pods.role: postgres + template: + metadata: + labels: + application: pgwatch + pgwatch.pods.role: postgres + spec: + containers: + - name: postgres + image: {{ .Values.pgwatch.postgres.new_pg_database.image }} + ports: + - containerPort: 5432 + name: postgres + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-postgres + key: password + - name: POSTGRES_USER + value: postgres + - name: ADDITIONAL_USER + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: username + - name: ADDITIONAL_USER_PASSWORD + valueFrom: + secretKeyRef: + name: pgwatch-postgresql-secret-pgwatch + key: password + - name: ADDITIONAL_DB1 + value: pgwatch + - name: ADDITIONAL_DB2 + value: pgwatch_metrics + - name: ADDITIONAL_DB3 + value: pgwatch_grafana + - name: PGDATA + value: /pgdata/data + volumeMounts: + - name: pgdata + mountPath: /pgdata + lifecycle: + postStart: + exec: + command: + - "/bin/bash" + - "-c" + - | + psql -U $POSTGRES_USER -c "DO \$\$ BEGIN IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = '$ADDITIONAL_USER') THEN RAISE NOTICE 'Role \"$ADDITIONAL_USER\" already exists. Skipping.'; ELSE CREATE ROLE $ADDITIONAL_USER LOGIN PASSWORD '$ADDITIONAL_USER_PASSWORD'; END IF; END \$\$;" + psql -U $POSTGRES_USER -tc "SELECT 1 FROM pg_database WHERE datname = '$ADDITIONAL_DB1'" | grep -q 1 || psql -U $POSTGRES_USER -c "CREATE DATABASE $ADDITIONAL_DB1" + psql -U $POSTGRES_USER -tc "SELECT 1 FROM pg_database WHERE datname = '$ADDITIONAL_DB2'" | grep -q 1 || psql -U $POSTGRES_USER -c "CREATE DATABASE $ADDITIONAL_DB2" + psql -U $POSTGRES_USER -tc "SELECT 1 FROM pg_database WHERE datname = '$ADDITIONAL_DB3'" | grep -q 1 || psql -U $POSTGRES_USER -c "CREATE DATABASE $ADDITIONAL_DB3" + psql -U $POSTGRES_USER -c "ALTER DATABASE $ADDITIONAL_DB1 OWNER TO $ADDITIONAL_USER;" + psql -U $POSTGRES_USER -c "ALTER DATABASE $ADDITIONAL_DB2 OWNER TO $ADDITIONAL_USER;" + psql -U $POSTGRES_USER -c "ALTER DATABASE $ADDITIONAL_DB3 OWNER TO $ADDITIONAL_USER;" + volumeClaimTemplates: + - metadata: + name: pgdata + labels: + application: pgwatch + pgwatch.pods.role: postgres + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: {{ .Values.pgwatch.postgres.new_pg_database.volume.storageClass }} + resources: + requests: + storage: {{ .Values.pgwatch.postgres.new_pg_database.volume.size }} +{{ end }} \ No newline at end of file diff --git a/helm/pgwatch/templates/prometheus-config.yaml b/helm/pgwatch/templates/prometheus-config.yaml new file mode 100644 index 0000000..f6ec135 --- /dev/null +++ b/helm/pgwatch/templates/prometheus-config.yaml @@ -0,0 +1,21 @@ +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/name: postgres-operator-monitoring + vendor: opensource.cybertec + name: pgwatch-prometheus-cm +data: + prometheus.yml: | + --- + global: + scrape_interval: 1m + scrape_timeout: 15s + evaluation_interval: 5s + + scrape_configs: + - job_name: 'pgwatch' + static_configs: + - targets: ['pgwatch-svc.pgwatch.svc.cluster.local:9188'] +{{ end }} diff --git a/helm/pgwatch/templates/prometheus-deployment.yaml b/helm/pgwatch/templates/prometheus-deployment.yaml new file mode 100644 index 0000000..174e797 --- /dev/null +++ b/helm/pgwatch/templates/prometheus-deployment.yaml @@ -0,0 +1,77 @@ +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/name: pgwatch + vendor: opensource.cybertec + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-prometheus +spec: + selector: + matchLabels: + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-prometheus + template: + metadata: + creationTimestamp: null + labels: + postgres-operator.cybertec.at/stack: pgwatch + name: pgwatch-prometheus + spec: + containers: + - image: {{ .Values.pgwatch.prometheus.new_prometheus.image }} + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /-/healthy + port: 9090 + scheme: HTTP + initialDelaySeconds: 15 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 1 + name: pgwatch-prometheus + ports: + - containerPort: 9090 + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /-/ready + port: 9090 + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + args: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--storage.tsdb.path=/prometheus" + - "--storage.tsdb.retention.time={{ .Values.pgwatch.prometheus.new_prometheus.settings.retention_days }}d" + volumeMounts: + - mountPath: /etc/prometheus + name: prometheus-cm + - mountPath: /prometheus + name: prometheus-volume + securityContext: {} + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + terminationGracePeriodSeconds: 30 + volumes: + - configMap: + defaultMode: 420 + name: pgwatch-prometheus-cm + name: prometheus-cm + - name: prometheus-volume + persistentVolumeClaim: + claimName: prometheus-pvc + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + strategy: + type: Recreate +{{ end }} \ No newline at end of file diff --git a/helm/pgwatch/templates/prometheus_rbac.yaml b/helm/pgwatch/templates/prometheus_rbac.yaml new file mode 100644 index 0000000..306e4e9 --- /dev/null +++ b/helm/pgwatch/templates/prometheus_rbac.yaml @@ -0,0 +1,47 @@ +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} +# apiVersion: v1 +# kind: ServiceAccount +# metadata: +# labels: +# app.kubernetes.io/name: cpo-monitoring +# vendor: opensource.cybertec +# name: pgwatch-prometheus + +# --- + +# apiVersion: rbac.authorization.k8s.io/v1 +# kind: ClusterRole +# metadata: +# labels: +# app.kubernetes.io/name: cpo-monitoring +# vendor: opensource.cybertec +# name: pgwatch-prometheus +# rules: +# - resources: +# - pods +# apiGroups: +# - "" +# verbs: +# - get +# - list +# - watch + +# --- + +# apiVersion: rbac.authorization.k8s.io/v1 +# kind: ClusterRoleBinding +# metadata: +# labels: +# app.kubernetes.io/name: cpo-monitoring +# vendor: opensource.cybertec +# name: pgwatch-prometheus +# roleRef: +# apiGroup: rbac.authorization.k8s.io +# kind: ClusterRole +# name: pgwatch-prometheus +# subjects: +# - kind: ServiceAccount +# name: pgwatch-prometheus +# namespace: cpo-monitoring + +{{ end }} diff --git a/helm/pgwatch/templates/pvcs.yaml b/helm/pgwatch/templates/pvcs.yaml new file mode 100644 index 0000000..92b738f --- /dev/null +++ b/helm/pgwatch/templates/pvcs.yaml @@ -0,0 +1,17 @@ +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app.kubernetes.io/name: cpo-monitoring + vendor: opensource.cybertec + name: prometheus-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.pgwatch.prometheus.new_prometheus.volume.size }} + storageClassName: {{ .Values.pgwatch.prometheus.new_prometheus.volume.storageClass }} +{{ end }} \ No newline at end of file diff --git a/helm/pgwatch/templates/secrets.yaml b/helm/pgwatch/templates/secrets.yaml new file mode 100644 index 0000000..38928fa --- /dev/null +++ b/helm/pgwatch/templates/secrets.yaml @@ -0,0 +1,23 @@ +{{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} +apiVersion: v1 +kind: Secret +metadata: + name: pgwatch-postgresql-secret-postgres + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + password: 'beeF+u1bohce5xieZaamahChei3uthu>' + username: 'postgres' +--- + +apiVersion: v1 +kind: Secret +metadata: + name: pgwatch-postgresql-secret-pgwatch + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + password: 'awaes6ohR1dee2iedoo1n0Ao2lie3Le-' + username: 'pgwatch' +--- +{{ end }} \ No newline at end of file diff --git a/helm/pgwatch/templates/services.yaml b/helm/pgwatch/templates/services.yaml new file mode 100644 index 0000000..7624232 --- /dev/null +++ b/helm/pgwatch/templates/services.yaml @@ -0,0 +1,70 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + application: pgwatch + name: pgwatch-svc + namespace: {{ .Release.Namespace }} +spec: + ports: + - name: pgwatch + port: 8080 + targetPort: 8080 +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} + - name: pgwatch-prometheus-sink + port: 9188 + targetPort: 9188 +{{ end }} + selector: + application: pgwatch + pgwatch.pods.role: pgwatch +--- +apiVersion: v1 +kind: Service +metadata: + labels: + application: pgwatch + name: grafana-svc + namespace: {{ .Release.Namespace }} +spec: + ports: + - name: grafana + port: 3000 + targetPort: 3000 + selector: + application: pgwatch + pgwatch.pods.role: grafana +--- +{{- if eq .Values.pgwatch.postgres.create_metric_database "true" }} +apiVersion: v1 +kind: Service +metadata: + labels: + application: pgwatch + name: postgres-svc + namespace: {{ .Release.Namespace }} +spec: + ports: + - name: postgresql + port: 5432 + targetPort: 5432 + selector: + application: pgwatch + pgwatch.pods.role: postgres +{{ end }} +--- +{{- if eq .Values.pgwatch.prometheus.new_prometheus.create_prometheus "true" }} +apiVersion: v1 +kind: Service +metadata: + labels: + application: pgwatch + name: pgwatch-prometheus-svc +spec: + type: ClusterIP + ports: + - name: prometheus + port: 9090 + selector: + name: pgwatch-prometheus +{{ end }} \ No newline at end of file diff --git a/helm/pgwatch/values.yaml b/helm/pgwatch/values.yaml new file mode 100644 index 0000000..5bde5ac --- /dev/null +++ b/helm/pgwatch/values.yaml @@ -0,0 +1,37 @@ +pgwatch: + image: "docker.io/cybertecpostgresql/pgwatch:latest" + namespace: pgwatch + postgres: + enable_pg_sink: "true" + settings: + retention_days: 31 + # define is a database for the metrics needs to be created or if there is already an existing database + create_metric_database: "true" #"false" + new_pg_database: # Will be used for pgqwatch config only, if enable_pg_sink = "false" + image: "docker.io/schmaetz/postgres:bookworm-17.4-1" + volume: + size: '10Gi' + storageClass: 'crc-csi-hostpath-provisioner' + # use_existing_database: # Will be used for pgqwatch config only, if enable_pg_sink = "false" + # endpoint: postgresql.local + # port: '5432' + # database: PGWATCH_DATABASE + # sslmode: require + # username: pgwatch_user + # password: PASSWORD_FOR_PGWATCH_USER + prometheus: + enable_prom_sink: "true" + new_prometheus: + create_prometheus: "false" + create_alertmanager: "false" + image: "prom/prometheus:main" + settings: + retention_days: 31 + volume: + size: '10Gi' + storageClass: 'crc-csi-hostpath-provisioner' + grafana: + enable_grafana: "true" + enable_datasources: + postgres: "true" + prometheus: "false" diff --git a/helm/.helmignore b/helm/pgwatch2(old)/.helmignore similarity index 100% rename from helm/.helmignore rename to helm/pgwatch2(old)/.helmignore diff --git a/helm/Chart.lock b/helm/pgwatch2(old)/Chart.lock similarity index 100% rename from helm/Chart.lock rename to helm/pgwatch2(old)/Chart.lock diff --git a/helm/Chart.yaml b/helm/pgwatch2(old)/Chart.yaml similarity index 100% rename from helm/Chart.yaml rename to helm/pgwatch2(old)/Chart.yaml diff --git a/helm/pgwatch2(old)/README.md b/helm/pgwatch2(old)/README.md new file mode 100644 index 0000000..25bd169 --- /dev/null +++ b/helm/pgwatch2(old)/README.md @@ -0,0 +1,11 @@ +# Documentation + + +Key | Default value | Description +---|---|--- +storage | influx | influx or postgres; Defines backend for storing data +postgres_storage.database | pgwatch2_metrics | in case if storage is set to postgres, defines database name +metrics_preset | | +metrics_preset.name | remotedba | name of the default metrics_preset +metrics_preset.description| Metrics used for monitoring of Remote-DBA Databases | Metrics preset description +metrics_preset.metrics | '{"kpi": 120, "wal": 60, "locks": 60, "db_size": 300, "archiver": 60, "backends": 60, "bgwriter": 60, "cpu_load": 60, "db_stats": 60, "settings": 7200, "wal_size": 300, "locks_mode": 60, "index_stats": 900, "replication": 120, "sproc_stats": 180, "table_stats": 300, "wal_receiver": 120, "change_events": 300, "table_io_stats": 600, "sequence_health": 3600, "replication_slots": 120}' | Metrics diff --git a/helm/charts/influxdb-4.12.0.tgz b/helm/pgwatch2(old)/charts/influxdb-4.12.0.tgz similarity index 100% rename from helm/charts/influxdb-4.12.0.tgz rename to helm/pgwatch2(old)/charts/influxdb-4.12.0.tgz diff --git a/helm/charts/timescaledb-single-0.33.1.tgz b/helm/pgwatch2(old)/charts/timescaledb-single-0.33.1.tgz similarity index 100% rename from helm/charts/timescaledb-single-0.33.1.tgz rename to helm/pgwatch2(old)/charts/timescaledb-single-0.33.1.tgz diff --git a/helm/charts/grafana-6.50.0.tgz b/helm/pgwatch2(old)/grafana-6.50.0.tgz similarity index 100% rename from helm/charts/grafana-6.50.0.tgz rename to helm/pgwatch2(old)/grafana-6.50.0.tgz diff --git a/helm/grafana_dashboards b/helm/pgwatch2(old)/grafana_dashboards similarity index 100% rename from helm/grafana_dashboards rename to helm/pgwatch2(old)/grafana_dashboards diff --git a/helm/templates/NOTES.txt b/helm/pgwatch2(old)/templates/NOTES.txt similarity index 100% rename from helm/templates/NOTES.txt rename to helm/pgwatch2(old)/templates/NOTES.txt diff --git a/helm/templates/_helpers.tpl b/helm/pgwatch2(old)/templates/_helpers.tpl similarity index 100% rename from helm/templates/_helpers.tpl rename to helm/pgwatch2(old)/templates/_helpers.tpl diff --git a/helm/templates/configmaps.yaml b/helm/pgwatch2(old)/templates/configmaps.yaml similarity index 100% rename from helm/templates/configmaps.yaml rename to helm/pgwatch2(old)/templates/configmaps.yaml diff --git a/helm/templates/configmaps2.yaml b/helm/pgwatch2(old)/templates/configmaps2.yaml similarity index 100% rename from helm/templates/configmaps2.yaml rename to helm/pgwatch2(old)/templates/configmaps2.yaml diff --git a/helm/templates/deployment.yaml b/helm/pgwatch2(old)/templates/deployment.yaml similarity index 100% rename from helm/templates/deployment.yaml rename to helm/pgwatch2(old)/templates/deployment.yaml diff --git a/helm/templates/grafana-dashboards.yaml b/helm/pgwatch2(old)/templates/grafana-dashboards.yaml similarity index 100% rename from helm/templates/grafana-dashboards.yaml rename to helm/pgwatch2(old)/templates/grafana-dashboards.yaml diff --git a/helm/templates/ingress.yaml b/helm/pgwatch2(old)/templates/ingress.yaml similarity index 100% rename from helm/templates/ingress.yaml rename to helm/pgwatch2(old)/templates/ingress.yaml diff --git a/helm/templates/service.yaml b/helm/pgwatch2(old)/templates/service.yaml similarity index 100% rename from helm/templates/service.yaml rename to helm/pgwatch2(old)/templates/service.yaml diff --git a/helm/values.yaml b/helm/pgwatch2(old)/values.yaml similarity index 100% rename from helm/values.yaml rename to helm/pgwatch2(old)/values.yaml