apiVersion: v1
data:
  postgresql_service_health.json: |-
   {
     "__inputs": [
       {
         "name": "DS_PROMETHEUS",
         "label": "PROMETHEUS",
         "description": "",
         "type": "datasource",
         "pluginId": "prometheus",
         "pluginName": "Prometheus"
       }
     ],
     "__requires": [
       {
         "type": "grafana",
         "id": "grafana",
         "name": "Grafana",
         "version": "7.4.5"
       },
       {
         "type": "panel",
         "id": "graph",
         "name": "Graph",
         "version": ""
       },
       {
         "type": "datasource",
         "id": "prometheus",
         "name": "Prometheus",
         "version": "1.0.0"
       }
     ],
     "annotations": {
       "list": [
         {
           "builtIn": 1,
           "datasource": "-- Grafana --",
           "enable": true,
           "hide": true,
           "iconColor": "rgba(0, 211, 255, 1)",
           "name": "Annotations & Alerts",
           "type": "dashboard"
         }
       ]
     },
     "editable": false,
     "gnetId": null,
     "graphTooltip": 0,
     "id": null,
     "iteration": 1625069909806,
     "links": [
       {
         "asDropdown": false,
         "icon": "external link",
         "includeVars": true,
         "keepTime": true,
         "tags": [
           "vendor=crunchydata"
         ],
         "title": "",
         "type": "dashboards"
       }
     ],
     "panels": [
       {
         "aliasColors": {},
         "bars": false,
         "dashLength": 10,
         "dashes": false,
         "datasource": "Prometheus",
         "fieldConfig": {
           "defaults": {
             "custom": {},
             "links": []
           },
           "overrides": []
         },
         "fill": 1,
         "fillGradient": 5,
         "gridPos": {
           "h": 7,
           "w": 12,
           "x": 0,
           "y": 0
         },
         "hiddenSeries": false,
         "id": 6,
         "legend": {
           "alignAsTable": true,
           "avg": false,
           "current": false,
           "max": false,
           "min": false,
           "rightSide": true,
           "show": true,
           "sideWidth": 150,
           "total": false,
           "values": false
         },
         "lines": true,
         "linewidth": 1,
         "links": [],
         "nullPointMode": "null",
         "options": {
           "alertThreshold": true
         },
         "percentage": false,
         "pluginVersion": "7.4.5",
         "pointradius": 5,
         "points": false,
         "renderer": "flot",
         "seriesOverrides": [],
         "spaceLength": 10,
         "stack": false,
         "steppedLine": false,
         "targets": [
           {
             "expr": "sum(ccp_connection_stats_total{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip) / sum(ccp_connection_stats_max_connections{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip)",
             "format": "time_series",
             "instant": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Connections",
             "refId": "C"
           },
           {
             "expr": "100 - 100 * avg(ccp_nodemx_data_disk_available_bytes{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip) / avg(ccp_nodemx_data_disk_total_bytes{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"})  without (pod,instance,ip)",
             "format": "time_series",
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Mount:{{mount_point}}",
             "refId": "A"
           }
         ],
         "thresholds": [],
         "timeFrom": null,
         "timeRegions": [],
         "timeShift": null,
         "title": "Saturation (pct used)",
         "tooltip": {
           "shared": true,
           "sort": 0,
           "value_type": "individual"
         },
         "type": "graph",
         "xaxis": {
           "buckets": null,
           "mode": "time",
           "name": null,
           "show": true,
           "values": []
         },
         "yaxes": [
           {
             "decimals": null,
             "format": "percent",
             "label": null,
             "logBase": 1,
             "max": "100",
             "min": "0",
             "show": true
           },
           {
             "format": "short",
             "label": null,
             "logBase": 1,
             "max": null,
             "min": null,
             "show": false
           }
         ],
         "yaxis": {
           "align": false,
           "alignLevel": null
         }
       },
       {
         "aliasColors": {},
         "bars": false,
         "cacheTimeout": null,
         "dashLength": 10,
         "dashes": false,
         "datasource": "Prometheus",
         "fieldConfig": {
           "defaults": {
             "custom": {},
             "links": []
           },
           "overrides": []
         },
         "fill": 1,
         "fillGradient": 5,
         "gridPos": {
           "h": 7,
           "w": 12,
           "x": 12,
           "y": 0
         },
         "hiddenSeries": false,
         "id": 18,
         "legend": {
           "alignAsTable": true,
           "avg": false,
           "current": false,
           "max": false,
           "min": false,
           "rightSide": true,
           "show": true,
           "sideWidth": 150,
           "total": false,
           "values": false
         },
         "lines": true,
         "linewidth": 1,
         "links": [],
         "nullPointMode": "null",
         "options": {
           "alertThreshold": true
         },
         "percentage": false,
         "pluginVersion": "7.4.5",
         "pointradius": 2,
         "points": false,
         "renderer": "flot",
         "seriesOverrides": [],
         "spaceLength": 10,
         "stack": false,
         "steppedLine": false,
         "targets": [
           {
             "exemplar": false,
             "expr": "  sum(irate(ccp_stat_database_xact_commit{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m])) \n+ sum(irate(ccp_stat_database_xact_rollback{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m]))",
             "format": "time_series",
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Transactions",
             "refId": "A"
           },
           {
             "expr": "max(ccp_connection_stats_active{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip,dbname)",
             "format": "time_series",
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Active connections",
             "refId": "C"
           },
           {
             "expr": "sum(irate(ccp_pg_stat_statements_total_calls_count{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m]))",
             "format": "time_series",
             "hide": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Queries",
             "refId": "B"
           }
         ],
         "thresholds": [],
         "timeFrom": null,
         "timeRegions": [],
         "timeShift": null,
         "title": "Traffic",
         "tooltip": {
           "shared": true,
           "sort": 2,
           "value_type": "individual"
         },
         "type": "graph",
         "xaxis": {
           "buckets": null,
           "mode": "time",
           "name": null,
           "show": true,
           "values": []
         },
         "yaxes": [
           {
             "format": "short",
             "label": "",
             "logBase": 1,
             "max": null,
             "min": "0.001",
             "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": "Prometheus",
         "description": "Errors",
         "fieldConfig": {
           "defaults": {
             "custom": {},
             "links": []
           },
           "overrides": []
         },
         "fill": 1,
         "fillGradient": 5,
         "gridPos": {
           "h": 7,
           "w": 12,
           "x": 0,
           "y": 7
         },
         "hiddenSeries": false,
         "id": 4,
         "legend": {
           "alignAsTable": true,
           "avg": false,
           "current": false,
           "max": false,
           "min": false,
           "rightSide": true,
           "show": true,
           "sideWidth": 150,
           "total": false,
           "values": false
         },
         "lines": true,
         "linewidth": 1,
         "links": [],
         "nullPointMode": "null",
         "options": {
           "alertThreshold": true
         },
         "percentage": false,
         "pluginVersion": "7.4.5",
         "pointradius": 5,
         "points": false,
         "renderer": "flot",
         "seriesOverrides": [],
         "spaceLength": 10,
         "stack": false,
         "steppedLine": false,
         "targets": [
           {
             "expr": "sum(irate(ccp_stat_database_xact_rollback{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m]) without(pod,instance,ip))",
             "format": "time_series",
             "hide": true,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Rollbacks",
             "refId": "A"
           },
           {
             "expr": "sum(irate(ccp_stat_database_deadlocks{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m]))  without(pod,instance,ip,dbname)",
             "format": "time_series",
             "hide": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Deadlock ",
             "refId": "D"
           },
           {
             "expr": "sum(irate(ccp_stat_database_conflicts{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}[1m])) without(pod,instance,ip,dbname)",
             "format": "time_series",
             "hide": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Conflicts",
             "refId": "B"
           },
           {
             "expr": "max(pg_exporter_last_scrape_error{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without(pod,instance,ip,dbname)",
             "format": "time_series",
             "hide": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "scrape error",
             "refId": "C"
           },
           {
             "expr": "max(clamp_max(ccp_archive_command_status_seconds_since_last_fail{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"},1)) without (instance,pod,ip)",
             "format": "time_series",
             "hide": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "archive error",
             "refId": "E"
           }
         ],
         "thresholds": [],
         "timeFrom": null,
         "timeRegions": [],
         "timeShift": null,
         "title": "Errors",
         "tooltip": {
           "shared": true,
           "sort": 0,
           "value_type": "individual"
         },
         "type": "graph",
         "xaxis": {
           "buckets": null,
           "mode": "time",
           "name": null,
           "show": true,
           "values": []
         },
         "yaxes": [
           {
             "decimals": null,
             "format": "short",
             "label": "",
             "logBase": 2,
             "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": "Prometheus",
         "fieldConfig": {
           "defaults": {
             "custom": {},
             "links": []
           },
           "overrides": []
         },
         "fill": 1,
         "fillGradient": 1,
         "gridPos": {
           "h": 7,
           "w": 12,
           "x": 12,
           "y": 7
         },
         "hiddenSeries": false,
         "id": 10,
         "legend": {
           "alignAsTable": true,
           "avg": false,
           "current": false,
           "max": false,
           "min": false,
           "rightSide": true,
           "show": true,
           "sideWidth": 150,
           "total": false,
           "values": false
         },
         "lines": true,
         "linewidth": 1,
         "links": [],
         "nullPointMode": "null",
         "options": {
           "alertThreshold": true
         },
         "percentage": false,
         "pluginVersion": "7.4.5",
         "pointradius": 5,
         "points": false,
         "renderer": "flot",
         "seriesOverrides": [
           {
             "alias": "/Max:/",
             "color": "#E02F44",
             "nullPointMode": "null as zero"
           },
           {
             "alias": "/Avg:/",
             "color": "#8AB8FF"
           }
         ],
         "spaceLength": 10,
         "stack": false,
         "steppedLine": false,
         "targets": [
           {
             "expr": "max(ccp_pg_stat_statements_total_mean_exec_time_ms{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip)",
             "format": "time_series",
             "hide": false,
             "instant": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Avg: {{exported_role}}({{dbname}})",
             "refId": "A"
           },
           {
             "expr": "max(ccp_pg_stat_statements_top_max_exec_time_ms{pg_cluster=\"[[cluster]]\",role=\"[[role]]\"}) without (pod,instance,ip,query,queryid)",
             "format": "time_series",
             "hide": false,
             "instant": false,
             "interval": "",
             "intervalFactor": 1,
             "legendFormat": "Max: {{exported_role}}({{dbname}})",
             "refId": "B"
           }
         ],
         "thresholds": [],
         "timeFrom": null,
         "timeRegions": [],
         "timeShift": null,
         "title": "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": "ms",
             "label": null,
             "logBase": 2,
             "max": null,
             "min": "0",
             "show": true
           },
           {
             "format": "short",
             "label": null,
             "logBase": 1,
             "max": null,
             "min": null,
             "show": false
           }
         ],
         "yaxis": {
           "align": false,
           "alignLevel": null
         }
       }
     ],
     "refresh": "5m",
     "schemaVersion": 27,
     "style": "dark",
     "tags": [
       "vendor=crunchydata"
     ],
     "templating": {
       "list": [
         {
           "allValue": null,
           "current": {},
           "datasource": "Prometheus",
           "definition": "label_values(pg_cluster)",
           "description": null,
           "error": null,
           "hide": 0,
           "includeAll": false,
           "label": null,
           "multi": false,
           "name": "cluster",
           "options": [],
           "query": {
             "query": "label_values(pg_cluster)",
             "refId": "PROMETHEUS-cluster-Variable-Query"
           },
           "refresh": 1,
           "regex": "",
           "skipUrlSync": false,
           "sort": 0,
           "tagValuesQuery": "",
           "tags": [],
           "tagsQuery": "",
           "type": "query",
           "useTags": false
         },
         {
           "allValue": null,
           "current": {},
           "datasource": "Prometheus",
           "definition": "label_values({pg_cluster=\"[[cluster]]\"},role)",
           "description": null,
           "error": null,
           "hide": 0,
           "includeAll": false,
           "label": null,
           "multi": false,
           "name": "role",
           "options": [],
           "query": {
             "query": "label_values({pg_cluster=\"[[cluster]]\"},role)",
             "refId": "PROMETHEUS-role-Variable-Query"
           },
           "refresh": 1,
           "regex": "",
           "skipUrlSync": false,
           "sort": 0,
           "tagValuesQuery": "",
           "tags": [],
           "tagsQuery": "",
           "type": "query",
           "useTags": false
         }
       ]
     },
     "time": {
       "from": "now-1h",
       "to": "now"
     },
     "timepicker": {
       "time_options": [
         "5m",
         "15m",
         "1h",
         "6h",
         "12h",
         "24h",
         "2d",
         "7d",
         "30d"
       ]
     },
     "timezone": "browser",
     "title": "PostgreSQL Service Health",
     "uid": "dhG1wgsMz",
     "version": 1
   }
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: grafana-dashboard-crunchy-postgresql-service-health
