Grafana dashboard: OpenNMS Database (PostgreSQL)
Description: OpenNMS database performance monitoring

Dashboard to monitor PostgreSQL performance for OpenNMS.

This needs a PostgreSQL datasource, which is not part of OpenNMS Helm!



{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.1.2"
    },
    {
      "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"
      }
    ]
  },
  "description": "OpenNMS database performance monitoring",
  "editable": true,
  "gnetId": 6048,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1526070039731,
  "links": [
    {
      "icon": "external link",
      "tags": [],
      "targetBlank": true,
      "title": "Performance Optimization",
      "tooltip": "PostgreSQL Performance Optimization",
      "type": "link",
      "url": "https://wiki.postgresql.org/wiki/Performance_Optimization"
    },
    {
      "icon": "external link",
      "tags": [],
      "targetBlank": true,
      "title": "Useful Queries",
      "tooltip": "Most of the content has been taken from \"Useful PostgreSQL Queries and Commands\"",
      "type": "link",
      "url": "https://gist.github.com/rgreenjr/3637525"
    }
  ],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 16,
      "panels": [],
      "title": "Cache",
      "type": "row"
    },
    {
      "columns": [],
      "datasource": "$database",
      "fontSize": "100%",
      "gridPos": {
        "h": 3,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 10,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": "row",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 4,
          "link": false,
          "mappingType": 1,
          "pattern": "ratio",
          "thresholds": [
            "0.98",
            "0.99"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "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": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "SELECT sum(heap_blks_read) as heap_read, sum(heap_blks_hit)  as heap_hit, (sum(heap_blks_hit) - sum(heap_blks_read)) / sum(heap_blks_hit) as ratio\nFROM pg_statio_user_tables",
          "refId": "A"
        }
      ],
      "title": "Table cache hit rates",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "$database",
      "fontSize": "100%",
      "gridPos": {
        "h": 3,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 18,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "colorMode": "row",
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 4,
          "mappingType": 1,
          "pattern": "ratio",
          "thresholds": [
            "0.990",
            "0.995"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "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": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "SELECT\n        sum(idx_blks_read) AS idx_read,\n        sum(idx_blks_hit) AS idx_hit,\n        (sum(idx_blks_hit) - sum(idx_blks_read)) / sum(idx_blks_hit) AS ratio\nFROM\n        pg_statio_user_indexes",
          "refId": "A"
        }
      ],
      "title": "Index cache hit rates",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "$database",
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 4
      },
      "id": 12,
      "links": [],
      "pageSize": 25,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "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": "short"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "SELECT schemaname AS \"Schema\",\n       relname AS \"Relation\", \n  CASE WHEN (seq_scan + idx_scan) != 0\n    THEN 100.0 * idx_scan / (seq_scan + idx_scan) \n    ELSE 0\n  END AS percent_of_times_index_used,\n  n_live_tup AS rows_in_table\nFROM\n        pg_stat_user_tables \nWHERE\n        n_live_tup > 0\nORDER BY n_live_tup DESC",
          "refId": "A"
        }
      ],
      "title": "Table index usage rates",
      "transform": "table",
      "type": "table"
    },
    {
      "collapsed": true,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 12
      },
      "id": 34,
      "panels": [
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 13
          },
          "id": 24,
          "links": [],
          "pageSize": null,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 2,
            "desc": false
          },
          "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT d.datname AS Name, pg_catalog.pg_get_userbyid(d.datdba) AS Owner,\n  CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n    THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname)) \n    ELSE 'No Access' \n  END AS SIZE \nFROM pg_catalog.pg_database d \nORDER BY \n  CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') \n    THEN pg_catalog.pg_database_size(d.datname)\n    ELSE NULL \n  END",
              "refId": "A"
            }
          ],
          "title": "Database size",
          "transform": "table",
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 13
          },
          "id": 26,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 2,
            "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)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 0,
              "mappingType": 1,
              "pattern": "total_size",
              "thresholds": [],
              "type": "number",
              "unit": "bytes"
            },
            {
              "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT\n        nspname AS \"Scheme\",\n        relname AS \"Relation\",\n        pg_total_relation_size(C.oid) AS \"total_size\"\nFROM\n        pg_class C\nLEFT JOIN\n        pg_namespace N ON (N.oid = C.relnamespace)\nWHERE\n        nspname NOT IN ('pg_catalog', 'information_schema')\nAND\n        C.relkind <> 'i'\nAND\n        nspname !~ '^pg_toast'\nORDER BY\n        pg_total_relation_size(C.oid) DESC",
              "refId": "A"
            }
          ],
          "title": "Table size",
          "transform": "table",
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 24,
            "x": 0,
            "y": 22
          },
          "id": 22,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 7,
            "desc": true
          },
          "styles": [
            {
              "alias": "Last $1",
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "pattern": "/last_(.*)/",
              "type": "date"
            },
            {
              "alias": "Level",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "level",
              "thresholds": [],
              "type": "number",
              "unit": "percent"
            },
            {
              "alias": "$1 tupel",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "/n_(.*)_tup/",
              "thresholds": [],
              "type": "number",
              "unit": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT\n        schemaname AS \"Schema\",\n        relname AS \"Relation\",\n        last_vacuum,\n        last_autovacuum,\n        last_analyze,\n        last_autoanalyze,\n        n_live_tup,\n        n_dead_tup,\n        n_live_tup * 100. / ( n_live_tup + n_dead_tup) AS level\nfrom\n        pg_stat_user_tables\nwhere\n        n_dead_tup > 0\norder by\n        n_dead_tup desc",
              "refId": "A"
            }
          ],
          "title": "Table disk level",
          "transform": "table",
          "type": "table"
        }
      ],
      "title": "Disk storage",
      "type": "row"
    },
    {
      "collapsed": true,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 13
      },
      "id": 30,
      "panels": [
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 24,
            "x": 0,
            "y": 14
          },
          "id": 20,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 0,
            "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT now() - query_start as \"runtime\", usename, datname, waiting, state, query\n  FROM  pg_stat_activity\n  WHERE now() - query_start > '2 minutes'::interval\n ORDER BY runtime DESC",
              "refId": "A"
            }
          ],
          "title": "Slow queries",
          "transform": "table",
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 23
          },
          "id": 2,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 4,
            "desc": false
          },
          "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)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 0,
              "mappingType": 1,
              "pattern": "pid",
              "thresholds": [],
              "type": "number",
              "unit": "none"
            },
            {
              "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT pid, age(query_start, clock_timestamp()), usename, client_hostname, application_name, query \nFROM pg_stat_activity \nWHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' \nORDER BY query_start desc;",
              "refId": "A"
            }
          ],
          "title": "Running queries",
          "transform": "table",
          "type": "table"
        }
      ],
      "title": "Queries",
      "type": "row"
    },
    {
      "collapsed": true,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 14
      },
      "id": 32,
      "panels": [
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 7,
            "w": 24,
            "x": 0,
            "y": 1
          },
          "id": 28,
          "links": [],
          "pageSize": null,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 0,
            "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT t.relname, l.locktype, page, virtualtransaction, pid, mode, granted \nFROM pg_locks l, pg_stat_all_tables t \nWHERE l.relation = t.relid ORDER BY relation asc",
              "refId": "A"
            }
          ],
          "title": "Locks",
          "transform": "table",
          "type": "table"
        }
      ],
      "title": "Locks",
      "type": "row"
    },
    {
      "collapsed": true,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 15
      },
      "id": 14,
      "panels": [
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 16
          },
          "id": 6,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 0,
            "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "SELECT\n       *\nfrom\n      pg_user",
              "refId": "A"
            }
          ],
          "title": "Users",
          "transform": "table",
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 0,
            "y": 24
          },
          "id": 4,
          "links": [],
          "pageSize": 25,
          "scroll": true,
          "showHeader": true,
          "sort": {
            "col": 0,
            "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)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 0,
              "mappingType": 1,
              "pattern": "connections",
              "thresholds": [],
              "type": "number",
              "unit": "short"
            },
            {
              "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "select usename, count(usename) as connections from pg_stat_activity where query not like '<%' group by usename order by connections desc",
              "refId": "A"
            }
          ],
          "title": "Connections per user",
          "transform": "table",
          "type": "table"
        },
        {
          "columns": [],
          "datasource": "$database",
          "fontSize": "100%",
          "gridPos": {
            "h": 9,
            "w": 12,
            "x": 12,
            "y": 24
          },
          "id": 35,
          "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)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 0,
              "mappingType": 1,
              "pattern": "connections",
              "thresholds": [],
              "type": "number",
              "unit": "short"
            },
            {
              "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": "short"
            }
          ],
          "targets": [
            {
              "alias": "",
              "format": "table",
              "rawSql": "select application_name, count(application_name) as connections from pg_stat_activity where query not like '<%' group by application_name order by connections desc",
              "refId": "A"
            }
          ],
          "title": "Connections per application",
          "transform": "table",
          "type": "table"
        }
      ],
      "title": "Users and Connections",
      "type": "row"
    }
  ],
  "schemaVersion": 16,
  "style": "dark",
  "tags": [
    "opennms",
    "postgresql"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "text": "OpenNMS PostgreSQL",
          "value": "OpenNMS PostgreSQL"
        },
        "hide": 0,
        "label": null,
        "name": "database",
        "options": [],
        "query": "postgres",
        "refresh": 1,
        "regex": "",
        "type": "datasource"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "hidden": true,
    "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": "OpenNMS Database (PostgreSQL)",
  "uid": "CwD66dnmz",
  "version": 11
}