Grafana dashboard: PostgreSQL Infrastructure
Description: A basic dashboard for monitoring PostgreSQL database clusters using collectd v5+, TimescaleDB/PostgreSQL v10+ and Grafana v6+

This dashboard is meant to help visualize PostgreSQL database KPIs, and scale easily with the addition of multiple DB hosts and PostgreSQL databases.  This dashboard uses TimescaleDB features for querying and displaying data.

{
  "__inputs": [
    {
      "name": "DS_COLLECTD",
      "label": "collectd",
      "description": "Created for use with TimescaleDB/PostgreSQL",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.0.2"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": "5.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": "5.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 9948,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1553059530274,
  "links": [],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 8,
      "panels": [],
      "title": "System Stats",
      "type": "row"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 2,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": true,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  type_inst AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'cpu' AND\n  type = 'percent' AND\n  type_inst != 'idle'\nGROUP BY 1, type_inst,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'cpu'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'percent'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "!=",
                "'idle'"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  type_inst AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'cpu' AND\n  type = 'percent' AND\n  type_inst != 'idle' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1, type_inst,2\nORDER BY 1,2",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'cpu'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'percent'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "!=",
                "'idle'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CPU activity (%)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "percent",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 3,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": false,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "name",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  name AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'load' AND\n  value = value AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'load'"
              ],
              "type": "expression"
            },
            {
              "name": "",
              "params": [
                "value",
                "=",
                "value"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "System Load",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 2,
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 10
      },
      "id": 4,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": false,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "plugin_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "type"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "'TX: ' || plugin_inst ",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  'TX: ' || plugin_inst  AS metric,\n  (CASE WHEN avg(value) >= lag(avg(value)) OVER (PARTITION BY 'TX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) THEN avg(value) - lag(avg(value)) OVER (PARTITION BY 'TX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) WHEN lag(avg(value)) OVER (PARTITION BY 'TX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) IS NULL THEN NULL ELSE avg(value) END)/extract(epoch from min(tstamp) - lag(min(tstamp)) OVER (PARTITION BY 'TX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval))) AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'interface' AND\n  type = 'if_octets' AND\n  name = '''tx''' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1, plugin_inst, type,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "rate"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'interface'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'if_octets'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'''tx'''"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "plugin_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "type"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "'RX: ' || plugin_inst ",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  'RX: ' || plugin_inst  AS metric,\n  (CASE WHEN avg(value) >= lag(avg(value)) OVER (PARTITION BY 'RX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) THEN avg(value) - lag(avg(value)) OVER (PARTITION BY 'RX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) WHEN lag(avg(value)) OVER (PARTITION BY 'RX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) IS NULL THEN NULL ELSE avg(value) END)/extract(epoch from min(tstamp) - lag(min(tstamp)) OVER (PARTITION BY 'RX: ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval))) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin = 'interface' AND\n  type = 'if_octets' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo() AND\n  tstamp < $__timeTo()\nGROUP BY 1, plugin_inst, type,2\nORDER BY 1,2",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "rate"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'interface'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'if_octets'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Network Activity",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 10
      },
      "id": 5,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": false,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "plugin_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "type"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "'read - ' || plugin_inst ",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  'read - ' || plugin_inst  AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY 'read - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY 'read - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) WHEN lag(last(value,tstamp)) OVER (PARTITION BY 'read - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) IS NULL THEN NULL ELSE last(value,tstamp) END) / 60 AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'disk' AND\n  type = 'disk_octets' AND\n  name = '''read''' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1, plugin_inst, type,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'disk'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'disk_octets'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'''read'''"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "plugin_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "type"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "'write - ' || plugin_inst ",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  'write - ' || plugin_inst  AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY 'write - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY 'write - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) WHEN lag(last(value,tstamp)) OVER (PARTITION BY 'write - ' || plugin_inst  ORDER BY $__timeGroup(tstamp,$__interval)) IS NULL THEN NULL ELSE last(value,tstamp) END) / 60 AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'disk' AND\n  type = 'disk_octets' AND\n  name = '''write''' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1, plugin_inst, type,2\nORDER BY 1,2",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'disk'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'disk_octets'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "name",
                "=",
                "'''write'''"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Disk I/O",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "columns": [],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 6,
        "x": 0,
        "y": 19
      },
      "id": 21,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (REPLACE('/' || plugin_inst,'-', '/'))\n REPLACE('/' || plugin_inst,'-', '/') as mountpoint, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'df_complex' AND \n  type_inst = 'used' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Disk Space: Used",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 6,
        "x": 6,
        "y": 19
      },
      "id": 24,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "percent"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (REPLACE('/' || plugin_inst,'-', '/'))\n REPLACE('/' || plugin_inst,'-', '/') as mountpoint, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'percent_bytes' AND \n  type_inst = 'used' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Disk Space: Used %",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 6,
        "x": 12,
        "y": 19
      },
      "id": 23,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (REPLACE('/' || plugin_inst,'-', '/'))\n REPLACE('/' || plugin_inst,'-', '/') as mountpoint, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'df_complex' AND \n  type_inst = 'free' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Disk Space: Free",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [
        {
          "text": "Current",
          "value": "current"
        }
      ],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 6,
        "x": 18,
        "y": 19
      },
      "id": 22,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": true,
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (REPLACE('/' || plugin_inst,'-', '/'))\n REPLACE('/' || plugin_inst,'-', '/') as mountpoint, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'percent_bytes' AND \n  type_inst = 'used' AND \n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,24h),\n  REPLACE('/' || plugin_inst,'-', '/') AS metric,\n  (CASE WHEN avg(value) >= lag(avg(value)) OVER (PARTITION BY REPLACE('/' || plugin_inst,'-', '/') ORDER BY $__timeGroup(tstamp,24h)) THEN avg(value) - lag(avg(value)) OVER (PARTITION BY REPLACE('/' || plugin_inst,'-', '/') ORDER BY $__timeGroup(tstamp,24h)) WHEN lag(avg(value)) OVER (PARTITION BY REPLACE('/' || plugin_inst,'-', '/') ORDER BY $__timeGroup(tstamp,24h)) IS NULL THEN NULL ELSE avg(value) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo() AND\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'df_complex' AND\n  type_inst = 'used' AND\n  value IS NOT NULL\nGROUP BY 1, REPLACE('/' || plugin_inst,'-', '/'),2\nORDER BY 1,2",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": "24h",
      "title": "Disk Space: % Change over 24h",
      "transform": "timeseries_aggregations",
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 25
      },
      "id": 6,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": false,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            },
            {
              "params": [
                "plugin_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "type"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  type_inst AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin = 'memory' AND\n  type = 'memory' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1, plugin_inst, type,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamptz",
          "where": [
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'memory'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'memory'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Memory Utilization",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": 0,
          "format": "decbytes",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 31
      },
      "id": 10,
      "panels": [],
      "title": "PostgreSQL Stats",
      "type": "row"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 32
      },
      "id": 12,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  avg(value) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  type = 'pg_numbackends_n' AND\n  plugin = 'postgresql' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "avg"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_numbackends_n'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Database Connections",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 32
      },
      "id": 13,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END)/extract(epoch from min(tstamp) - lag(min(tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp)) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_xact' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "rate"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_xact'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "identifier"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": true,
          "metricColumn": "plugin_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  plugin_inst AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin = 'df' AND\n  type = 'df_complex' AND\n  type_inst = value\nGROUP BY type_inst, tstamp, identifier,2\nORDER BY 1,2",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'df'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'df_complex'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "value"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Commit/Rollback",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": -1,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_COLLECTD}",
      "format": "decbytes",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 0,
        "y": 41
      },
      "id": 15,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "type",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  type AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_db_size' AND\n  tstamp > $__timeFrom() AND\n  tstamp <  $__timeTo()\nGROUP BY 1,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_db_size'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                " $__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": "",
      "title": "Database Size",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_COLLECTD}",
      "decimals": null,
      "format": "short",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 5,
        "y": 41
      },
      "id": 16,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "type",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  $__timeGroupAlias(tstamp,$__interval),\n  type AS metric,\n  last(value,tstamp) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_db_vac_age' AND\n  tstamp > $__timeFrom() AND\n  tstamp <  $__timeTo()\nGROUP BY 1,2\nORDER BY 1,2",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_db_vac_age'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                " $__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": "",
      "title": "xacts since last vacuum",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "columns": [],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 7,
        "x": 10,
        "y": 41
      },
      "id": 19,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (type_inst)\n  type_inst as table, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'table_sizes' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Table Size",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_COLLECTD}",
      "fontSize": "100%",
      "gridPos": {
        "h": 6,
        "w": 7,
        "x": 17,
        "y": 41
      },
      "id": 20,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "format": "table",
          "group": [],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "none",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": true,
          "rawSql": "SELECT\n  DISTINCT ON (type_inst)\n  type_inst as table, value\nFROM collectd\nWHERE\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  name = '''indexes_size''' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY 1,2\nORDER BY 1,2 DESC",
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": [],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Index Size",
      "transform": "table",
      "type": "table"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_COLLECTD}",
      "fill": 1,
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 47
      },
      "id": 17,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "paceLength": 10,
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_scan' AND\n  type_inst = 'idx_tup_fetch' AND\n  tstamp > $__timeFrom() AND\n  tstamp <  $__timeTo()\nGROUP BY type_inst, tstamp, type_inst,2\nORDER BY 1,2",
          "refId": "B",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_scan'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "'idx_tup_fetch'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                " $__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_blks' AND\n  type_inst = 'idx_read' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp, type_inst,2\nORDER BY 1,2",
          "refId": "C",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_blks'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "'idx_read'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_n_tup_c' AND\n  type_inst = 'ins' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp, type_inst,2\nORDER BY 1,2",
          "refId": "D",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_n_tup_c'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "'ins'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_n_tup_c' AND\n  type_inst = 'upd' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp, type_inst,2\nORDER BY 1,2",
          "refId": "E",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_n_tup_c'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "'upd'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            },
            {
              "params": [
                "tstamp"
              ],
              "type": "column"
            },
            {
              "params": [
                "type_inst"
              ],
              "type": "column"
            }
          ],
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "hide": false,
          "metricColumn": "type_inst",
          "orderByTime": "ASC",
          "policy": "default",
          "rawQuery": false,
          "rawSql": "SELECT\n  tstamp AS \"time\",\n  type_inst AS metric,\n  (CASE WHEN last(value,tstamp) >= lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) THEN last(value,tstamp) - lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) WHEN lag(last(value,tstamp)) OVER (PARTITION BY type_inst ORDER BY tstamp) IS NULL THEN NULL ELSE last(value,tstamp) END) AS \"value\"\nFROM collectd\nWHERE\n  $__timeFilter(tstamp) AND\n  host = '$host' AND\n  plugin_inst = '$database' AND\n  plugin = 'postgresql' AND\n  type = 'pg_n_tup_c' AND\n  type_inst = 'del' AND\n  tstamp > $__timeFrom() AND\n  tstamp < $__timeTo()\nGROUP BY type_inst, tstamp, type_inst,2\nORDER BY 1,2",
          "refId": "F",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              },
              {
                "params": [
                  "last"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "increase"
                ],
                "type": "window"
              },
              {
                "params": [
                  "value"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "collectd",
          "tags": [],
          "timeColumn": "tstamp",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "host",
                "=",
                "'$host'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin_inst",
                "=",
                "'$database'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "plugin",
                "=",
                "'postgresql'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type",
                "=",
                "'pg_n_tup_c'"
              ],
              "type": "expression"
            },
            {
              "datatype": "varchar",
              "name": "",
              "params": [
                "type_inst",
                "=",
                "'del'"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                ">",
                "$__timeFrom()"
              ],
              "type": "expression"
            },
            {
              "datatype": "timestamptz",
              "name": "",
              "params": [
                "tstamp",
                "<",
                "$__timeTo()"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Row Activity",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": -1,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": false,
  "schemaVersion": 18,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_COLLECTD}",
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "host",
        "options": [],
        "query": "SELECT DISTINCT ON (host) host as host from identifiers;",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_COLLECTD}",
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "database",
        "options": [],
        "query": "SELECT DISTINCT ON (plugin_inst) plugin_inst as plugin_inst from identifiers where plugin = 'postgresql' and host = '$host';",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "PostgreSQL Infrastructure",
  "uid": "OzvgcLBmk",
  "version": 1,
  "description": "A basic dashboard for monitoring PostgreSQL database clusters using collectd v5+, TimescaleDB/PostgreSQL v10+ and Grafana v6+"
}