{
  "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 Replication of Single cluster",
  "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":70,"panels":[],"title":"Overview","type":"row"},
    {
      "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},
      "description":"",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"mappings":[],"max":2.5,"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"#3e668f"}]}},
        "overrides":[{"matcher":{"id":"byFrameRefID","options":"A"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance : ${primary}","url":"/d/pgsql-instance?var-ins=${primary}&${__url_time_range}"}]}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"links","value":[{"title":"PGSQL Cluster : ${cls}","url":"/d/pgsql-cluster?var-cls=${cls}&${__url_time_range}"}]}]}]
      },
      "gridPos":{"h":5,"w":6,"x":0,"y":1},
      "id":115,
      "options":{"colorMode":"background","graphMode":"area","justifyMode":"auto","orientation":"horizontal","percentChangeColorMode":"standard","reduceOptions":{"calcs":["lastNotNull"],"fields":"/.*/","values":true},"showPercentChange":false,"text":{"titleSize":16,"valueSize":16},"textMode":"value_and_name","wideLayout":true},
      "pluginVersion":"12.0.0",
      "targets":[
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Cluster","type":"string","values":["${cls}"]}],"meta":{},"name":""} ,"hide":false,"refId":"B" },
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Leader","type":"string","values":["$primary"]}],"meta":{},"name":""},"hide":false,"refId":"A" }
      ],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"All instances among pgsql cluster ${cls}\n\nInstance: Goto PGSQL Instance\n\nIP: Goto PGSQL Node\n\nStatus: Goto PGSQL Service\n\nLoad: max(cpu,postgres,pgbouncer)\n\nSpace: Disk space usage max(all device)\n\nProxy: session number, Goto Haproxy Admin Page",
      "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"}]}},
        "overrides":[
          {"matcher":{"id":"byName","options":"Instance"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance ${__data.fields.Instance}","url":"/d/pgsql-instance?var-ins=${__data.fields.Instance}&${__url_time_range}"}]},{"id":"custom.width"}]},
          {"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"},{"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                                                                                                                                                                                                                                          }
            ]
          },
          {"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"},{"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"},{"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"},{"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"},{"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"},{"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"},{"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":5,"w":18,"x":6,"y":1},
      "id":113,
      "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":"12.0.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":"",
      "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":"Replication Status among cluster ${cls}",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"},"filterable":false,"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#e3e3e3e0"}]}},
        "overrides":[
          {
            "matcher":{"id":"byName","options":"STATE"},
            "properties":[
              { "id":"custom.width"      ,"value":100                                                                                                                                                                                                                                                                                                                                                             },
              { "id":"mappings"          ,"value":[{"options":{"-1":{"color":"#a352ccbf","index":0,"text":"unknown"},"0":{"color":"#346f36cc","index":1,"text":"streaming"},"1":{"color":"#e02f44bf","index":2,"text":"startup"},"2":{"color":"#f2cc0cbf","index":3,"text":"catchup"},"3":{"color":"#3275d9bf","index":4,"text":"backup"},"4":{"color":"#ff780abf","index":5,"text":"stopping"}},"type":"value"}] },
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}                                                                                                                                                                                                                                                                                                                   }
            ]
          },
          {"matcher":{"id":"byName","options":"TLI"},"properties":[{"id":"custom.width","value":60}]},
          {
            "matcher":{"id":"byName","options":"SYNC"},
            "properties":[
              { "id":"mappings"          ,"value":[{"options":{"-1":{"color":"#a352ccbf","index":4,"text":"unknown"},"0":{"color":"#346f36cc","index":0,"text":"async"},"1":{"color":"#f2cc0cbf","index":1,"text":"potential"},"2":{"color":"#3275d9bf","index":2,"text":"sync"},"3":{"color":"#ff780abf","index":3,"text":"quorum"}},"type":"value"}] },
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}                                                                                                                                                                                                                                                        },
              { "id":"custom.width"      ,"value":90                                                                                                                                                                                                                                                                                                   }
            ]
          },
          {"matcher":{"id":"byName","options":"SRC"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance for replication source instance ${__data.fields.SRC}","url":"/d/pgsql-instance?var-ins=${__data.fields.SRC}&${__url_time_range}"}]}]},
          {"matcher":{"id":"byName","options":"DST"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance for replication destination instance ${__data.fields.DST}","url":"/d/pgsql-instance?var-ins=${__data.fields.DST}&${__url_time_range}"}]}]},
          {"matcher":{"id":"byName","options":"SRC IP"},"properties":[{"id":"custom.width","value":150},{"id":"links","value":[{"title":"PGSQL Node : ${__data.fields[\"SRC IP\"]}","url":"/d/node-instance?var-id=${__data.fields[\"SRC IP\"]}&${__url_time_range}"}]}]},
          {"matcher":{"id":"byName","options":"DST IP"},"properties":[{"id":"custom.width","value":150},{"id":"links","value":[{"title":"PGSQL Node: ${__data.fields[\"DST IP\"]}","url":"/d/node-instance?var-id=${__data.fields[\"DST IP\"]}&${__url_time_range}"}]}]}
        ]
      },
      "gridPos":{"h":5,"w":24,"x":0,"y":6},
      "id":110,
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[]},
      "pluginVersion":"12.0.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:cls:sender{cls=\"$cls\"}"  ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg:cls:receiver{cls=\"$cls\"}","format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"B" }
      ],
      "title":"",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"appname"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{"Time":true,"Time 1":true,"Time 2":true,"Value #A":false,"__name__":true,"__name__ 1":true,"__name__ 2":true,"address":true,"cls":true,"cls 1":true,"cls 2":true,"ip":false,"job":true,"job 1":true,"job 2":true,"pid":true,"sender_host":true,"sender_port":true,"usename":true},
            "indexByName":{"Time 1":11,"Time 2":15,"Value #A":1,"Value #B":7,"__name__ 1":12,"__name__ 2":16,"address":13,"appname":3,"cls 1":14,"cls 2":17,"ins":2,"ip 1":4,"ip 2":5,"job 1":19,"job 2":20,"pid":8,"sender_host":10,"sender_port":18,"slot_name":6,"state":0,"usename":9},
            "renameByName":{"Value":"TLI","Value #A":"SYNC","Value #B":"TLI","address":"","appname":"DST","ins":"SRC","ip":"SRC IP","ip 1":"SRC IP","ip 2":"DST IP","pid":"PID","sender_host":"","sender_port":"","slot_name":"SLOT","state":"STATE","usename":"USER"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Leadership shows who is in charge of this cluster ${cls}",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"hidden",
            "axisSoftMin":0,
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":57,
            "gradientMode":"none",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"stepBefore",
            "lineWidth":0,
            "pointSize":1,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "max":1,
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byType","options":"time"},"properties":[{"id":"custom.axisPlacement","value":"auto"}]}]
      },
      "gridPos":{"h":5,"w":8,"x":0,"y":11},
      "id":56,
      "options":{"legend":{"calcs":[],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg:cls:leader{cls=\"$cls\"}","interval":"","legendFormat":"leader: {{ ins }}","refId":"A"}],
      "title":"Leadership",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Replication Slot of cluster $cls on Primary Instance $primary",
      "fieldConfig":{
        "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"},"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]}},
        "overrides":[
          {"matcher":{"id":"byName","options":"Retained"},"properties":[{"id":"custom.width","value":80},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"#f79f64","value":1000000000},{"color":"red","value":100000000000}]}},{"id":"unit","value":"decbytes"},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"Active"},"properties":[{"id":"custom.width","value":80},{"id":"mappings","value":[{"options":{"0":{"color":"#f79f64","index":0,"text":"Inactive"},"1":{"color":"#346f36cc","index":1,"text":"Active"}},"type":"value"}]},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {"matcher":{"id":"byName","options":"Tmp"},"properties":[{"id":"custom.width","value":80},{"id":"mappings","value":[{"options":{"0":{"color":"#346f36cc","index":0,"text":"Perm"},"1":{"color":"#f79f64","index":1,"text":"Temp"}},"type":"value"}]},{"id":"custom.cellOptions","value":{"type":"color-text"}}]},
          {
            "matcher":{"id":"byName","options":"Status"},
            "properties":[
              { "id":"custom.width"      ,"value":100                                                                                                                                                                                                                                                                                                           },
              { "id":"mappings"          ,"value":[{"options":{"-1":{"color":"rgba(128, 128, 128, 1)","index":4,"text":"Unknown"},"0":{"color":"#346f36cc","index":0,"text":"Reserved"},"1":{"color":"#fcdb72","index":1,"text":"Extended"},"2":{"color":"#f79f64","index":2,"text":"Unreserved"},"3":{"color":"red","index":3,"text":"Lost"}},"type":"value"}] },
              { "id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}                                                                                                                                                                                                                                                                 }
            ]
          },
          {"matcher":{"id":"byName","options":"Restart LSN"},"properties":[{"id":"unit","value":"hex"},{"id":"custom.width","value":100}]}
        ]
      },
      "gridPos":{"h":5,"w":16,"x":8,"y":11},
      "id":100,
      "options":{"cellHeight":"sm","footer":{"countRows":false,"fields":"","reducer":["sum"],"show":false},"showHeader":true,"sortBy":[]},
      "pluginVersion":"12.0.0",
      "targets":[
        { "editorMode":"code","exemplar":false,"expr":"max by (ins, slot_name, datname) (pg_slot_retained_bytes{cls=\"$cls\", ins=\"$primary\"})","format":"table",             "instant":true,"interval":"","legendFormat":"","refId":"A" },
        { "editorMode":"code","exemplar":false,"expr":"max by (slot_name) (pg_slot_active{cls=\"$cls\", ins=\"$primary\"})"                      ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"B" },
        { "editorMode":"code","exemplar":false,"expr":"max by (slot_name) (pg_slot_temporary{cls=\"$cls\", ins=\"$primary\"})"                   ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"C" },
        { "editorMode":"code","exemplar":false,"expr":"max by (slot_name) (pg_slot_wal_status{cls=\"$cls\", ins=\"$primary\"})"                  ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"D" },
        { "editorMode":"code","exemplar":false,"expr":"max by (slot_name) (pg_slot_restart_lsn{cls=\"$cls\", ins=\"$primary\"})"                 ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","refId":"E" }
      ],
      "title":"Replication Slots",
      "transformations":[
        {"id":"seriesToColumns","options":{"byField":"slot_name"}},
        {
          "id":"organize",
          "options":{
            "excludeByName":{"Time 1":true,"Time 2":true,"Time 3":true,"Time 4":true,"Time 5":true,"ins":true},
            "indexByName":{"Time 1":7,"Time 2":8,"Time 3":9,"Time 4":10,"Time 5":11,"Value #A":2,"Value #B":3,"Value #C":4,"Value #D":5,"Value #E":6,"ins":0,"slot_name":1},
            "renameByName":{"Value #A":"Retained","Value #B":"Active","Value #C":"Tmp","Value #D":"Status","Value #E":"Restart LSN","ins":"Instance","slot_name":"Slot"}
          }
        }
      ],
      "type":"table"
    },
    {
      "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":25,
            "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"}
          },
          "decimals":0,
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[]
      },
      "gridPos":{"h":6,"w":8,"x":0,"y":16},
      "id":82,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg_timeline_id{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }}","refId":"A"}],
      "title":"Timeline",
      "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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Instance for ${__field.labels.appname}","url":"/d/pgsql-instance?var-ins=${__field.labels.appname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":6,"w":14,"x":8,"y":16},
      "id":83,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg_repl_replay_diff{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }} \u2192 {{ appname }}@{{ address }}","refId":"A"}],
      "title":"Replication Lag in Bytes",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Replication lag in bytes for Cluster ${cls}","url":"/d/pgsql-replication?var-cls=${cls}&viewPanel=73&${__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"},{"color":"#fcdb72","value":1000},{"color":"#f79f64","value":100000},{"color":"red","value":1000000},{"color":"#b783af","value":10000000},{"color":"text","value":100000000}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":22,"y":16},
      "id":61,
      "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":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg:cls:lag_bytes{cls=\"$cls\"}","interval":"","legendFormat":"Lag (B)","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Replication Detail in seconds for Cluster ${cls}","url":"/d/pgsql-replication?var-cls=${cls}&viewPanel=74&${__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"},{"color":"#fcdb72","value":0.1},{"color":"#f79f64","value":1},{"color":"red","value":4},{"color":"#b783af","value":16},{"color":"text","value":64}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":3,"w":2,"x":22,"y":19},
      "id":48,
      "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":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg:cls:lag_seconds{cls=\"$cls\"}","interval":"","legendFormat":"Lag (s)","refId":"A"}],
      "title":"",
      "type":"stat"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":22},"id":80,"panels":[],"title":"Metrics","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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Instance for ${__field.labels.appname}","url":"/d/pgsql-instance?var-ins=${__field.labels.appname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":10,"w":12,"x":0,"y":23},
      "id":73,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg_repl_replay_diff{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}","refId":"A"}],
      "title":"Replication Lag in Bytes",
      "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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Instance for ${__field.labels.appname}","url":"/d/pgsql-instance?var-ins=${__field.labels.appname}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":10,"w":12,"x":12,"y":23},
      "id":74,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg_repl_replay_lag{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}","refId":"A"}],
      "title":"Replication Lag in Seconds",
      "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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":10,"w":12,"x":0,"y":33},
      "id":98,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[
        { "exemplar":false,"expr":"pg_repl_lsn{cls=\"$cls\"} - pg_repl_sent_lsn{cls=\"$cls\"}"        ,             "interval":"","legendFormat":"[SENT] {{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}"  ,"refId":"A" },
        { "exemplar":false,"expr":"pg_repl_sent_lsn{cls=\"$cls\"} - pg_repl_write_lsn{cls=\"$cls\"}"  ,"hide":false,"interval":"","legendFormat":"[WRITE] {{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}" ,"refId":"B" },
        { "exemplar":false,"expr":"pg_repl_write_lsn{cls=\"$cls\"} - pg_repl_flush_lsn{cls=\"$cls\"}" ,"hide":false,"interval":"","legendFormat":"[FLUSH] {{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}" ,"refId":"C" },
        { "exemplar":false,"expr":"pg_repl_replay_lsn{cls=\"$cls\"} - pg_repl_flush_lsn{cls=\"$cls\"}","hide":false,"interval":"","legendFormat":"[REPLAY] {{ ins }} \u2192 {{ usename }}:{{ appname }}@{{ address }}","refId":"D" }
      ],
      "title":"Replication Lag in Detail",
      "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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"s"
        },
        "overrides":[]
      },
      "gridPos":{"h":10,"w":12,"x":12,"y":33},
      "id":97,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.0.0",
      "targets":[{"exemplar":false,"expr":"pg_lag{cls=\"$cls\"}","interval":"","legendFormat":"\u2192 {{ ins }}","refId":"A"}],
      "title":"Replication Lag in Seconds (Follower's View)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":43},"id":86,"panels":[],"title":"LSN","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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]},
          "unit":"hex"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.fillOpacity","value":20}]}]
      },
      "gridPos":{"h":10,"w":24,"x":0,"y":44},
      "id":92,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[
        { "exemplar":false,"expr":"max(pg_repl_lsn{cls=\"$cls\"})"   ,             "interval":"","legendFormat":"Current"                       ,"refId":"A" },{ "exemplar":false,"expr":"pg_repl_replay_lsn{cls=\"$cls\"}" ,"hide":false,"interval":"","legendFormat":"replay @ {{ appname }}"        ,"refId":"B" },
        { "exemplar":false,"expr":"pg_repl_flush_lsn{cls=\"$cls\"}"  ,"hide":false,"interval":"","legendFormat":"flush @ {{ appname }}"         ,"refId":"C" },{ "exemplar":false,"expr":"pg_repl_write_lsn{cls=\"$cls\"}"  ,"hide":false,"interval":"","legendFormat":"write @ {{ appname }}"         ,"refId":"D" },
        { "exemplar":false,"expr":"pg_slot_restart_lsn{cls=\"$cls\"}","hide":false,"interval":"","legendFormat":"slot restart @ {{ slot_name }}","refId":"E" }
      ],
      "title":"Replication LSN Progress",
      "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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]},
          "unit":"hex"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"super-light-orange","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":9,"w":24,"x":0,"y":54},
      "id":90,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[
        { "exemplar":false,"expr":"max(pg_lsn{cls=\"$cls\"})"                                    ,             "interval":"","legendFormat":"Current"                      ,"refId":"A" },{ "exemplar":false,"expr":"pg_checkpoint_checkpoint_lsn{ins=\"$primary\"}"               ,"hide":false,"interval":"","legendFormat":"Checkpoint Leader $primary"   ,"refId":"B" },
        { "exemplar":false,"expr":"pg_checkpoint_checkpoint_lsn{cls=\"$cls\", ins!=\"$primary\"}","hide":false,"interval":"","legendFormat":"Checkpoint Follower {{ ins }}","refId":"C" },{ "exemplar":false,"expr":"pg_checkpoint_redo_lsn{cls=\"$cls\", ins!=\"$primary\"}"      ,"hide":false,"interval":"","legendFormat":"Redo {{ ins }}"               ,"refId":"D" }
      ],
      "title":"Checkpoint LSN Progress",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Rate of lsn 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":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]},
          "unit":"Bps"
        },
        "overrides":[]
      },
      "gridPos":{"h":8,"w":24,"x":0,"y":63},
      "id":91,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[{"exemplar":false,"expr":"pg:ins:lsn_rate1m{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }}","refId":"A"}],
      "title":"LSN Progress Rate 1m",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":71},"id":88,"panels":[],"title":"XID","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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"super-light-orange","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":0,"y":72},
      "id":96,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg_xact_xmax{cls=\"$cls\"}","interval":"","legendFormat":"xmax-{{ ins }}","refId":"A"},{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"pg_xact_xmin{cls=\"$cls\"}","hide":true,"interval":"","legendFormat":"xmin-{{ ins }}","refId":"B"}],
      "title":"XMax Progress",
      "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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"super-light-orange","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":12,"y":72},
      "id":94,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[{"exemplar":false,"expr":"pg_xact_xmin{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }}","refId":"A"}],
      "title":"Xmin Progress",
      "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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"super-light-orange","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":0,"y":78},
      "id":93,
      "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[
        {                     "exemplar":false,"expr":"max(pg_xact_xmax{cls=\"$cls\"})"   ,             "interval":"","legendFormat":"XMax"                           ,"refId":"A"              },{                     "exemplar":false,"expr":"pg_repl_backend_xmin{cls=\"$cls\"}","hide":false,"interval":"","legendFormat":"repl: {{ appname }}"            ,"refId":"B"              },
        { "editorMode":"code","exemplar":false,"expr":"pg_slot_catalog_xmin{cls=\"$cls\"}","hide":false,"interval":"","legendFormat":"slot: {{ ins }}.{{ slot_name }}","refId":"C","range":true }
      ],
      "title":"XMin Horizon",
      "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":0,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]},
          "unit":"none"
        },
        "overrides":[{"matcher":{"id":"byName","options":"Current"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"super-light-orange","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":12,"y":78},
      "id":95,
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[{"exemplar":false,"expr":"pg_xact_xnum{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }}","refId":"A"}],
      "title":"Xact in Progress",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":84},"id":76,"panels":[],"title":"Slot","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":30,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":2,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"always",
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]},
          "unit":"decbytes"
        },
        "overrides":[]
      },
      "gridPos":{"h":10,"w":24,"x":0,"y":85},
      "id":84,
      "options":{"legend":{"calcs":["max","last"],"displayMode":"table","placement":"right","showLegend":true,"sortBy":"Name","sortDesc":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"11.6.0",
      "targets":[{"editorMode":"code","exemplar":false,"expr":"pg_slot_retained_bytes{cls=\"$cls\"}","interval":"","legendFormat":"{{ ins }}.{{ slot_name }}","range":true,"refId":"A"}],
      "title":"Slot Retained Bytes",
      "type":"timeseries"
    },
    {
      "collapsed":true,
      "gridPos":{"h":1,"w":24,"x":0,"y":95},
      "id":78,
      "panels":[
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "description":"",
          "fieldConfig":{
            "defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"}},"links":[],"mappings":[],"max":2.5,"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]}},
            "overrides":[{"matcher":{"id":"byRegexp","options":"/.*LSN/"},"properties":[{"id":"unit","value":"hex"}]},{"matcher":{"id":"byRegexp","options":"/.*Time/"},"properties":[{"id":"unit","value":"dateTimeAsIso"}]}]
          },
          "gridPos":{"h":4,"w":24,"x":0,"y":121},
          "id":106,
          "options":{"footer":{"fields":"","reducer":["sum"],"show":false},"showHeader":true},
          "pluginVersion":"8.3.4",
          "targets":[
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_id{ins=\"$primary\"})"           ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"E" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_pid{ins=\"$primary\"})"          ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"F" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_received_lsn{ins=\"$primary\"})" ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"A" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_reported_lsn{ins=\"$primary\"})" ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"B" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_msg_send_time{ins=\"$primary\"})","format":"table","hide":true ,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"C" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_msg_recv_time{ins=\"$primary\"})","format":"table","hide":true ,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"D" },
            { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"exemplar":false,"expr":"max by (subname) (pg_sub_reported_time{ins=\"$primary\"})","format":"table","hide":true ,"instant":true,"interval":"","legendFormat":"","queryType":"measurements","refId":"G" }
          ],
          "title":"",
          "transformations":[
            { "id":"seriesToColumns","options":{"byField":"subname"}                                                                                                                                                                                                                                                                                                                                            },
            { "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},"indexByName":{},"renameByName":{"Value #A":"ReceiveLSN","Value #B":"ReportedLSN","Value #C":"MsgSendTime","Value #D":"MsgRecvTime","Value #E":"SubID","Value #F":"SubPID","Value #G":"ReportedTime","subname":"Subscription"}} }
          ],
          "type":"table"
        },
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "description":"",
          "fieldConfig":{
            "defaults":{"color":{"mode":"thresholds"},"links":[{"title":"PGSQL Replication for ${cls}","url":"/d/pgsql-replication?var-cls=${cls}&${__url_time_range}"}],"mappings":[],"max":2.5,"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"}]}},
            "overrides":[
              { "matcher":{"id":"byFrameRefID","options":"A"},"properties":[{"id":"mappings","value":[{"options":{"0":{"color":"#3e668f","index":0,"text":"No"},"1":{"color":"#346f36cc","index":1,"text":"Yes"}},"type":"value"}]}]                                                                                          },
              { "matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"mappings","value":[{"options":{"0":{"color":"#3e668f","index":0,"text":"No"},"1":{"color":"#346f36cc","index":1,"text":"Yes"}},"type":"value"}]}]                                                                                          },
              { "matcher":{"id":"byFrameRefID","options":"C"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f"},{"color":"#346f36cc","value":1}]}}]                                                                                                                                    },
              { "matcher":{"id":"byFrameRefID","options":"D"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#346f36cc"}]}},{"id":"mappings","value":[{"options":{"0":{"color":"#346f36cc","index":0,"text":"Parent"},"1":{"color":"#346f36cc","index":1,"text":"Parent"}},"type":"value"}]}] },
              { "matcher":{"id":"byFrameRefID","options":"E"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f"},{"color":"#346f36cc","value":1}]}}]                                                                                                                                    },
              { "matcher":{"id":"byFrameRefID","options":"F"},"properties":[{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#3e668f"},{"color":"#346f36cc","value":1}]}}]                                                                                                                                    }
            ]
          },
          "gridPos":{"h":7,"w":3,"x":0,"y":125},
          "id":105,
          "options":{"colorMode":"background","graphMode":"area","justifyMode":"center","orientation":"horizontal","reduceOptions":{"calcs":["last"],"fields":"","values":false},"text":{"titleSize":18},"textMode":"value_and_name"},
          "pluginVersion":"8.3.4",
          "targets":[
            { "exemplar":false,"expr":"count by (ins)(pg_pubrel_count{ins=\"$primary\"}) > bool 0 or on() vector(0)","hide":false,"instant":true,"interval":"","legendFormat":"Publication" ,"queryType":"measurements","refId":"E" },
            { "exemplar":false,"expr":"count by (ins)(pg_sub_id{ins=\"$primary\"}) or on() vector(0)"               ,"hide":false,"instant":true,"interval":"","legendFormat":"Subscription","queryType":"measurements","refId":"F" }
          ],
          "title":"",
          "type":"stat"
        },
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "fieldConfig":{
            "defaults":{
              "color":{"mode":"palette-classic"},
              "custom":{"axisLabel":"","axisPlacement":"auto","axisSoftMin":0,"barAlignment":0,"drawStyle":"line","fillOpacity":60,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"lineInterpolation":"stepBefore","lineWidth":0,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"normal"},"thresholdsStyle":{"mode":"off"}},
              "mappings":[],
              "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]}
            },
            "overrides":[]
          },
          "gridPos":{"h":7,"w":9,"x":3,"y":125},
          "id":103,
          "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi"}},
          "targets":[{"exemplar":false,"expr":"pg_pubrel_count{ins=\"$primary\"}","interval":"","legendFormat":"{{ pubname }}","refId":"A"}],
          "title":"Publication Table Count",
          "type":"timeseries"
        },
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "description":"i = init , d = data sync , r = ready",
          "fieldConfig":{
            "defaults":{
              "color":{"mode":"palette-classic"},
              "custom":{"axisLabel":"","axisPlacement":"auto","axisSoftMin":0,"barAlignment":0,"drawStyle":"line","fillOpacity":60,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"lineInterpolation":"stepBefore","lineWidth":0,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"normal"},"thresholdsStyle":{"mode":"off"}},
              "mappings":[],
              "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc"},{"color":"red","value":80}]}
            },
            "overrides":[]
          },
          "gridPos":{"h":7,"w":12,"x":12,"y":125},
          "id":102,
          "options":{"legend":{"calcs":["last"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"mode":"multi"}},
          "targets":[{"exemplar":false,"expr":"pg_subrel_count{ins=\"$primary\"}","interval":"","legendFormat":"{{ subname }}.{{ state }}","refId":"A"}],
          "title":"Subscription Table Count by State",
          "type":"timeseries"
        }
      ],
      "title":"Logical",
      "type":"row"
    }
  ],
  "preload":false,
  "refresh":"",
  "schemaVersion":41,
  "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\"}, ip)",
        "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\"}, ip)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      }
    ]
  },
  "time":{"from":"now-1h","to":"now"},
  "timepicker":{},
  "timezone":"browser",
  "title":"PGSQL Replication",
  "uid":"pgsql-replication",
  "version":1
}