{
  "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"}]},
  "author":"Ruohang Feng (rh@vonng.com)",
  "description":"PostgreSQL Databases",
  "editable":true,
  "fiscalYearStartMonth":0,
  "graphTooltip":0,
  "id":null,
  "license":"https://pigsty.io/docs/about/license/",
  "links":[
    { "asDropdown":true,"icon":"external link","includeVars":true,"keepTime":true,"tags":["Pigsty","PGSQL","Overview"],"targetBlank":false,"title":"Overview","tooltip":"","type":"dashboards","url":"" },{ "asDropdown":true,"icon":"external link","includeVars":true,"keepTime":true,"tags":["Pigsty","PGSQL","Cluster"] ,"targetBlank":false,"title":"Cluster" ,"tooltip":"","type":"dashboards","url":"" },
    { "asDropdown":true,"icon":"external link","includeVars":true,"keepTime":true,"tags":["Pigsty","PGSQL","Instance"],"targetBlank":false,"title":"Instance","tooltip":"","type":"dashboards","url":"" },{ "asDropdown":true,"icon":"external link","includeVars":true,"keepTime":true,"tags":["Pigsty","PGSQL","Database"],"targetBlank":false,"title":"Database","tooltip":"","type":"dashboards","url":"" }
  ],
  "panels":[
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":575,"panels":[],"title":"Overview","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"links":[{"title":"PGSQL Cluster : ${cls}","url":"/d/pgsql-cluster?var-cls=${cls}&${__url_time_range}"}],"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null}]}},"overrides":[]},
      "gridPos":{"h":3,"w":8,"x":0,"y":1},
      "id":2281,
      "options":{"colorMode":"background","graphMode":"none","justifyMode":"center","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"valueSize":26},"textMode":"name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"1","format":"table","instant":true,"interval":"","legendFormat":"Cluster","queryType":"measurements","refId":"A"}],
      "title":"",
      "transformations":[{"id":"organize","options":{"excludeByName":{"Time":true},"indexByName":{},"renameByName":{"Time":"","Value":"${cls}.${datname}"}}}],
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Database of this cluster ${cls}\n\nLoad: active_time / backends (PG14 only)\n\nQuery RT : max query rt of this database\n\nClient: Pgbouncer Active Clients\n\nServer: Pgbouncer Active Servers\n\nBackend: Postgres num backends\n\nT = is Template?\n\nD = Disabled in Pgbouncer ?\n\nP = Paused in Pgbouncer ?",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"mode":"gradient","type":"color-background"},"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#e3e3e3e0","value":null}]}},
        "overrides":[
          {
            "matcher":{"id":"byName","options":"Database"},
            "properties":[
              { "id":"links"             ,"value":[{"title":"PGSQL Cluster Database : ${cls}.${__data.fields.Database}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${__data.fields.Database}&${__url_time_range}"}] },
              { "id":"mappings"          ,"value":[{"options":{"postgres":{"color":"#808080","index":2},"template0":{"color":"#c0c0c0e0","index":0},"template1":{"color":"#a8a8a8e0","index":1}},"type":"value"}]             },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                       },
              { "id":"color"             ,"value":{"fixedColor":"#3e668f","mode":"fixed"}                                                                                                                                     }
            ]
          },{
            "matcher":{"id":"byName","options":"Size"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                                                                           },
              { "id":"unit"              ,"value":"decbytes"                                                                                                                                                                                   },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1000000000},{"color":"#fcdb72","value":1000000000000},{"color":"#f79f64","value":10000000000000}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                        },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                        },
              { "id":"color"             ,"value":{"mode":"thresholds"}                                                                                                                                                                        },
              { "id":"decimals"          ,"value":0                                                                                                                                                                                            }
            ]
          },{
            "matcher":{"id":"byName","options":"Age"},
            "properties":[
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":60000000},{"color":"#EAB839","value":200000000},{"color":"#f79f64","value":600000000},{"color":"red","value":1000000000},{"color":"#b783af","value":2000000000},{"color":"text","value":2137483647}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                                           },
              { "id":"unit"              ,"value":"percentunit"                                                                                                                                                                                                                                                                                   },
              { "id":"custom.width"      ,"value":60                                                                                                                                                                                                                                                                                              },
              { "id":"color"             ,"value":{"mode":"thresholds"}                                                                                                                                                                                                                                                                           },
              { "id":"decimals"          ,"value":1                                                                                                                                                                                                                                                                                               }
            ]
          },
          {"matcher":{"id":"byName","options":"TPS"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#f79f64","value":30000}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}},{"id":"custom.width","value":70},{"id":"color","value":{"mode":"thresholds"}},{"id":"decimals","value":1}]},
          {
            "matcher":{"id":"byName","options":"T"},
            "properties":[{"id":"custom.width","value":40},{"id":"mappings","value":[{"options":{"0":{"color":"#346f36cc","index":1,"text":"F"},"1":{"color":"#f79f64","index":2,"text":"T"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"#e3e3e3e0","index":0,"text":"N"}},"type":"special"}]},{"id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}}]
          },{
            "matcher":{"id":"byName","options":"Backend"},
            "properties":[{"id":"custom.cellOptions","value":{"type":"color-text"}},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#f79f64","value":1000}]}},{"id":"color","value":{"mode":"thresholds"}},{"id":"custom.width","value":75},{"id":"custom.cellOptions","value":{"type":"color-text"}}]
          },{
            "matcher":{"id":"byName","options":"ConnLimit"},
            "properties":[
              { "id":"custom.width"      ,"value":85                                                                                                                                                                                                                                                                                },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                             },
              { "id":"color"                                                                                                                                                                                                                                                                                                        },
              { "id":"mappings"          ,"value":[{"options":{"-1":{"color":"#3e668f","index":1,"text":"NO LIMIT"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"N/A"}},"type":"special"},{"options":{"from":0,"result":{"color":"#f79f64","index":2},"to":99999999},"type":"range"}] }
            ]
          },{
            "matcher":{"id":"byRegexp","options":"Conn%"},
            "properties":[
              { "id":"unit"              ,"value":"percentunit"                                                                                                                                                                                                                                              },
              { "id":"custom.width"      ,"value":90                                                                                                                                                                                                                                                         },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":0.1},{"color":"#fcdb72","value":0.3},{"color":"#f79f64","value":0.5},{"color":"red","value":0.7},{"color":"#b783af","value":0.9},{"color":"text","value":0.99}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                      }
            ]
          },
          {"matcher":{"id":"byName","options":"Client"},"properties":[{"id":"custom.width","value":60},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1000}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"Server"},"properties":[{"id":"custom.width","value":60},{"id":"custom.cellOptions","value":{"type":"color-text"}},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#fcdb72","value":1000}]}}]},
          {"matcher":{"id":"byName","options":"Conn%"},"properties":[{"id":"custom.width","value":70},{"id":"custom.cellOptions","value":{"type":"color-text"}},{"id":"decimals","value":1}]},
          {
            "matcher":{"id":"byName","options":"RT"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                                                                                               },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":2},{"color":"red","value":4},{"color":"#b783af","value":8},{"color":"text","value":16}]} },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"index":0,"text":"-"}},"type":"special"}]                                                                                                                              },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                            },
              { "id":"unit"              ,"value":"s"                                                                                                                                                                                                              }
            ]
          },{
            "matcher":{"id":"byName","options":"Load"},
            "properties":[
              { "id":"custom.width"      ,"value":120                                                                                                                                                                                                                                                     },
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"gauge"}                                                                                                                                                                                                                      },
              { "id":"unit"              ,"value":"percentunit"                                                                                                                                                                                                                                           },
              { "id":"decimals"          ,"value":1                                                                                                                                                                                                                                                       },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":0.1},{"color":"#fcdb72","value":0.3},{"color":"#f79f64","value":0.5},{"color":"red","value":0.7},{"color":"#b783af","value":0.9},{"color":"text","value":1}]} },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"index":0,"text":"-"}},"type":"special"}]                                                                                                                                                                     }
            ]
          },{
            "matcher":{"id":"byName","options":"D"},
            "properties":[{"id":"custom.width","value":50},{"id":"mappings","value":[{"options":{"0":{"color":"#346f36cc","index":0,"text":"F"},"1":{"color":"#f79f64","index":1,"text":"T"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"transparent","index":2,"text":"-"}},"type":"special"}]},{"id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}}]
          },
          {"matcher":{"id":"byName","options":"P"},"properties":[{"id":"mappings","value":[{"options":{"0":{"color":"#346f36cc","index":0,"text":"F"},"1":{"color":"#f79f64","index":1,"text":"T"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"transparent","index":2,"text":"-"}},"type":"special"}]},{"id":"custom.width","value":50}]},
          {"matcher":{"id":"byName","options":"PoolSize"},"properties":[{"id":"custom.width","value":80},{"id":"custom.cellOptions","value":{"type":"auto"}}]},{"matcher":{"id":"byName","options":"Target"},"properties":[{"id":"custom.minWidth","value":60},{"id":"custom.cellOptions","value":{"type":"auto"}},{"id":"custom.inspect","value":true}]},
          {
            "matcher":{"id":"byName","options":"OID"},
            "properties":[
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                      },{ "id":"links"             ,"value":[{"title":"PGCAT Database : ${primary}.${__data.fields.Database}","url":"/d/pgcat-database?var-dsn=${primary}.${__data.fields.Database}"}] },
              { "id":"mappings"          ,"value":[{"options":{"from":0,"result":{"color":"#bfbfbf33","index":1},"to":10},"type":"range"}]                                                   },{ "id":"custom.width"      ,"value":90                                                                                                                                         },
              { "id":"color"             ,"value":{"fixedColor":"#3e668f","mode":"fixed"}                                                                                                    }
            ]
          }
        ]
      },
      "gridPos":{"h":6,"w":16,"x":8,"y":1},
      "id":187,
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[{"desc":true,"displayName":"Size"}]},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pg_size_bytes{cls=\"$cls\", datname!~\"wal|log\"})"                                                                                              ,"format":"table",             "instant":true,"interval":"","legendFormat":"Age"          ,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pg:db:age{cls=\"$cls\"})"                                                                                                                        ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Commit"       ,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pg_db_is_template{cls=\"$cls\", ins=\"$primary\"})"                                                                                              ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"isTemplate"   ,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pg_activity_count{cls=\"$cls\"})"                                                                                                                ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Backend"      ,"refId":"D" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pg:db:xact_commit_rate1m{cls=\"$cls\"})"                                                                                                         ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"TPS"          ,"refId":"E" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pg_db_conn_limit{ins=\"$primary\"})"                                                                                                             ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Conn Limit"   ,"refId":"F" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pgbouncer:db:query_rt_1m{ins=\"$primary\"})"                                                                                                     ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Conn Limit"   ,"refId":"G" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pg:db:conn_usage{cls=\"$cls\"})"                                                                                                                 ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"PG Conn Usage","refId":"H" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pgbouncer_database_disabled{ins=\"$primary\", datname!=\"pgbouncer\"})"                                                                          ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Disabled"     ,"refId":"I" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname) (pgbouncer_database_paused{ins=\"$primary\", datname!=\"pgbouncer\"})"                                                                            ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Paused"       ,"refId":"J" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pg:db:active_time_rate1m{cls=\"$cls\"}) / sum by (datname) (pg_db_numbackends{cls=\"$cls\"})"                                                    ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Conn Usage"   ,"refId":"L" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pgbouncer:db:active_servers{cls=\"$cls\"})"                                                                                                      ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Conn Usage"   ,"refId":"M" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (datname) (pgbouncer:db:active_servers{cls=\"$cls\"})"                                                                                                      ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Conn Usage"   ,"refId":"N" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (datname,host) (pgbouncer_database_pool_size{cls=\"$cls\", datname!=\"pgbouncer\"} + pgbouncer_database_reserve_pool{cls=\"$cls\", datname!=\"pgbouncer\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Age"          ,"refId":"K" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (datname) (pg_db_datid{cls=\"$cls\"})"                                                                                                                      ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Age"          ,"refId":"O" }
      ],
      "title":"Database",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"datname"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{"Time 1":true,"Time 10":true,"Time 11":true,"Time 12":true,"Time 13":true,"Time 14":true,"Time 15":true,"Time 2":true,"Time 3":true,"Time 4":true,"Time 5":true,"Time 6":true,"Time 7":true,"Time 8":true,"Time 9":true,"Value #G":false,"Value #H":false},
            "indexByName":{
              "Time 1":17,
              "Time 10":26,
              "Time 11":27,
              "Time 12":28,
              "Time 13":29,
              "Time 14":30,
              "Time 15":31,
              "Time 2":18,
              "Time 3":19,
              "Time 4":20,
              "Time 5":21,
              "Time 6":22,
              "Time 7":23,
              "Time 8":24,
              "Time 9":25,
              "Value #A":2,
              "Value #B":3,
              "Value #C":15,
              "Value #D":4,
              "Value #E":5,
              "Value #F":11,
              "Value #G":6,
              "Value #H":10,
              "Value #I":13,
              "Value #J":14,
              "Value #K":12,
              "Value #L":9,
              "Value #M":8,
              "Value #N":7,
              "Value #O":1,
              "datname":0,
              "host":16
            },
            "renameByName":{"Time 1":"","Time 7":"","Value #A":"Size","Value #B":"Age","Value #C":"T","Value #D":"Backend","Value #E":"TPS","Value #F":"ConnLimit","Value #G":"RT","Value #H":"Conn%","Value #I":"D","Value #J":"P","Value #K":"PoolSize","Value #L":"Load","Value #M":"Client","Value #N":"Server","Value #O":"OID","datname":"Database","host":"Target","real_datname":"Datname"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"links":[{"title":"PGSQL Database : ${__field.labels.ins}","url":"/d/pgsql-database?var-ins=${__field.labels.ins}&var-datname=${__field.labels.datname}&${__url_time_range}"}],"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1},{"color":"#f79f64","value":1000}]},"unit":"none"},
        "overrides":[]
      },
      "gridPos":{"h":10,"w":4,"x":0,"y":4},
      "id":212,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"horizontal","percentChangeColorMode":"standard","reduceOptions":{"calcs":["last"],"fields":"","values":false},"showPercentChange":false,"text":{},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum by (ins,datname) (pg_db_numbackends{cls=\"$cls\", datname!~\"wal|log|postgres|template\\\\d\"})","interval":"","legendFormat":"{{ ins }}.{{ datname }}","range":true,"refId":"A"}],
      "title":"Conn / PGSQL",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"decimals":1,"links":[{"title":"PGCAT Database : ${__field.labels.ins}.${__field.labels.datname}","url":"/d/pgcat-database?var-dsn=${__field.labels.ins}.${__field.labels.datname}&${__url_time_range}"}],"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null}]},"unit":"none"},"overrides":[]},
      "gridPos":{"h":10,"w":4,"x":4,"y":4},
      "id":2283,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"horizontal","percentChangeColorMode":"standard","reduceOptions":{"calcs":["last"],"fields":"","values":false},"showPercentChange":false,"text":{},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum by (ins,datname) (rate(pg_db_xact_commit{cls=\"$cls\", datname=\"$datname\"}[1m]))","interval":"","legendFormat":"{{ ins }}","range":true,"refId":"A"}],
      "title":"TPS / PGCAT",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"},"inspect":false},"mappings":[],"max":1.2,"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"#e3e3e3e0","value":null}]}},
        "overrides":[
          {"matcher":{"id":"byName","options":"Instance"},"properties":[{"id":"links","value":[{"title":"PGSQL Database ${__data.fields.Instance}.${datname}","url":"/d/pgsql-database?var-ins=${__data.fields.Instance}&var-datname=${datname}&${__url_time_range}"}]},{"id":"custom.minWidth","value":180}]},
          {"matcher":{"id":"byName","options":"IP"},"properties":[{"id":"custom.width","value":110},{"id":"links","value":[{"title":"Node Instance : ${__data.fields.IP}","url":"/d/node-instance?var-id=${__data.fields.IP}&${__url_time_range}"}]}]},
          {
            "matcher":{"id":"byName","options":"Role"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                             },{ "id":"mappings"          ,"value":[{"options":{"0":{"color":"#3e668f","index":0,"text":"primary"},"1":{"color":"#346f36cc","index":1,"text":"replica"}},"type":"value"}]         },
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}                                                                                                  },{ "id":"links"             ,"value":[{"title":"PGSQL Service for ${cls}-${__data.fields.Role}","url":"/d/pgsql-service?var-svc=${cls}-${__data.fields.Role}&${__url_time_range}"}] }
            ]
          },{
            "matcher":{"id":"byName","options":"Load"},
            "properties":[
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"gauge"}                                                                                                                                                                                                                      },
              { "id":"color"             ,"value":{"mode":"thresholds"}                                                                                                                                                                                                                                   },
              { "id":"unit"              ,"value":"percentunit"                                                                                                                                                                                                                                           },
              { "id":"custom.width"      ,"value":120                                                                                                                                                                                                                                                     },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":0.1},{"color":"#fcdb72","value":0.3},{"color":"#f79f64","value":0.5},{"color":"red","value":0.7},{"color":"#b783af","value":0.9},{"color":"text","value":1}]} },
              { "id":"decimals"          ,"value":1                                                                                                                                                                                                                                                       },
              { "id":"mappings"          ,"value":[{"options":{"-1":{"color":"transparent","index":0,"text":"N/A"}},"type":"value"}]                                                                                                                                                                      }
            ]
          },
          {"matcher":{"id":"byName","options":"Cluster"},"properties":[{"id":"links","value":[{"title":"PGSQL Cluster for ${__data.fields.Cluster}","url":"/d/pgsql-cluster?var-cls=${__data.fields.Cluster}&${__url_time_range}"}]}]},
          {"matcher":{"id":"byName","options":"TPS"},"properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#3e668f","value":32},{"color":"#f79f64","value":32000}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"QPS"},"properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#3e668f","value":32},{"color":"#f79f64","value":32000}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {
            "matcher":{"id":"byName","options":"DB Conn"},
            "properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#EAB839","value":20},{"color":"#EF843C","value":40},{"color":"#E24D42","value":80},{"color":"#b783af","value":100},{"color":"text","value":400}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]
          },{
            "matcher":{"id":"byName","options":"RT"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                                                                                               },
              { "id":"unit"              ,"value":"s"                                                                                                                                                                                                              },
              { "id":"mappings"          ,"value":[{"options":{"match":"nan","result":{"index":1,"text":"-"}},"type":"special"}]                                                                                                                                   },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":2},{"color":"red","value":4},{"color":"#b783af","value":8},{"color":"text","value":16}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                            }
            ]
          },
          {"matcher":{"id":"byName","options":"LB Conn"},"properties":[{"id":"custom.width","value":72},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1},{"color":"#fcdb72","value":1000},{"color":"#f79f64","value":2000},{"color":"red","value":3000}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"Queue"},"properties":[{"id":"custom.width","value":60},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"red","value":1}]}},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"HAProxy"},"properties":[{"id":"links","value":[{"targetBlank":true,"title":"HAProxy Admin Page : ${__data.fields.Instance}","url":"/haproxy/${__data.fields.Instance}"}]}]},
          {"matcher":{"id":"byName","options":"Up"},"properties":[{"id":"custom.width","value":80},{"id":"mappings","value":[{"options":{"0":{"color":"#cc4637d9","index":0,"text":"Dead"},"1":{"color":"#346f36cc","index":1,"text":"Alive"}},"type":"value"}]},{"id":"custom.cellOptions","value":{"type":"color-background"}}]}
        ]
      },
      "gridPos":{"h":7,"w":16,"x":8,"y":7},
      "id":2279,
      "links":[{"title":"PGSQL Instance : ${primary}","url":"/d/pgsql-instance?var-ins=${primary}&${__url_time_range}"}],
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[{"desc":false,"displayName":"Instance"}]},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"min by (ins,ip) (up{job=\"pgsql\", cls=\"$cls\"})"                                       ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (ins) (pg:ins:load1{cls=\"$cls\"})"                                               ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (ins) (pg:ins:xact_total_rate1m{cls=\"$cls\"})"                                   ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"min by (ins,ip) (pg_in_recovery{cls=\"$cls\"})"                                          ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"D" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (ins) (pg:ins:num_backends{cls=\"$cls\"})"                                        ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"E" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (ins) (pgbouncer:ins:xact_rt_1m{cls=\"$cls\"})"                                   ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"F" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (ins,instance) (haproxy_backend_current_sessions{cls=\"$cls\", proxy!=\"stats\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"G" }
      ],
      "title":"Instances",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"ins"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{
              "Time":true,
              "Time 1":true,
              "Time 10":true,
              "Time 2":true,
              "Time 3":true,
              "Time 4":true,
              "Time 6":true,
              "Time 8":true,
              "Time 9":true,
              "Value #A":false,
              "Value #B":false,
              "Value #H":false,
              "__name__":true,
              "__name__ 1":true,
              "__name__ 2":true,
              "__name__ 3":true,
              "__name__ 5":true,
              "__name__ 7":true,
              "cls":true,
              "cls 1":true,
              "cls 2":true,
              "cls 3":true,
              "cls 4":true,
              "cls 5":true,
              "cls 6":true,
              "cls 7":true,
              "instance":false,
              "instance 1":true,
              "instance 2":false,
              "instance 3":true,
              "instance 4":true,
              "instance 5":true,
              "instance 6":true,
              "ip 2":true,
              "ip 3":true,
              "ip 4":true,
              "ip 5":true,
              "ip 6":true,
              "ip 7":true,
              "job":true,
              "job 1":true,
              "job 2":true,
              "job 3":true,
              "job 4":true,
              "job 5":true,
              "job 6":true,
              "job 7":true
            },
            "indexByName":{"Time 1":9,"Time 2":10,"Time 3":11,"Time 4":12,"Time 5":13,"Time 6":15,"Value #A":0,"Value #B":4,"Value #C":5,"Value #D":1,"Value #E":7,"Value #G":6,"ins":2,"instance":8,"ip 1":3,"ip 2":14},
            "renameByName":{"Time 4":"","Value #A":"Up","Value #B":"Load","Value #C":"TPS","Value #D":"Role","Value #E":"DB Conn","Value #F":"RT","Value #G":"LB Conn","Value #H":"LB","Value #I":"QPS","Value #J":"LB Clients","Value #K":"Lag","cls 1":"","cls 2":"","ins":"Instance","instance":"HAProxy","instance 2":"","ip":"IP","ip 1":"IP"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"Xact Commit for ${cls}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1786&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":32},{"color":"#fcdb72","value":100000}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":0,"y":14},
      "id":399,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pg:db:xact_commit_rate1m{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Commit","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Rollback for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1786&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":4},{"color":"red","value":8}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":2,"y":14},
      "id":400,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pg:db:xact_rollback_rate1m{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Rollback","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Databases : TPS for ${cls}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1786&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":32000}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":4,"y":14},
      "id":401,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:xact_rate1m{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"TPS","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : QPS for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1786&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":32000}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":6,"y":14},
      "id":541,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:query_rate1m{cls=\"$cls\",datname=\"$datname\"})","interval":"","legendFormat":"QPS","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Query RT for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1623&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "noValue":"\u2205",
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":2},{"color":"red","value":4},{"color":"#b783af","value":8},{"color":"text","value":16}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":8,"y":14},
      "id":550,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:query_time_rate1m{cls=\"$cls\",  datname=\"$datname\"}) / sum(pgbouncer:db:query_rate1m{cls=\"$cls\",  datname=\"$datname\"})","interval":"","legendFormat":"Query RT","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Pool Clients for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1976&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#fcdb72","value":10000}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":10,"y":14},
      "id":546,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:active_clients{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Pool Client","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Rollback for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=2115&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#fcdb72","value":20},{"color":"#f79f64","value":40},{"color":"red","value":80},{"color":"#b783af","value":100},{"color":"text","value":400}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":12,"y":14},
      "id":545,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:active_servers{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Server","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Backend Number for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=212&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":4},{"color":"#fcdb72","value":400}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":14,"y":14},
      "id":544,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pg_db_numbackends{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Backend","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Queue Client for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=1951&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":2},{"color":"red","value":4},{"color":"#b783af","value":8},{"color":"text","value":16}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":16,"y":14},
      "id":547,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (cls) (pgbouncer_pool_waiting_clients{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Queue","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":1},{"color":"#f79f64","value":2},{"color":"red","value":4},{"color":"#b783af","value":8},{"color":"text","value":16}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":18,"y":14},
      "id":548,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pg:db:ixact_backends{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"iXact","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "decimals":2,
          "links":[{"title":"PGSQL Persist : Age for ${primary}","url":"/d/pgsql-persist?var-ins=${primary}&viewPanel=228&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "max":1,
          "min":0,
          "noValue":"\u2205",
          "thresholds":{"mode":"percentage","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":2},{"color":"#f79f64","value":10},{"color":"red","value":30},{"color":"#b783af","value":90},{"color":"text","value":100}]},
          "unit":"percentunit"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":20,"y":14},
      "id":542,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max(pg:db:age{cls=\"$cls\", datname=\"$datname\"}) / 2147483647","interval":"","legendFormat":"Age","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Database : Size Details for ${cls}.${datname}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&viewPanel=960&${__url_time_range}"}],
          "mappings":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"\u2205"}},"type":"special"}],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1000000000},{"color":"#fcdb72","value":10000000000000},{"color":"#f79f64","value":100000000000000}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":22,"y":14},
      "id":543,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"auto","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12,"valueSize":18},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pg_size_bytes{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"Size","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":17},"id":595,"panels":[],"title":"Metrics","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Tuples fetched from databases",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":3,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"cps"
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":18},
      "id":1618,
      "links":[{"title":"PGSQL Database : CRUD for ${primary}","url":"/d/pgsql-database?var-ins=${primary}&${__url_time_range}"}],
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_tup_fetched{cls=\"$cls\", ins=\"$primary\", datname=\"$datname\"}[5m])" ,             "interval":"","legendFormat":"{{ ins }}\u2b50\ufe0f","range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_tup_fetched{cls=\"$cls\", ins!=\"$primary\", datname=\"$datname\"}[5m])","hide":false,"interval":"","legendFormat":"{{ ins }}"            ,"range":true,"refId":"B" }
      ],
      "title":"Row Fetched (rate5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Tuples fetched, inserted, updated, delete among this cluster",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":50,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":0,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"cps"
        },
        "overrides":[{"matcher":{"id":"byName","options":"DELETED"},"properties":[{"id":"color","value":{"fixedColor":"#cc4637d9","mode":"fixed"}}]},{"matcher":{"id":"byName","options":"INSERTED"},"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]},{"matcher":{"id":"byName","options":"UPDATED"},"properties":[{"id":"color","value":{"fixedColor":"#fcdb72","mode":"fixed"}}]}]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":18},
      "id":1621,
      "links":[{"title":"PGSQL Database : CRUD for ${primary}","url":"/d/pgsql-database?var-ins=${primary}&${__url_time_range}"}],
      "options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum(rate(pg_db_tup_inserted{ins=\"$primary\"}[5m]))","hide":false,"interval":"","intervalFactor":2,"legendFormat":"INSERTED","range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum(rate(pg_db_tup_updated{ins=\"$primary\"}[5m]))" ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"UPDATED" ,"range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum(rate(pg_db_tup_deleted{ins=\"$primary\"}[5m]))" ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"DELETED" ,"range":true,"refId":"D" }
      ],
      "title":"Row Modified (rate5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"`pg_stat_databases`:\n\n`xact_commit` + `xact_rollback` rate in last 5 minutes",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":2,
            "gradientMode":"hue",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Xacts for ${__field.labels.ins}","url":"/d/pgsql-xacts?var-ins=${__field.labels.ins}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"short"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Instance"},"properties":[{"id":"custom.lineWidth","value":0},{"id":"custom.fillOpacity","value":20}]}]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":25},
      "id":1786,
      "options":{"legend":{"calcs":["mean"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum by (ins) (pg:ins:xact_total_rate5m{cls=\"$cls\", ins=\"$primary\"})" ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ ins }} \u2b50\ufe0f","range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum by (ins) (pg:ins:xact_total_rate5m{cls=\"$cls\", ins!=\"$primary\"})","hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ ins }}"             ,"range":true,"refId":"A" }
      ],
      "title":"TPS (rate5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":40,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":0,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":25},
      "id":1949,
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (ins) (pg_activity_max_tx_duration{cls=\"$cls\", ins=\"$primary\", state=\"active\"})" ,             "interval":"","legendFormat":"{{ ins }}\u2b50\ufe0f","range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (ins) (pg_activity_max_tx_duration{cls=\"$cls\", ins!=\"$primary\", state=\"active\"})","hide":false,"interval":"","legendFormat":"{{ ins }}"            ,"range":true,"refId":"B" }
      ],
      "title":"Long Lived Xact",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"bars",
            "fillOpacity":55,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":true,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "decimals":0,
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"green","value":null}]},
          "unit":"short"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"AccessShareLock"}         ,"properties":[{"id":"color","value":{"fixedColor":"#56A64B","mode":"fixed"}}] },{ "matcher":{"id":"byName","options":"RowShareLock"}            ,"properties":[{"id":"color","value":{"fixedColor":"#8AB8FF","mode":"fixed"}}] },
          { "matcher":{"id":"byName","options":"RowExclusiveLock"}        ,"properties":[{"id":"color","value":{"fixedColor":"#3274D9","mode":"fixed"}}] },{ "matcher":{"id":"byName","options":"ShareUpdateExclusiveLock"},"properties":[{"id":"color","value":{"fixedColor":"#F2CC0C","mode":"fixed"}}] },
          { "matcher":{"id":"byName","options":"ShareLock"}               ,"properties":[{"id":"color","value":{"fixedColor":"#CC9D00","mode":"fixed"}}] },{ "matcher":{"id":"byName","options":"ShareRowExclusiveLock"}   ,"properties":[{"id":"color","value":{"fixedColor":"#FF780A","mode":"fixed"}}] },
          { "matcher":{"id":"byName","options":"ExclusiveLock"}           ,"properties":[{"id":"color","value":{"fixedColor":"#E02F44","mode":"fixed"}}] },{ "matcher":{"id":"byName","options":"AccessExclusiveLock"}     ,"properties":[{"id":"color","value":{"fixedColor":"#A352CC","mode":"fixed"}}] }
        ]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":32},
      "id":2278,
      "options":{"legend":{"calcs":["lastNotNull","max"],"displayMode":"table","placement":"bottom","showLegend":true,"sortBy":"Max","sortDesc":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (mode) (pg_lock_count{cls=\"$cls\"})","interval":"","legendFormat":"{{ mode }}","refId":"A"}],
      "title":"Locks",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Database 4k blocks hit ratio in last 1 minute",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "axisSoftMax":1,
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":5,
            "gradientMode":"hue",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "decimals":2,
          "links":[{"title":"PGSQL Database for ${__field.labels.datname}","url":"/d/pgsql-database?var-ins=${ins}&var-datname=${__field.labels.datname}&${__url_time_range}"}],
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"percentunit"
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":32},
      "id":1478,
      "options":{"legend":{"calcs":["min"],"displayMode":"table","placement":"right","showLegend":true,"sortBy":"Min","sortDesc":false},"tooltip":{"mode":"multi","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:db:blks_hit_ratio1m{cls=\"$cls\", ins=\"$primary\", datname=\"$datname\"}" ,             "interval":"","legendFormat":"{{ ins }}\u2b50\ufe0f","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:db:blks_hit_ratio1m{cls=\"$cls\", ins!=\"$primary\", datname=\"$datname\"}","hide":false,"interval":"","legendFormat":"{{ ins }}"            ,"refId":"B" }
      ],
      "title":"Blocks Hit Ratio (1m)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":39},"id":2284,"panels":[],"title":"Pgbouncer","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":2,
            "gradientMode":"hue",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"stepBefore",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]}
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":40},
      "id":1976,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (ins) (pgbouncer:db:active_clients{cls=\"$cls\", ins=\"primary\", datname=\"$datname\"})"  ,             "interval":"","legendFormat":"{{ ins }}\u2b50\ufe0f","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (ins) (pgbouncer:db:active_clients{cls=\"$cls\", ins!=\"primary\",  datname=\"$datname\"})","hide":false,"interval":"","legendFormat":"{{ ins }}"            ,"refId":"B" }
      ],
      "title":"Active Clients (Pgbouncer)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":0,
            "gradientMode":"opacity",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"s"
        },
        "overrides":[
          {"matcher":{"id":"byName","options":"Cluster"},"properties":[{"id":"custom.fillOpacity","value":35},{"id":"custom.lineWidth","value":0},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.gradientMode","value":"scheme"},{"id":"links","value":[{"title":"PGSQL Cluster for ${__field.labels.cls}","url":"/d/pgsql-instance?var-cls=${__field.labels.cls}&${__url_time_range}"}]}]},
          {"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance for ${__field.labels.ins}","url":"/d/pgsql-instance?var-ins=${__field.labels.ins}&${__url_time_range}"}]}]}
        ]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":40},
      "id":1623,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum(pgbouncer:db:query_time_rate1m{cls=\"$cls\", datname=\"$datname\"}) / \nsum(pgbouncer:db:query_rate1m{cls=\"$cls\", datname=\"$datname\"})",             "interval":"","intervalFactor":1,"legendFormat":"Cluster"              ,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pgbouncer:db:query_rt_1m{cls=\"$cls\", ins=\"$primary\", datname=\"$datname\"}"                                                                ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"{{ ins }}\u2b50\ufe0f","refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pgbouncer:db:query_rt_1m{cls=\"$cls\", ins!=\"$primary\", datname=\"$datname\"}"                                                               ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"{{ ins }}"            ,"refId":"C" }
      ],
      "title":"Query RT (Pgbouncer 1m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":51,
            "gradientMode":"hue",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"stepBefore",
            "lineWidth":0,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]}
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":47},
      "id":2115,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (ins) (pgbouncer:db:active_servers{cls=\"$cls\", datname=\"$datname\"})","interval":"","legendFormat":"{{ ins }}","refId":"A"}],
      "title":"Active Servers (Pgbouncer)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]}},
        "overrides":[
          { "matcher":{"id":"byRegexp","options":"/\\[statement\\].*/"}  ,"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]   },{ "matcher":{"id":"byRegexp","options":"/\\[transaction\\].*/"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}] },
          { "matcher":{"id":"byRegexp","options":"/\\[session\\].*/"}    ,"properties":[{"id":"color","value":{"fixedColor":"#fcdb72","mode":"fixed"}}]   }
        ]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":47},
      "id":1951,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"horizontal","percentChangeColorMode":"standard","reduceOptions":{"calcs":["last"],"fields":"","values":false},"showPercentChange":false,"text":{"titleSize":12},"textMode":"auto","wideLayout":true},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (pool_mode,user,datname) (pgbouncer_pool_active_clients{cls=\"$cls\"})","interval":"","legendFormat":"[{{ pool_mode }}]] {{ user }}@{{ datname }}","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":54},"id":615,"panels":[],"title":"Tables","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"`pg_class` and `pg_stat_user_tables` metrics",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"},"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#e3e3e3e0","value":null}]}},
        "overrides":[
          {"matcher":{"id":"byType","options":"number"},"properties":[{"id":"mappings","value":[{"options":{"0":{"color":"#7b7b7be0","index":1,"text":"0"}},"type":"value"},{"options":{"match":"null+nan","result":{"index":0,"text":"-"}},"type":"special"}]},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"Relation"},"properties":[{"id":"links","value":[{"title":"PGSQL Table : ${__data.fields.Relation}","url":"/d/pgsql-table?var-ins=${primary}&var-cls=${cls}&var-datname=${datname}&var-relname=${__data.fields.Relation}&${__url_time_range}"}]},{"id":"custom.minWidth","value":200},{"id":"custom.align","value":"auto"}]},
          {
            "matcher":{"id":"byRegexp","options":"/Scan.*/"},
            "properties":[
              { "id":"custom.width"      ,"value":90                                                                                                                                                                                                                    },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"super-light-green","value":1},{"color":"light-green","value":10},{"color":"semi-dark-green","value":100},{"color":"dark-green","value":1000}]} },
              { "id":"color"             ,"value":{"mode":"thresholds"}                                                                                                                                                                                                 },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                 },
              { "id":"mappings"          ,"value":[{"options":{"0":{"color":"#8080807a","index":1,"text":"0"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"-"}},"type":"special"}]                                        }
            ]
          },{
            "matcher":{"id":"byName","options":"Row"},
            "properties":[
              { "id":"custom.width"      ,"value":110                                                                                                                                                                                                                                                                                                                  },
              { "id":"unit"              ,"value":"locale"                                                                                                                                                                                                                                                                                                             },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1000},{"color":"super-light-green","value":1000000000},{"color":"#fcdb72","value":10000000000},{"color":"#f79f64","value":100000000000},{"color":"red","value":1000000000000},{"color":"#b783af","value":10000000000000}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                                                                },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"N/A"}},"type":"special"}]                                                                                                                                                                                                                 }
            ]
          },{
            "matcher":{"id":"byName","options":"Size"},
            "properties":[
              {"id":"custom.width","value":100},{"id":"unit","value":"bytes"},{"id":"decimals"},{"id":"custom.cellOptions","value":{"type":"color-text"}},
              {
                "id":"thresholds",
                "value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"super-light-blue","value":8192},{"color":"super-light-green","value":8193},{"color":"#346f36cc","value":1000000},{"color":"#fcdb72","value":1000000000},{"color":"#f79f64","value":10000000000},{"color":"red","value":10000000000},{"color":"#b783af","value":30000000000},{"color":"text","value":100000000000}]}
              }
            ]
          },{
            "matcher":{"id":"byName","options":"Row(dead)"},
            "properties":[
              { "id":"custom.width"      ,"value":110                                                                                                                                                                                                                                                                                                                  },
              { "id":"unit"              ,"value":"locale"                                                                                                                                                                                                                                                                                                             },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1000},{"color":"super-light-green","value":1000000000},{"color":"#fcdb72","value":10000000000},{"color":"#f79f64","value":100000000000},{"color":"red","value":1000000000000},{"color":"#b783af","value":10000000000000}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                                                                },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"N/A"}},"type":"special"}]                                                                                                                                                                                                                 }
            ]
          },
          {"matcher":{"id":"byName","options":"Scan(Seq)"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":10},{"color":"#EAB839","value":100},{"color":"#f79f64","value":1000},{"color":"red","value":10000}]}}]},
          {"matcher":{"id":"byName","options":"Row(r/s)"},"properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#807f7f","value":null},{"color":"#3e668f","value":1},{"color":"#346f36cc","value":10},{"color":"#EAB839","value":100},{"color":"#f79f64","value":1000},{"color":"red","value":10000},{"color":"#b783af","value":100000}]}}]},
          {"matcher":{"id":"byName","options":"Row(w/s)"},"properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#747574ba","value":null},{"color":"#3e668f","value":1},{"color":"#346f36cc","value":10},{"color":"#fcdb72","value":100},{"color":"#f79f64","value":1000},{"color":"#E24D42","value":10000},{"color":"#b783af","value":100000}]}}]},
          {
            "matcher":{"id":"byName","options":"Dead%"},
            "properties":[{"id":"custom.width","value":80},{"id":"unit","value":"percentunit"},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":0.1},{"color":"#EAB839","value":0.3},{"color":"#f79f64","value":0.5},{"color":"red","value":0.7},{"color":"#b783af","value":0.99},{"color":"text","value":1}]}},{"id":"decimals","value":1}]
          },
          {"matcher":{"id":"byName","options":"OID"},"properties":[{"id":"custom.width","value":80},{"id":"links","value":[{"title":"PGCAT Table : ${__data.fields.Relation}","url":"/d/pgcat-table?var-dsn=${primary}.${datname}&var-cls=${cls}&var-datname=${datname}&var-relname=${__data.fields.Relation}&${__url_time_range}"}]},{"id":"custom.cellOptions","value":{"type":"auto"}}]}
        ]
      },
      "gridPos":{"h":12,"w":15,"x":0,"y":55},
      "id":237,
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[{"desc":true,"displayName":"Row"}]},
      "pluginVersion":"11.3.0",
      "targets":[
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (relname, relid) (pg_table_relid{ins=\"$primary\"})","format":"table","instant":true,"interval":"","legendFormat":"OID","refId":"A"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (relname) (pg_table_size_bytes{cls=\"$cls\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Table Size","refId":"B"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (pg:table:scan_rate1m{cls=\"$cls\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Table Scan","refId":"C"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (pg:table:scan_rate1m{ins=\"$primary\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Primary Scan","refId":"D"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (pg_table_seq_scan{cls=\"$cls\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Seq Scan","refId":"E"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (rate(pg_table_tup_read{cls=\"$cls\", datname=\"$datname\"}[1m]))","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Tup Read","refId":"F"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (rate(pg_table_n_tup_mod{cls=\"$cls\", datname=\"$datname\"}[1m]))","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Tup Mod","refId":"G"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (relname) (pg_table_n_live_tup{ins=\"$primary\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Tup Live","refId":"H"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (relname) (pg_table_n_dead_tup{ins=\"$primary\", datname=\"$datname\"})","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Tup Dead","refId":"I"},
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (relname) (pg_table_n_dead_tup{ins=\"$primary\", datname=\"$datname\"} / \n(pg_table_n_live_tup{ins=\"$primary\", datname=\"$datname\"} + pg_table_n_dead_tup{ins=\"$primary\", datname=\"$datname\"}))","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"Dead%","refId":"J"}
      ],
      "title":"Tables",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"relname"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{"Time":true,"Time 1":true,"Time 2":true,"Time 3":true,"Time 4":true,"Time 5":true,"Time 6":true,"Time 7":true,"Time 8":true,"Time 9":true,"Value #B":false,"__name__":true,"cls":true,"datname":true,"ins":true,"instance":true,"ip":true,"job":true},
            "indexByName":{"Time 1":10,"Time 10":20,"Time 2":11,"Time 3":12,"Time 4":13,"Time 5":14,"Time 6":15,"Time 7":16,"Time 8":17,"Time 9":19,"Value #A":1,"Value #B":18,"Value #C":3,"Value #D":4,"Value #E":5,"Value #F":6,"Value #G":7,"Value #H":2,"Value #I":8,"Value #J":9,"relname":0},
            "renameByName":{"Time":"","Time 2":"","Time 4":"","Value":"OID","Value #A":"OID","Value #B":"Size","Value #C":"Scan","Value #D":"Scan (P)","Value #E":"Scan(Seq)","Value #F":"Row(r/s)","Value #G":"Row(w/s)","Value #H":"Row","Value #I":"Row(dead)","Value #J":"Dead%","Value #K":"Last Vacuum","relname":"Relation"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Index Scan + Seq Scan on this table per second.\n\nSize by table size, Color by table scan rate.",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Table for ${__data.fields.relname}","url":"/d/pgsql-table?var-ins=${primary}&var-cls=${cls}&var-datname=${datname}&var-relname=${__data.fields.relname}&${__url_time_range}"},{"title":"PGCAT Table : ${__data.fields.relname}","url":"/d/pgcat-table?var-dsn=${primary}.${datname}&var-cls=${cls}&var-datname=${datname}&var-relname=${__data.fields.relname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"short"
        },
        "overrides":[
          {"matcher":{"id":"byName","options":"Size"},"properties":[{"id":"unit","value":"decbytes"}]},
          {
            "matcher":{"id":"byName","options":"Scan"},
            "properties":[
              { "id":"unit"      ,"value":"reqps"                                                                                                                                                                                                                                                                          },
              { "id":"thresholds","value":{"mode":"absolute","steps":[{"color":"super-light-blue","value":null},{"color":"super-light-green","value":0.01},{"color":"#346f36cc","value":1},{"color":"super-light-yellow","value":10},{"color":"super-light-orange","value":100},{"color":"super-light-red","value":1000}]} },
              { "id":"mappings"  ,"value":[{"options":{"match":"null+nan","result":{"color":"#808080a3","index":0,"text":"inactive"}},"type":"special"}]                                                                                                                                                                   }
            ]
          }
        ]
      },
      "gridPos":{"h":12,"w":9,"x":15,"y":55},
      "id":960,
      "options":{"colorByField":"Value #B","labelFields":["Value #A","Value #B"],"sizeField":"Value #A","textField":"relname","tiling":"treemapSquarify"},
      "pluginVersion":"2.0.1",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (relname) (pg_table_size_bytes{cls=\"$cls\", datname=\"$datname\"})"         ,"format":"table",             "instant":true,"interval":"","intervalFactor":2,"legendFormat":"{{ relname }}","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (\n    pg:table:scan_rate1m{cls=\"$cls\", datname=\"$datname\"}\n)","format":"table","hide":false,"instant":true,"interval":"","intervalFactor":2,"legendFormat":"{{ relname }}","refId":"B" }
      ],
      "title":"Table Size & Access",
      "transformations":[{"id":"seriesToColumns","options":{"byField":"relname"}},{"id":"organize","options":{"excludeByName":{"Time 1":true,"Time 2":true},"indexByName":{"Time 1":3,"Time 2":4,"Value #A":1,"Value #B":2,"relname 1":0},"renameByName":{"Value #A":"Size","Value #B":"Scan","relname 1":"Relation"}}}],
      "type":"marcusolsson-treemap-panel"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Index Scan + Seq Scan on this table per second",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":2,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Table for ${__field.labels.relname}","url":"/d/pgsql-table?var-ins=${primary}&var-cls=${cls}&var-datname=${datname}&var-relname=${__field.labels.relname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"short"
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":67},
      "id":635,
      "options":{"legend":{"calcs":["mean"],"displayMode":"table","placement":"right","showLegend":true,"sortBy":"Mean","sortDesc":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (\n    pg:table:scan_rate1m{cls=\"$cls\", datname=\"$datname\"}\n)","interval":"","intervalFactor":2,"legendFormat":"{{ relname }}","refId":"A"}],
      "title":"Table Scan (scan/s)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":2,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Table for ${__field.labels.relname}","url":"/d/pgsql-table?var-ins=${primary}&var-cls=${cls}&var-datname=${datname}&var-relname=${__field.labels.relname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"short"
        },
        "overrides":[]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":67},
      "id":798,
      "options":{"legend":{"calcs":["mean"],"displayMode":"table","placement":"right","showLegend":true,"sortBy":"Mean","sortDesc":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"sum by (relname) (\n    rate(pg_table_tup_read{cls=\"$cls\", datname=\"$datname\"}[1m])\n)","interval":"","intervalFactor":2,"legendFormat":"{{ relname }}","refId":"A"}],
      "title":"Tuple Read (rows/s)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":74},"id":1125,"panels":[],"title":"Queries","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"`pg_stat_statements` metrics of database ${datname} in this cluster: ${cls}.\n\nClick the `Instance` Column will goes to PGSQL Database Dashboard.",
      "fieldConfig":{
        "defaults":{"custom":{"align":"center","cellOptions":{"type":"auto"},"filterable":false,"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},"unit":"none"},
        "overrides":[
          {"matcher":{"id":"byName","options":"Query"},"properties":[{"id":"links","value":[{"title":"PGSQL Query ${__data.fields.Query} on ${__data.fields.Instance}","url":"/d/pgsql-query?var-ins=${__data.fields.Instance}&var-cls=${cls}&var-datname=${datname}&var-query=${__data.fields.Query}&${__url_time_range}"}]},{"id":"unit","value":"string"},{"id":"custom.width","value":210}]},
          {
            "matcher":{"id":"byName","options":"RT"},
            "properties":[
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null},{"color":"#fcdb72","value":0.001},{"color":"#f79f64","value":0.002},{"color":"red","value":0.004},{"color":"#b783af","value":0.008}]} },
              { "id":"unit"              ,"value":"s"                                                                                                                                                                                                  },
              { "id":"custom.width"      ,"value":100                                                                                                                                                                                                  },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"-"}},"type":"special"}]                                                                                                   }
            ]
          },{
            "matcher":{"id":"byName","options":"Call"},
            "properties":[
              { "id":"custom.width"      ,"value":72                                                                                                                                                                                                                                                                      },
              { "id":"unit"              ,"value":"short"                                                                                                                                                                                                                                                                 },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"super-light-green","value":1000},{"color":"#fcdb72","value":1000000},{"color":"#f79f64","value":1000000000},{"color":"red","value":1000000000000},{"color":"#b783af","value":1000000000000000}]} },
              { "id":"mappings"          ,"value":[{"options":{"match":"null+nan","result":{"color":"gray","index":0,"text":"N/A"}},"type":"special"}]                                                                                                                                                                    },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                   }
            ]
          },
          {"matcher":{"id":"byName","options":"Time"},"properties":[{"id":"custom.width","value":80},{"id":"decimals","value":1},{"id":"unit","value":"ms"}]},
          {
            "matcher":{"id":"byName","options":"QPS"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                                                                                                                                                     },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                                  },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"super-light-green","value":0.1},{"color":"#346f36cc","value":1},{"color":"#EAB839","value":10},{"color":"#f79f64","value":100},{"color":"red","value":1000},{"color":"#b783af","value":10000}]} },
              { "id":"mappings"          ,"value":[{"options":{"0":{"color":"#80808080","index":0,"text":"0"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"#808080","index":1,"text":"-"}},"type":"special"}]                                                                                      }
            ]
          },
          {"matcher":{"id":"byName","options":"Database"},"properties":[{"id":"links","value":[{"title":"PGSQL Database for ${__data.fields.Database}","url":"/d/pgsql-database?var-ins=${ins}&var-datname=${__data.fields.Database}&${__url_time_range}"}]}]},
          {
            "matcher":{"id":"byName","options":"Rows"},
            "properties":[
              { "id":"custom.width"      ,"value":90                                                                                                                                                                                                                                                              },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#3e668f","value":1},{"color":"#346f36cc","value":10},{"color":"#fcdb72","value":100},{"color":"#f79f64","value":1000},{"color":"red","value":10000},{"color":"#b783af","value":100000}]} },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                                                                                           },
              { "id":"unit"              ,"value":"locale"                                                                                                                                                                                                                                                        },
              { "id":"decimals"          ,"value":0                                                                                                                                                                                                                                                               },
              { "id":"mappings"          ,"value":[{"options":{"0":{"color":"#80808080","index":0,"text":"0"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"#808080","index":1,"text":"-"}},"type":"special"}]                                                                               }
            ]
          },
          {"matcher":{"id":"byName","options":"Instance"},"properties":[{"id":"custom.minWidth","value":120},{"id":"links","value":[{"title":"PGSQL Database : ${__data.fields.Instance}.${datname}","url":"/d/pgsql-database?var-ins=${__data.fields.Instance}&var-datname=${datname}&${__url_time_range}"}]}]},
          {
            "matcher":{"id":"byName","options":"WAL"},
            "properties":[
              { "id":"custom.width"      ,"value":80                                                                                                                                                                                },
              { "id":"unit"              ,"value":"decbytes"                                                                                                                                                                        },
              { "id":"decimals"          ,"value":0                                                                                                                                                                                 },
              { "id":"mappings"          ,"value":[{"options":{"0":{"color":"#80808080","index":0,"text":"0"}},"type":"value"},{"options":{"match":"null+nan","result":{"color":"#808080","index":1,"text":"-"}},"type":"special"}] },
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                             },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#3e668f","value":null},{"color":"#346f36cc","value":1024},{"color":"#f79f64","value":1024000}]}                                             }
            ]
          }
        ]
      },
      "gridPos":{"h":12,"w":15,"x":0,"y":75},
      "id":1123,
      "links":[{"title":"PGSQL Database : ${primary}.${datname}","url":"/d/pgsql-database?var-ins=${primary}&var-datname=${datname}&${__url_time_range}&viewPanel=118"}],
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[{"desc":true,"displayName":"Call"}]},
      "pluginVersion":"11.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"sum by (ins, query) (pg_query_calls{cls=\"$cls\", datname=\"$datname\"}) > 0"                                                                      ,"format":"table",             "instant":true,"interval":"","legendFormat":"{{ query }}","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (query) (pg_query_exec_time{cls=\"$cls\", datname=\"$datname\"})"                                                                           ,"format":"table",             "instant":true,"interval":"","legendFormat":"{{ query }}","refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (query) (pg:query:rt_1m{cls=\"$cls\", datname=\"$datname\"})"                                                                               ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (query) (pg:query:call_rate1m{cls=\"$cls\", datname=\"$datname\"})"                                                                         ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"D" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"max by (query) (rate(pg_query_rows{cls=\"$cls\", datname=\"$datname\"}[5m])\n/ rate(pg_query_calls{cls=\"$cls\", datname=\"$datname\"}[5m])\n)"    ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"E" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"sum by (query) (rate(pg_query_wal_bytes{cls=\"$cls\", datname=\"$datname\"}[5m]) / rate(pg_query_calls{cls=\"$cls\", datname=\"$datname\"}[5m])\n)","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"F" }
      ],
      "title":"Statements",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"query"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{"Time":true,"Time 1":true,"Time 2":true,"Time 3":true,"Time 4":true,"Time 5":true,"Time 6":true,"Time 7":true,"Time 8":true,"datname":true,"ins":false},
            "indexByName":{"Time 1":5,"Time 2":9,"Time 3":10,"Time 4":11,"Time 5":12,"Time 6":13,"Value #A":2,"Value #B":3,"Value #C":4,"Value #D":6,"Value #E":7,"Value #F":8,"ins":0,"query":1},
            "renameByName":{"Time 1":"RT (rate1m)","Value #A":"Call","Value #B":"Time","Value #C":"RT","Value #D":"QPS","Value #E":"Rows","Value #F":"WAL","Value #G":"Call (rate1h)","Value #H":"Time (rate1h)","datname":"Database","ins":"Instance","query":"Query"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Area represent time spent in last 1h\ncolor represent RT of this query",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Query : ${__data.fields.query} on ${__data.fields.ins}","url":"/d/pgsql-query?var-cls=${cls}&var-datname=${datname}&var-ins=${__data.fields.ins}&var-query=${__data.fields.query}&${__url_time_range}"}],
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"super-light-blue","value":null},{"color":"#3e668f","value":0.0001},{"color":"super-light-green","value":0.001},{"color":"#346f36cc","value":0.002},{"color":"#EAB839","value":0.01},{"color":"#f79f64","value":0.1},{"color":"red","value":1},{"color":"#b783af","value":6},{"color":"text","value":60}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byName","options":"query"},"properties":[{"id":"unit","value":"string"}]},{"matcher":{"id":"byName","options":"Time"},"properties":[{"id":"unit","value":"s"}]},{"matcher":{"id":"byName","options":"RT"},"properties":[{"id":"unit","value":"s"},{"id":"mappings","value":[{"options":{"match":"null+nan","result":{"color":"#808080b3","index":0,"text":"Inactive"}},"type":"special"}]}]}]
      },
      "gridPos":{"h":12,"w":9,"x":15,"y":75},
      "id":1453,
      "links":[{"title":"PGSQL Database : ${primary}.${datname}","url":"/d/pgsql-database?var-ins=${primary}&var-datname=${datname}&${__url_time_range}&viewPanel=135"}],
      "options":{"colorByField":"Value #B","colorField":"rt","labelFields":["ins","ip","Value #A","Value #B"],"sizeField":"Value #A","textField":"query","tiling":"treemapSquarify"},
      "pluginVersion":"2.0.1",
      "targets":[
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "exemplar":false,
          "expr":"increase(pg_query_exec_time{cls=\"$cls\", datname=\"$datname\"}[1h])",
          "format":"table",
          "group":[],
          "interval":"",
          "legendFormat":"",
          "metricColumn":"none",
          "rawQuery":true,
          "refId":"A",
          "select":[[{"params":["video_duration"],"type":"column"}]],
          "table":"predefined_message_translations1",
          "timeColumn":"created_time",
          "timeColumnType":"timestamp",
          "where":[{"name":"$__timeFilter","params":[],"type":"macro"}]
        },{
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "exemplar":false,
          "expr":"max by (query) (pg:query:rt_1m{cls=\"$cls\", datname=\"$datname\"})",
          "format":"table",
          "group":[],
          "hide":false,
          "interval":"",
          "legendFormat":"",
          "metricColumn":"none",
          "rawQuery":true,
          "refId":"B",
          "select":[[{"params":["video_duration"],"type":"column"}]],
          "table":"predefined_message_translations1",
          "timeColumn":"created_time",
          "timeColumnType":"timestamp",
          "where":[{"name":"$__timeFilter","params":[],"type":"macro"}]
        }
      ],
      "title":"Query Time Spent & RT",
      "transformations":[{"id":"seriesToColumns","options":{"byField":"query"}},{"id":"organize","options":{"excludeByName":{"Time 1":true,"Time 2":true,"instance":true,"ip":true,"job":true},"indexByName":{"Time 1":9,"Time 2":10,"Value #A":0,"Value #B":1,"cls":3,"datname":4,"ins":5,"instance":6,"ip":7,"job":8,"query":2},"renameByName":{"Value #A":"Time","Value #B":"RT","query":""}}}],
      "type":"marcusolsson-treemap-panel"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"`dM/dt`, where `M` is `calls`, which is queries per second, in last minute",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query} on ${__field.labels.ins}","url":"/d/pgsql-query?var-ins=${__field.labels.ins}&var-cls=${cls}&var-datname=${datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"ops"
        },
        "overrides":[]
      },
      "gridPos":{"h":8,"w":12,"x":0,"y":87},
      "id":1290,
      "links":[{"title":"PGSQL Query QPS : ${primary}.${datname}","url":"/d/pgsql-database?var-ins=${primary}&var-datname=${datname}&${__url_time_range}&viewPanel=133"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:query:call_rate1m{cls=\"$cls\", datname=\"$datname\"}","interval":"","intervalFactor":2,"legendFormat":"{{ query }}","refId":"B"}],
      "title":"Query QPS (1m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"dM/dC, where M is total_exec_time and C is calls, which means query latency in last 1 minute",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":1,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query} on ${__field.labels.ins}","url":"/d/pgsql-query?var-ins=${__field.labels.ins}&var-cls=${cls}&var-datname=${datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":null}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":8,"w":12,"x":12,"y":87},
      "id":1288,
      "links":[{"title":"PGSQL Query RT : ${primary}.${datname}","url":"/d/pgsql-database?var-ins=${primary}&var-datname=${datname}&${__url_time_range}&viewPanel=134"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},
      "pluginVersion":"11.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:query:rt_1m{cls=\"$cls\", datname=\"$datname\"}","interval":"","intervalFactor":2,"legendFormat":"{{ query }}","refId":"B"}],
      "title":"Query RT (1m)",
      "type":"timeseries"
    }
  ],
  "preload":false,
  "refresh":"",
  "schemaVersion":40,
  "tags":["Pigsty","PGSQL","Cluster"],
  "templating":{
    "list":[
      {
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_up, cls)",
        "description":"Cluster identifier for this postgres instance, cls should be unique among entire environment. such as pg-meta, pg-test",
        "includeAll":false,
        "label":"Cluster",
        "name":"cls",
        "options":[],
        "query":{"query":"label_values(pg_up, cls)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg:cls:leader{cls=\"$cls\"}, ins)",
        "description":"Unique instance identifier (e.g pg-meta-1)",
        "hide":2,
        "includeAll":false,
        "label":"Primary",
        "name":"primary",
        "options":[],
        "query":{"query":"label_values(pg:cls:leader{cls=\"$cls\"}, ins)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_up{cls=\"$cls\"}, ins)",
        "description":"Unique instance identifier (e.g pg-meta-1)",
        "hide":2,
        "includeAll":true,
        "label":"Primary",
        "multi":true,
        "name":"members",
        "options":[],
        "query":{"query":"label_values(pg_up{cls=\"$cls\"}, ins)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_db_age{cls=\"$cls\"}, datname)",
        "description":"Unique instance identifier (e.g pg-meta-1)",
        "includeAll":false,
        "label":"Database",
        "name":"datname",
        "options":[],
        "query":{"query":"label_values(pg_db_age{cls=\"$cls\"}, datname)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"(?!^template\\d$)(^.*$)",
        "sort":1,
        "type":"query"
      }
    ]
  },
  "time":{"from":"now-1h","to":"now"},
  "timepicker":{},
  "timezone":"browser",
  "title":"PGSQL Databases",
  "uid":"pgsql-databases",
  "version":1,
  "weekStart":""
}