{
  "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":"PGSQL Query Dashboard",
  "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":378,"panels":[],"title":"Overview : ${query}","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","value":0}]}},
        "overrides":[
          { "matcher":{"id":"byFrameRefID","options":"A"},"properties":[{"id":"links","value":[{"title":"PGSQL Instance : ${ins}","url":"/d/pgsql-instance?var-ins=${ins}&${__url_time_range}"}]}]                               },
          { "matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"links","value":[{"title":"PGSQL Databases : ${cls}","url":"/d/pgsql-databases?var-cls=${cls}&var-datname=${datname}&${__url_time_range}"}]}]      },
          { "matcher":{"id":"byFrameRefID","options":"C"},"properties":[{"id":"links","value":[{"title":"PGSQL Database : ${ins}.${datname}","url":"/d/pgsql-database?var-ins=$ins&var-datname=$datname&${__url_time_range}"}]}] },
          { "matcher":{"id":"byFrameRefID","options":"D"},"properties":[{"id":"links","value":[{"title":"PGCAT Query : ${query}","url":"/d/pgcat-query?var-dsn=${ins}.${datname}&var-query=${query}&${__url_time_range}"}]}]     }
        ]
      },
      "gridPos":{"h":5,"w":7,"x":0,"y":1},
      "id":407,
      "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.3.0",
      "targets":[
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Query","type":"string","values":["${query}"]}],"meta":{},"name":""}     ,"hide":false,"refId":"D" },
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Database","type":"string","values":["${datname}"]}],"meta":{},"name":""},"hide":false,"refId":"C" },
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Instance","type":"string","values":["$ins"]}],"meta":{},"name":""}      ,"hide":false,"refId":"A" },
        { "datasource":{"type":"marcusolsson-static-datasource","uid":"ds-static"},"frame":{"fields":[{"config":{},"name":"Cluster","type":"string","values":["${cls}"]}],"meta":{},"name":""}     ,"hide":false,"refId":"B" }
      ],
      "type":"stat"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "fieldConfig":{
        "defaults":{"custom":{"align":"center","cellOptions":{"type":"auto"},"filterable":false,"footer":{"reducers":[]},"inspect":false},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},"unit":"none"},
        "overrides":[
          {"matcher":{"id":"byName","options":"Query"},"properties":[{"id":"links","value":[{"title":"PGSQL Query : ${ins}.${datname}.${__data.fields.Query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&var-query=${__data.fields.Query}&${__url_time_range}"}]},{"id":"unit","value":"string"},{"id":"custom.minWidth","value":200}]},
          {
            "matcher":{"id":"byName","options":"RT"},
            "properties":[
              { "id":"custom.cellOptions","value":{"type":"color-text"}                                                                                                                                                                             },
              { "id":"thresholds"        ,"value":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0},{"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":"N/A"}},"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":0},{"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":0},{"color":"#346f36cc","value":2},{"color":"#EAB839","value":512},{"color":"#f79f64","value":1024},{"color":"red","value":2048},{"color":"#b783af","value":4096},{"color":"text","value":8192}]}}]
          },
          {"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}"}]},{"id":"custom.minWidth","value":150}]},
          {"matcher":{"id":"byName","options":"WAL"},"properties":[{"id":"unit","value":"bytes"},{"id":"custom.width","value":80},{"id":"mappings","value":[{"options":{"0":{"color":"#80808066","index":0,"text":"N/A"}},"type":"value"}]},{"id":"custom.cellOptions","value":{"type":"color-text"}},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#f79f64","value":0}]}}]}
        ]
      },
      "gridPos":{"h":5,"w":17,"x":7,"y":1},
      "id":377,
      "options":{"cellHeight":"sm","showHeader":true,"sortBy":[{"desc":true,"displayName":"Call"}]},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (datname, query) (pg_query_calls{ins=\"$ins\", datname=\"$datname\"}) > 0","format":"table",             "instant":true,"interval":"","legendFormat":"{{ query }}","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (query) (pg_query_exec_time{ins=\"$ins\", datname=\"$datname\"})"         ,"format":"table",             "instant":true,"interval":"","legendFormat":"{{ query }}","refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (query) (pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\"})"             ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (query) (pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\"})"       ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"D" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"max by (query) (pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\"})"         ,"format":"table","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}","refId":"E" }
      ],
      "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":true},
            "indexByName":{"Time 1":5,"Time 2":7,"Time 3":8,"Time 4":9,"Time 5":10,"Value #A":3,"Value #B":4,"Value #C":2,"Value #D":1,"Value #E":11,"datname":6,"query":0},
            "renameByName":{"Time 1":"RT (rate1m)","Value #A":"Call","Value #B":"Time","Value #C":"RT","Value #D":"QPS","Value #E":"WAL","Value #F":"Max","Value #G":"Call (rate1h)","Value #H":"Time (rate1h)","datname":"Database","ins":"","query":"Query"}
          }
        }
      ],
      "type":"table"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Queries per second according to \n`pg_stat_statements`.`calls`\nin 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":"opacity",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"short"
        },
        "overrides":[{"matcher":{"id":"byName","options":"QPS"},"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineWidth","value":1}]}]
      },
      "gridPos":{"h":7,"w":12,"x":0,"y":6},
      "id":381,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"QPS","range":true,"refId":"A"}],
      "title":"QPS (1m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average Query Latency according to `pg_stat_statements`: rate of `total_exec_time` / rate of `calls` 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":"opacity",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":true,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[{"matcher":{"id":"byName","options":"RT"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.lineWidth","value":2}]}]
      },
      "gridPos":{"h":7,"w":12,"x":12,"y":6},
      "id":382,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) /\n rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])","interval":"","intervalFactor":1,"legendFormat":"RT","range":true,"refId":"A"}],
      "title":"RT (1m)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":13},"id":291,"panels":[],"title":"Query Metrics : QPS & RT","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Queries per second according to \n`pg_stat_statements`.`calls`\nin last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"short"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#f79f64","mode":"fixed"}}]                                                                                 },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":3},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":10,"w":12,"x":0,"y":14},
      "id":353,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}"     ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"1m" ,"refId":"A"              },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,             "interval":"","intervalFactor":1,"legendFormat":"5m" ,"refId":"B"              },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])",             "interval":"","intervalFactor":1,"legendFormat":"15m","refId":"C","range":true }
      ],
      "title":"Query Calls (QPS 1m/5m/15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"coefficient of variation, CV of Query Latency in last 5 minutes",
      "fieldConfig":{
        "defaults":{
          "color":{"fixedColor":"#f79f64","mode":"fixed"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"left",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":35,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":0,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "decimals":2,
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"percentunit"
        },
        "overrides":[{"matcher":{"id":"byName","options":"RT CV"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"custom.pointSize","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":12,"y":14},
      "id":325,
      "options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"stddev_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) /\navg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])","interval":"","legendFormat":"RT CV","range":true,"refId":"A"}],
      "title":"RT Variation \u03c3/\u00b5 (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average Query Latency according to `pg_stat_statements`: rate of `total_exec_time` / rate of `calls` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":true,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                        },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#f79f64","mode":"fixed"}}]                                                                                 },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":3},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":10,"w":12,"x":12,"y":20},
      "id":355,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) /\n increase(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])"  ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) /\n increase(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"  ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) /\n increase(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"Query Latency (RT 1m/5m/15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"coefficient of variation, CV of QPS in last 5 minutes",
      "fieldConfig":{
        "defaults":{
          "color":{"fixedColor":"#346f36cc","mode":"fixed"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":false,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"left",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":33,
            "gradientMode":"none",
            "hideFrom":{"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"linear",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "decimals":2,
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"percentunit"
        },
        "overrides":[{"matcher":{"id":"byName","options":"QPS CV"},"properties":[{"id":"custom.lineWidth","value":1},{"id":"custom.pointSize","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]}]
      },
      "gridPos":{"h":6,"w":12,"x":0,"y":24},
      "id":379,
      "options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[{"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"stddev_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) /\navg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])","interval":"","legendFormat":"QPS CV","range":true,"refId":"A"}],
      "title":"QPS Variation \u03c3/\u00b5 (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"QPS distribution in last 15 minute (offset 8min)",
      "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":0,
            "pointSize":3,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"none"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"QPS"}     ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"custom.pointSize","value":2},{"id":"custom.showPoints","value":"always"},{"id":"custom.drawStyle","value":"points"},{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}}] },
          { "matcher":{"id":"byName","options":"\u00b5"}  ,"properties":[{"id":"custom.lineStyle","value":{"dash":[10,10],"fill":"dash"}},{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"text","mode":"fixed"}}]                                                              },
          { "matcher":{"id":"byName","options":"+\u03c3"} ,"properties":[{"id":"custom.fillBelowTo","value":"-\u03c3"},{"id":"custom.lineWidth","value":0},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                                                              },
          { "matcher":{"id":"byName","options":"-\u03c3"} ,"properties":[{"id":"custom.lineWidth","value":0}]                                                                                                                                                                                           },
          { "matcher":{"id":"byName","options":"+3\u03c3"},"properties":[{"id":"custom.fillBelowTo","value":"-3\u03c3"},{"id":"custom.lineWidth","value":0},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                                                             },
          { "matcher":{"id":"byName","options":"-3\u03c3"},"properties":[{"id":"custom.lineWidth","value":0}]                                                                                                                                                                                           }
        ]
      },
      "gridPos":{"h":12,"w":12,"x":0,"y":30},
      "id":285,
      "options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "exemplar":false,"expr":"avg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) + 3 * stddev_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","interval":"","legendFormat":"+3\u03c3","refId":"E" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) - 3 * stddev_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","interval":"","legendFormat":"-3\u03c3","refId":"F" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) + stddev_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"    ,"interval":"","legendFormat":"+\u03c3" ,"refId":"C" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) - stddev_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"    ,"interval":"","legendFormat":"-\u03c3" ,"refId":"D" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"                                                                                                        ,"interval":"","legendFormat":"\u00b5"  ,"refId":"B" },
        { "exemplar":false,"expr":"pg:query:call_rate1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}  OFFSET 450s"                                                                                                               ,"interval":"","legendFormat":"QPS"     ,"refId":"A" }
      ],
      "title":"QPS Distribution (15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average Response time distribution in last 15 minute (offset 8min)",
      "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":0,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"RT"}      ,"properties":[{"id":"custom.showPoints","value":"always"},{"id":"custom.drawStyle","value":"points"},{"id":"custom.pointSize","value":2},{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}}] },
          { "matcher":{"id":"byName","options":"\u00b5"}  ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"custom.lineStyle","value":{"dash":[10,10],"fill":"dash"}},{"id":"color","value":{"fixedColor":"text","mode":"fixed"}}]                          },
          { "matcher":{"id":"byName","options":"+\u03c3"} ,"properties":[{"id":"custom.fillBelowTo","value":"-\u03c3"},{"id":"custom.lineWidth","value":0},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                        },
          { "matcher":{"id":"byName","options":"-\u03c3"} ,"properties":[{"id":"custom.lineWidth","value":0}]                                                                                                                                                       },
          { "matcher":{"id":"byName","options":"+3\u03c3"},"properties":[{"id":"custom.fillBelowTo","value":"-3\u03c3"},{"id":"custom.lineWidth","value":0},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                       },
          { "matcher":{"id":"byName","options":"-3\u03c3"},"properties":[{"id":"custom.lineWidth","value":0}]                                                                                                                                                       }
        ]
      },
      "gridPos":{"h":12,"w":12,"x":12,"y":30},
      "id":326,
      "options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":false},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "exemplar":false,"expr":"avg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) - 3 * stddev_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","interval":"","legendFormat":"-3\u03c3","refId":"F" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) + 3 * stddev_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","interval":"","legendFormat":"+3\u03c3","refId":"E" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) + stddev_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"    ,"interval":"","legendFormat":"+\u03c3" ,"refId":"C" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) - stddev_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"    ,"interval":"","legendFormat":"-\u03c3" ,"refId":"D" },
        { "exemplar":false,"expr":"avg_over_time(pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])"                                                                                                  ,"interval":"","legendFormat":"\u00b5"  ,"refId":"B" },
        { "exemplar":false,"expr":"pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}  OFFSET 450s"                                                                                                         ,"interval":"","legendFormat":"RT"      ,"refId":"A" }
      ],
      "title":"RT Distribution (15m)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":42},"id":384,"panels":[],"title":"Query Metrics / Call","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average number of rows returned by this query. Rate of `pg_stat_statements`: `rows` / `call` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"none"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":43},
      "id":387,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])"  ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"  ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"Rows Returned per Query (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average execution time of this query. Rate of `pg_stat_statements`: `total_exec_time`/`call` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":43},
      "id":389,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])"  ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"  ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"Execution Time per Query (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average number of WAL Bytes generated by this query. Rate of `pg_stat_statements`.`wal_bytes` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"Bps"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":52},
      "id":394,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) /\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])" ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])/\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"  ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])/\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"WAL Bytes per Query (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Avery seconds of IO(blocks read+write) time spent by this query. Rate of `pg_stat_statements`: `blk_read_time` + `blk_write_time` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":1}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":52},
      "id":392,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])"  ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"  ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m]) / \nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"I/O Time per Query (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average number of bytes (blocks multiply default 8K page size) read/written from/to (disk/fs cache) by this query\n\n`pg_stat_statements`: `shared_blks_read` , `shared_blks_written` , write is plot with negative Y axis",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"palette-classic"},
          "custom":{
            "axisBorderShow":false,
            "axisCenteredZero":true,
            "axisColorMode":"text",
            "axisLabel":"",
            "axisPlacement":"auto",
            "barAlignment":0,
            "barWidthFactor":0.6,
            "drawStyle":"line",
            "fillOpacity":30,
            "gradientMode":"opacity",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"binBps"
        },
        "overrides":[{"matcher":{"id":"byName","options":"read"},"properties":[{"id":"color","value":{"fixedColor":"#f79f64","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":1}]},{"matcher":{"id":"byName","options":"write"},"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]}]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":61},
      "id":398,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_sblk_read{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192\n/\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"    ,             "interval":"","intervalFactor":1,"legendFormat":"read" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"- rate(pg_query_sblk_written{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192 /\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"write","range":true,"refId":"B" }
      ],
      "title":"Shared Blocks Read/Write per Query (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Average number of bytes (blocks multiply default 8K page size) hit/dirtied from/to (disk/fs cache) by this query\n\n`pg_stat_statements`: `shared_blks_hit` , `shared_blks_dirtied` , dirty is plot with negative Y axis",
      "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":"opacity",
            "hideFrom":{"graph":false,"legend":false,"tooltip":false,"viz":false},
            "insertNulls":false,
            "lineInterpolation":"smooth",
            "lineWidth":1,
            "pointSize":5,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"never",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"binBps"
        },
        "overrides":[{"matcher":{"id":"byName","options":"hit"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.fillOpacity","value":30},{"id":"custom.lineWidth","value":1}]},{"matcher":{"id":"byName","options":"dirty"},"properties":[{"id":"color","value":{"fixedColor":"#cc4637d9","mode":"fixed"}}]}]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":61},
      "id":400,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_sblk_hit{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192\n/\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])"     ,             "interval":"","intervalFactor":1,"legendFormat":"hit"  ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"- rate(pg_query_sblk_dirtied{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192 /\nrate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"dirty","range":true,"refId":"B" }
      ],
      "title":"Shared Blocks Hit/Dirtied per Query (5m)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":70},"id":380,"panels":[],"title":"Query Metrics / Time","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Number of rows returned by this query per second. Rate of `pg_stat_statements`.`rows` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"none"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":71},
      "id":334,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])" ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,             "refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},                    "exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m",             "refId":"C" }
      ],
      "title":"Rows Returned per Second (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Seconds of exec time spent by this query per second. Rate of `pg_stat_statements`.`total_exec_time` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":0}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":71},
      "id":388,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])" ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"Execution Time per Second (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Number of WAL Bytes generated by this query per second. Rate of `pg_stat_statements`.`wal_bytes` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"Bps"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":1}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":80},
      "id":393,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])" ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"WAL Bytes per Second (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Seconds of IO(blocks read+write) time spent by this query per second. Rate of `pg_stat_statements`: `blk_read_time` + `blk_write_time` in last 1m, 5m, 15m",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"15m"},"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]                                          },
          { "matcher":{"id":"byName","options":"5m"} ,"properties":[{"id":"custom.lineWidth","value":1},{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}}]                                                                               },
          { "matcher":{"id":"byName","options":"1m"} ,"properties":[{"id":"color","value":{"fixedColor":"#5b9cd5","mode":"fixed"}},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":2},{"id":"custom.lineWidth","value":1}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":80},
      "id":390,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1m])" ,             "interval":"","intervalFactor":1,"legendFormat":"1m" ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,"hide":false,"interval":"","intervalFactor":1,"legendFormat":"5m" ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_io_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[15m])","hide":false,"interval":"","intervalFactor":1,"legendFormat":"15m","range":true,"refId":"C" }
      ],
      "title":"I/O Time per Second (1m, 5m, 15m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Number of bytes (blocks multiply default 8K page size) dirtied / written by this query per second.\n\n`pg_stat_statements`: `shared_blks_dirtied` , `shared_blks_written` \n\nDirtied >= Write because a block may by updated multiple time before written to disk.",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"binBps"
        },
        "overrides":[{"matcher":{"id":"byName","options":"dirty"},"properties":[{"id":"color","value":{"fixedColor":"#f79f64","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.fillBelowTo","value":"write"},{"id":"custom.lineWidth","value":1}]},{"matcher":{"id":"byName","options":"write"},"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}}]}]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":89},
      "id":396,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_sblk_dirtied{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192",             "interval":"","intervalFactor":1,"legendFormat":"dirty","range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_sblk_written{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192","hide":false,"interval":"","intervalFactor":1,"legendFormat":"write","range":true,"refId":"B" }
      ],
      "title":"Shared Blocks Dirtied/Write per Second (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Number of bytes (blocks multiply default 8K page size) read / hit by this query per second.\n\n`pg_stat_statements`: `shared_blks_read`, `shared_blks_hit` and `hit` / `(read+hit)`\n\nUsually, Hit >> Read, which means hit ratio ~ 1.0",
      "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",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"binBps"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"read"}     ,"properties":[{"id":"color","value":{"fixedColor":"#f79f64","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":1},{"id":"unit","value":"binBps"}]                                                                                      },
          { "matcher":{"id":"byName","options":"hit ratio"},"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"unit","value":"percentunit"},{"id":"custom.axisSoftMax","value":1},{"id":"custom.fillOpacity","value":15},{"id":"custom.showPoints","value":"auto"},{"id":"custom.pointSize","value":2}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":89},
      "id":397,
      "options":{"legend":{"calcs":["mean","min","max","last"],"displayMode":"table","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        {"datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_sblk_read{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192","interval":"","intervalFactor":1,"legendFormat":"read","range":true,"refId":"A"},
        {
          "datasource":{"type":"prometheus","uid":"ds-prometheus"},
          "editorMode":"code",
          "exemplar":false,
          "expr":"rate(pg_query_sblk_hit{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) / \n(rate(pg_query_sblk_hit{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) + rate(pg_query_sblk_read{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m]) * 8192)",
          "hide":false,
          "interval":"",
          "intervalFactor":1,
          "legendFormat":"hit ratio",
          "range":true,
          "refId":"B"
        }
      ],
      "title":"Shared Blocks Read per Second (5m) & Blocks Hit Ratio",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":98},"id":375,"panels":[],"title":"Query Metrics / Total %","type":"row"},
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Query QPS of this database ${datname} on ${ins} in last 5 minutes.\n\nrate 5m of `pg_stat_statements`.`calls`\nClick datapoint to check a specific query.",
      "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":0,
            "pointSize":4,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"ops"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"Postgres TPS"}                  ,"properties":[{"id":"custom.fillOpacity","value":0},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                                 },
          { "matcher":{"id":"byName","options":"Pgbouncer QPS"}                 ,"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"mode":"palette-classic"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                   },
          { "matcher":{"id":"byFrameRefID","options":"C"}                       ,"properties":[{"id":"color","value":{"fixedColor":"#24292ee6","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"custom.pointSize","value":4},{"id":"custom.stacking","value":{"group":"A","mode":"normal"}}] },
          { "matcher":{"id":"byRegexp","options":"/Pgbouncer QPS|Postgres TPS/"},"properties":[{"id":"custom.hideFrom","value":{"legend":false,"tooltip":true,"viz":true}}]                                                                                                                                                                                                              }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":99},
      "id":369,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=369"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pgbouncer_stat_total_query_count{ins=\"$ins\", datname=\"$datname\"}[5m])" ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Pgbouncer QPS"          ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_xact_commit{ins=\"$ins\", datname=\"$datname\"}[5m])"                ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Postgres TPS"           ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,             "interval":"","intervalFactor":2,"legendFormat":"This Query \u2b50\ufe0f","range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_calls{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ query }}"            ,"range":true,"refId":"D" }
      ],
      "title":"Query QPS (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Query RT of this database ${datname} on ${ins}.\n\nrate 1m of `total_exec_time` / `calls`\n\nClick datapoint to check a specific query.",
      "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":4,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"none"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"Postgres RT"} ,"properties":[{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineWidth","value":2},{"id":"custom.fillOpacity","value":2}]                                                                                    },
          { "matcher":{"id":"byName","options":"Pgbouncer RT"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.lineWidth","value":2},{"id":"custom.fillOpacity","value":2}]                                                                                  },
          { "matcher":{"id":"byFrameRefID","options":"C"}     ,"properties":[{"id":"custom.lineWidth","value":2},{"id":"custom.showPoints","value":"always"},{"id":"custom.pointSize","value":5},{"id":"color","value":{"fixedColor":"#24292ee6","mode":"fixed"}},{"id":"custom.fillOpacity","value":20}] }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":99},
      "id":371,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=371"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pgbouncer_stat_total_query_time{ins=\"$ins\", datname=\"$datname\"}[5m]) /\nrate(pgbouncer_stat_total_query_count{ins=\"$ins\", datname=\"$datname\"}[5m])","hide":false,"interval":"","intervalFactor":2,"legendFormat":"Pgbouncer RT"           ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_active_time{ins=\"$ins\", datname=\"$datname\"}[5m]) /\nrate(pg_db_xact_commit{ins=\"$ins\", datname=\"$datname\"}[5m])"                             ,             "interval":"","intervalFactor":2,"legendFormat":"Postgres RT"            ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"pg:query:rt_1m{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}"                                                                                           ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"This Query \u2b50\ufe0f","range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"pg:query:rt_1m{ins=\"$ins\",datname=\"$datname\", query!=\"$query\"}"                                                                                           ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ query }}"            ,"range":true,"refId":"D" }
      ],
      "title":"Query RT (1m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Size by exec time spent in last hour, Colored by RT in last hour",
      "fieldConfig":{
        "defaults":{
          "color":{"mode":"thresholds"},
          "links":[{"title":"PGSQL Query : ${__data.fields.query}","url":"/d/pgsql-query?var-ins=${ins}&var-datname=${datname}&var-query=${__data.fields.query}&${__url_time_range}"},{"title":"PGCAT Query : ${__data.fields.query}","url":"/d/pgcat-query?var-dsn=${ins}.${datname}&var-query=${__data.fields.Query}&${__url_time_range}"}],
          "mappings":[],
          "thresholds":{"mode":"absolute","steps":[{"color":"super-light-blue","value":0},{"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":60},{"color":"text","value":600}]},
          "unit":"locale"
        },
        "overrides":[{"matcher":{"id":"byName","options":"RT"},"properties":[{"id":"unit","value":"s"},{"id":"mappings","value":[{"options":{"match":"null+nan","result":{"color":"#808080","index":1,"text":"N/A"}},"type":"special"}]}]},{"matcher":{"id":"byName","options":"Query"},"properties":[{"id":"unit","value":"string"}]},{"matcher":{"id":"byName","options":"Time"},"properties":[{"id":"unit","value":"s"}]}]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":108},
      "id":402,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=402"}],
      "options":{"colorByField":"Value #B","colorField":"rt","labelFields":["Value #A","Value #B"],"sizeField":"Value #A","textField":"query","tiling":"treemapSquarify"},
      "pluginVersion":"2.1.1",
      "targets":[
        {
          "datasource":{"type":"postgres","uid":"cc8a3615-9c82-44d7-be42-07d8aa1cac68"},
          "editorMode":"code",
          "expr":"sum by (query) (increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\"}[1h]))",
          "format":"table",
          "group":[],
          "hide":false,
          "legendFormat":"__auto",
          "metricColumn":"none",
          "range":true,
          "rawQuery":true,
          "rawSql":"SELECT queryid::TEXT AS qid, d.datname, r.rolname, s.rows AS value, s.mean_exec_time AS rt\nFROM pg_stat_statements s\n         LEFT JOIN pg_database d ON s.dbid = d.oid\n         LEFT JOIN pg_roles r ON s.userid = r.oid\nWHERE datname='$datname' AND rows > 0\nORDER BY calls DESC\nLIMIT 100;",
          "refId":"A",
          "select":[[{"params":["video_duration"],"type":"column"}]],
          "sql":{"columns":[{"parameters":[],"type":"function"}],"groupBy":[{"property":{"type":"string"},"type":"groupBy"}],"limit":50},
          "table":"predefined_message_translations1",
          "timeColumn":"created_time",
          "timeColumnType":"timestamp",
          "where":[{"name":"$__timeFilter","params":[],"type":"macro"}]
        },{
          "datasource":{"type":"postgres","uid":"cc8a3615-9c82-44d7-be42-07d8aa1cac68"},
          "editorMode":"code",
          "expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\"}[1h]) / increase(pg_query_calls{ins=\"$ins\", datname=\"$datname\"}[1h])",
          "format":"table",
          "group":[],
          "hide":false,
          "legendFormat":"__auto",
          "metricColumn":"none",
          "range":true,
          "rawQuery":true,
          "rawSql":"SELECT queryid::TEXT AS qid, d.datname, r.rolname, s.rows AS value, s.mean_exec_time AS rt\nFROM pg_stat_statements s\n         LEFT JOIN pg_database d ON s.dbid = d.oid\n         LEFT JOIN pg_roles r ON s.userid = r.oid\nWHERE datname='$datname' AND rows > 0\nORDER BY calls DESC\nLIMIT 100;",
          "refId":"B",
          "select":[[{"params":["video_duration"],"type":"column"}]],
          "sql":{"columns":[{"parameters":[],"type":"function"}],"groupBy":[{"property":{"type":"string"},"type":"groupBy"}],"limit":50},
          "table":"predefined_message_translations1",
          "timeColumn":"created_time",
          "timeColumnType":"timestamp",
          "where":[{"name":"$__timeFilter","params":[],"type":"macro"}]
        }
      ],
      "title":"Exec Time / RT Matrix (1h)",
      "transformations":[{"id":"joinByField","options":{"byField":"query","mode":"outer"}},{"id":"organize","options":{"excludeByName":{"Time 1":true,"Time 2":true},"indexByName":{"Time 1":3,"Time 2":4,"Value #A":1,"Value #B":2,"query":0},"renameByName":{"Value #A":"Time","Value #B":"RT","query":"Query"}}}],
      "type":"marcusolsson-treemap-panel"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Numbers of rows returned of each query in this database ${datname} on ${ins} in last 5 minutes.\n\nrate 5m of `pg_stat_statements`.`calls`\nClick datapoint to check a specific query.",
      "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":0,
            "pointSize":4,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"rowsps"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"Postgres RPS"}    ,"properties":[{"id":"custom.fillOpacity","value":0},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                                 },
          { "matcher":{"id":"byFrameRefID","options":"C"}         ,"properties":[{"id":"color","value":{"fixedColor":"#24292ee6","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"custom.pointSize","value":4},{"id":"custom.stacking","value":{"group":"A","mode":"normal"}}] },
          { "matcher":{"id":"byRegexp","options":"/Postgres RPS/"},"properties":[{"id":"custom.hideFrom","value":{"legend":false,"tooltip":true,"viz":true}}]                                                                                                                                                                                                              }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":108},
      "id":404,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=404"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_tup_returned{ins=\"$ins\", datname=\"$datname\"}[5m])"              ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Postgres RPS"           ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,             "interval":"","intervalFactor":2,"legendFormat":"This Query \u2b50\ufe0f","range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_rows{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ query }}"            ,"range":true,"refId":"D" }
      ],
      "title":"Rows Returned (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Time spent on executing statements during last 1 hour.\n\nincrease1h of `pg_stat_statements`.`total_exec_time`",
      "fieldConfig":{
        "defaults":{"color":{"mode":"palette-classic"},"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false}},"links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],"mappings":[],"unit":"s"},
        "overrides":[{"matcher":{"id":"byFrameRefID","options":"A"},"properties":[{"id":"color","value":{"fixedColor":"#24292ecc","mode":"fixed"}}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"mode":"palette-classic"}}]}]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":117},
      "id":362,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=362"}],
      "options":{"legend":{"displayMode":"table","placement":"right","showLegend":true,"sortBy":"Percent","sortDesc":true,"values":["percent","value"]},"pieType":"pie","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"sort":"desc","tooltip":{"hideZeros":false,"mode":"single","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1h])" ,"hide":false,"instant":true,"interval":"","legendFormat":"\u2b50\ufe0f{{ query }}","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"increase(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[1h])","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}"            ,"refId":"B" }
      ],
      "title":"Exec Time Spent (1h)",
      "type":"piechart"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Exec Time Spent of this database ${datname} on ${ins}.\n\nrate 5m of `pg_stat_statements`.`calls`\nClick datapoint to check a specific query.",
      "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":0,
            "pointSize":4,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"s"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"Postgres Time"} ,"properties":[{"id":"custom.fillOpacity","value":20},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                                },
          { "matcher":{"id":"byName","options":"Pgbouncer Time"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"mode":"palette-classic"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                   },
          { "matcher":{"id":"byFrameRefID","options":"C"}       ,"properties":[{"id":"color","value":{"fixedColor":"#24292ee6","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"custom.pointSize","value":4},{"id":"custom.stacking","value":{"group":"A","mode":"normal"}}] },
          { "matcher":{"id":"byRegexp","options":"/.*Time/"}    ,"properties":[{"id":"custom.hideFrom","value":{"legend":false,"tooltip":true,"viz":true}}]                                                                                                                                                                                                              }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":117},
      "id":403,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=403"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pgbouncer_stat_total_query_time{ins=\"$ins\", datname=\"$datname\"}[5m])"      ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Pgbouncer Time"         ,"range":true,"refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_db_active_time{ins=\"$ins\", datname=\"$datname\"}[5m])"                    ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Postgres Time"          ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,             "interval":"","intervalFactor":2,"legendFormat":"This Query \u2b50\ufe0f","range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_exec_time{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ query }}"            ,"range":true,"refId":"D" }
      ],
      "title":"Exec Time Spent (5m)",
      "type":"timeseries"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Shared blocks access & read size in bytes, in last 1 hour of each query.\n\n`pg_stat_statements`: `share_blks_read` + `shared_blks_hit`",
      "fieldConfig":{
        "defaults":{"color":{"mode":"palette-classic"},"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false}},"links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],"mappings":[],"unit":"bytes"},
        "overrides":[{"matcher":{"id":"byFrameRefID","options":"A"},"properties":[{"id":"color","value":{"fixedColor":"#24292ecc","mode":"fixed"}}]},{"matcher":{"id":"byFrameRefID","options":"B"},"properties":[{"id":"color","value":{"mode":"palette-classic"}}]}]
      },
      "gridPos":{"h":9,"w":12,"x":0,"y":126},
      "id":401,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=401"}],
      "options":{"legend":{"displayMode":"table","placement":"right","showLegend":true,"values":["percent","value"]},"pieType":"pie","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"sort":"desc","tooltip":{"hideZeros":false,"mode":"single","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"(increase(pg_query_sblk_read{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1h]) +\nincrease(pg_query_sblk_hit{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[1h])) * 8192"  ,"hide":false,"instant":true,"interval":"","legendFormat":"\u2b50\ufe0f{{ query }}","refId":"A" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"(increase(pg_query_sblk_read{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[1h]) +\nincrease(pg_query_sblk_hit{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[1h])) * 8192","hide":false,"instant":true,"interval":"","legendFormat":"{{ query }}"            ,"refId":"B" }
      ],
      "title":"Blocks Access (1h)",
      "type":"piechart"
    },
    {
      "datasource":{"type":"prometheus","uid":"ds-prometheus"},
      "description":"Numbers of wal bytes generated of each query in this database ${datname} on ${ins} in last 5 minutes.\n\nrate 5m of `pg_stat_statements`.`wal_bytes`\n\nClick the data-point to check a specific query.",
      "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":0,
            "pointSize":4,
            "scaleDistribution":{"type":"linear"},
            "showPoints":"auto",
            "showValues":false,
            "spanNulls":false,
            "stacking":{"group":"A","mode":"normal"},
            "thresholdsStyle":{"mode":"off"}
          },
          "links":[{"title":"PGSQL Query ${__field.labels.query}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${__field.labels.datname}&var-query=${__field.labels.query}&${__url_time_range}"}],
          "mappings":[],
          "min":0,
          "thresholds":{"mode":"absolute","steps":[{"color":"#346f36cc","value":0}]},
          "unit":"binBps"
        },
        "overrides":[
          { "matcher":{"id":"byName","options":"Postgres LSN"} ,"properties":[{"id":"custom.fillOpacity","value":0},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"fixedColor":"#3e668f","mode":"fixed"}},{"id":"custom.lineStyle","value":{"fill":"solid"}},{"id":"custom.hideFrom","value":{"legend":false,"tooltip":true,"viz":true}}] },
          { "matcher":{"id":"byName","options":"Pgbouncer QPS"},"properties":[{"id":"color","value":{"fixedColor":"#346f36cc","mode":"fixed"}},{"id":"custom.stacking","value":{"group":"A","mode":"none"}},{"id":"custom.lineWidth","value":2},{"id":"color","value":{"mode":"palette-classic"}},{"id":"custom.lineStyle","value":{"fill":"solid"}}]                                                               },
          { "matcher":{"id":"byFrameRefID","options":"C"}      ,"properties":[{"id":"color","value":{"fixedColor":"#24292ee6","mode":"fixed"}},{"id":"custom.fillOpacity","value":80},{"id":"custom.lineWidth","value":2},{"id":"custom.showPoints","value":"auto"},{"id":"custom.pointSize","value":4},{"id":"custom.stacking","value":{"group":"A","mode":"normal"}}]                                             }
        ]
      },
      "gridPos":{"h":9,"w":12,"x":12,"y":126},
      "id":406,
      "links":[{"title":"PGSQL Query : ${ins}.${datname}","url":"/d/pgsql-query?var-ins=${ins}&var-cls=${cls}&var-datname=${datname}&${__url_time_range}&viewPanel=406"}],
      "options":{"legend":{"calcs":["max"],"displayMode":"table","placement":"right","showLegend":true},"tooltip":{"hideZeros":false,"mode":"multi","sort":"none"}},
      "pluginVersion":"12.3.0",
      "targets":[
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_lsn{ins=\"$ins\"}[5m])"                                                     ,"hide":false,"interval":"","intervalFactor":2,"legendFormat":"Postgres LSN"           ,"range":true,"refId":"B" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query=\"$query\"}[5m])" ,             "interval":"","intervalFactor":2,"legendFormat":"This Query \u2b50\ufe0f","range":true,"refId":"C" },
        { "datasource":{"type":"prometheus","uid":"ds-prometheus"},"editorMode":"code","exemplar":false,"expr":"rate(pg_query_wal_bytes{ins=\"$ins\", datname=\"$datname\", query!=\"$query\"}[5m])","hide":false,"interval":"","intervalFactor":2,"legendFormat":"{{ query }}"            ,"range":true,"refId":"D" }
      ],
      "title":"WAL Bytes (5m)",
      "type":"timeseries"
    },
    {"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":135},"id":408,"panels":[],"title":"Query Logs","type":"row"},
    {
      "datasource":{"type":"victoriametrics-logs-datasource","uid":"ds-vlogs"},
      "description":"",
      "gridPos":{"h":13,"w":24,"x":0,"y":136},
      "id":409,
      "options":{"dedupStrategy":"none","detailsMode":"sidebar","enableInfiniteScrolling":true,"enableLogDetails":true,"fontSize":"small","prettifyLogMessage":false,"showCommonLabels":false,"showControls":true,"showLabels":true,"showTime":true,"sortOrder":"Descending","syntaxHighlighting":true,"wrapLogMessage":false},
      "pluginVersion":"12.3.0",
      "targets":[{"datasource":{"type":"victoriametrics-logs-datasource","uid":"ds-vlogs"},"editorMode":"code","expr":"ip:$ip job:postgres query:\"${query}\"","instant":false,"queryType":"instant","range":true,"refId":"A"}],
      "type":"logs"
    }
  ],
  "preload":false,
  "refresh":"",
  "schemaVersion":42,
  "tags":["Pigsty","PGSQL","Database","Query"],
  "templating":{
    "list":[
      {"current":{},"datasource":{"type":"prometheus","uid":"ds-prometheus"},"definition":"label_values(pg_up{}, ins)","description":"Unique instance identifier (e.g pg-meta-1)","includeAll":false,"label":"Instance","name":"ins","options":[],"query":{"query":"label_values(pg_up{}, ins)","refId":"StandardVariableQuery"},"refresh":2,"regex":"","sort":1,"type":"query"},
      {"current":{},"datasource":{"type":"prometheus","uid":"ds-prometheus"},"definition":"label_values(pg_db_age{ins=\"$ins\"}, datname)","description":"Database name","includeAll":false,"label":"Database","name":"datname","options":[],"query":{"query":"label_values(pg_db_age{ins=\"$ins\"}, datname)","refId":"StandardVariableQuery"},"refresh":2,"regex":"","sort":1,"type":"query"},
      {
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_query_calls{ins=\"$ins\", datname=\"$datname\"}, query)",
        "description":"Query Identifier",
        "includeAll":false,
        "label":"Query",
        "name":"query",
        "options":[],
        "query":{"query":"label_values(pg_query_calls{ins=\"$ins\", datname=\"$datname\"}, query)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_up{ins=\"$ins\"} , instance)",
        "description":"IP address of this postgres instance",
        "hide":2,
        "includeAll":false,
        "label":"IP",
        "name":"ip",
        "options":[],
        "query":{"query":"label_values(pg_up{ins=\"$ins\"} , instance)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"/([0-9\\.]+)\\:\\d+/",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_up{ins=\"$ins\"},  ins)",
        "description":"Sequence number of this instance, which is an unique integer among a postgres cluster",
        "hide":2,
        "includeAll":false,
        "label":"Sequence",
        "name":"seq",
        "options":[],
        "query":{"query":"label_values(pg_up{ins=\"$ins\"},  ins)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"/^[a-zA-Z0-9-_]+-(\\d+)$/",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(pg_up{ins=\"$ins\"}, cls)",
        "description":"Cluster identifier for this postgres instance, cls should be unique among entire environment. such as pg-meta, pg-test",
        "hide":2,
        "includeAll":false,
        "label":"Cluster",
        "name":"cls",
        "options":[],
        "query":{"query":"label_values(pg_up{ins=\"$ins\"}, cls)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      },{
        "current":{},
        "datasource":{"type":"prometheus","uid":"ds-prometheus"},
        "definition":"label_values(node_uname_info{ins=\"$ins\"}, nodename)",
        "description":"Node name of current postgres instance",
        "hide":2,
        "includeAll":false,
        "label":"Node",
        "name":"node",
        "options":[],
        "query":{"query":"label_values(node_uname_info{ins=\"$ins\"}, nodename)","refId":"StandardVariableQuery"},
        "refresh":2,
        "regex":"",
        "sort":1,
        "type":"query"
      }
    ]
  },
  "time":{"from":"now-1h","to":"now"},
  "timepicker":{"refresh_intervals":["1s","2s","3s","5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"]},
  "timezone":"browser",
  "title":"PGSQL Query",
  "uid":"pgsql-query",
  "version":1,
  "weekStart":""
}