Grafana dashboard: GOdin
Description: Sample dashboard for GOdin metrics collector


{
  "__inputs": [
    {
      "name": "DS_POSTGRESQL-GODIN",
      "label": "PostgreSQL-godin",
      "description": "",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.1.2"
    },
    {
      "type": "panel",
      "id": "piechart",
      "name": "Pie chart",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 14939,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1630075948001,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_POSTGRESQL-GODIN}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "#FF9830",
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "filterable": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 11,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Upgradable packages"
          }
        ]
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT s2.hostname,\r\n      s2.timestamp AS \"Last checked\",\r\n       COUNT(*) AS \"Upgradable packages\"\r\nFROM\r\n  (SELECT s1.hostname,\r\n          s1.timestamp,\r\n          arr\r\n   FROM\r\n     (SELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->>'hostname' AS hostname,\r\n                                                                                TIMESTAMP,\r\n                                                                                report\r\n      FROM reports\r\n      ORDER BY report->'host_info'->'hostname',\r\n                                    TIMESTAMP DESC) AS s1,\r\n        jsonb_array_elements(s1.report -> 'packages') arr(item_object)\r\n   WHERE arr.item_object ->> 'upgrade' = 'yes') AS s2\r\nGROUP BY s2.hostname, s2.timestamp;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "reports",
          "timeColumn": "\"timestamp\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Upgrade panel",
      "transformations": [],
      "type": "table"
    },
    {
      "datasource": "${DS_POSTGRESQL-GODIN}",
      "description": "Hosts that haven't reported in >7 days",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 7,
        "x": 11,
        "y": 0
      },
      "id": 7,
      "options": {
        "showHeader": true
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT DISTINCT ON (report -> 'host_info' ->> 'hostname') report->'host_info'->>'hostname' as hostname, timestamp\r\nFROM reports\r\nWHERE timestamp <= NOW() - INTERVAL '7 DAY'\r\nORDER BY report->'host_info'->>'hostname', timestamp DESC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Missing hosts",
      "type": "table"
    },
    {
      "datasource": "${DS_POSTGRESQL-GODIN}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            }
          },
          "mappings": []
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 6,
        "x": 18,
        "y": 0
      },
      "id": 5,
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "pieType": "pie",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT\r\n      now() as time,\r\n      s2.hostname AS metric,\r\n      COUNT(*) AS value\r\nFROM\r\n  (SELECT s1.hostname,\r\n          arr\r\n   FROM\r\n     (SELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->>'hostname' AS hostname,\r\n                                                                                TIMESTAMP,\r\n                                                                                report\r\n      FROM reports\r\n      ORDER BY report->'host_info'->'hostname',\r\n                                    TIMESTAMP DESC) AS s1,\r\n        jsonb_array_elements(s1.report -> 'packages') arr(item_object)\r\n   WHERE arr.item_object ->> 'upgrade' = 'yes') AS s2\r\nGROUP BY s2.hostname;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Same but nice pie chart",
      "type": "piechart"
    },
    {
      "datasource": "${DS_POSTGRESQL-GODIN}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 24,
        "x": 0,
        "y": 9
      },
      "id": 9,
      "options": {
        "showHeader": true
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT DISTINCT ON (report -> 'host_info' ->> 'hostname')\r\n  report->'host_info'->>'os' as OS,\r\n  report->'host_info'->>'kernel' as kernel,\r\n  report->'host_info'->>'architecture' as architecture,\r\n  report->>'package_manager' AS \"Package manager\"\r\nFROM reports\r\nWHERE report -> 'host_info' ->> 'hostname' = ${hostname:singlequote}\r\nORDER BY report->'host_info'->>'hostname' DESC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "column"
              }
            ]
          ],
          "timeColumn": "time",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "${hostname}",
      "type": "table"
    },
    {
      "datasource": "${DS_POSTGRESQL-GODIN}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 12
      },
      "id": 3,
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": false,
            "displayName": "Package name"
          }
        ]
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "format": "table",
          "group": [],
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT s2.arr->>'name' AS \"Package name\",\r\n       s3.arr->>'version' AS \"Current\",\r\n       s2.arr->>'version' AS \"Candidate\"\r\nFROM\r\n\t(\t\r\n\tSELECT s1.hostname,\r\n          arr\r\n\tFROM\r\n\t\t(\tSELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->'hostname' AS hostname,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTIMESTAMP,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treport\r\n\t\t\tFROM reports\r\n\t\t\tWHERE report->'host_info'->>'hostname' = ${hostname:singlequote}\r\n\t\t\tORDER BY report->'host_info'->'hostname',\r\n\t\t\t\t\t\t\t\t\t\tTIMESTAMP DESC\r\n\t\t) AS s1,\r\n\t\tjsonb_array_elements(s1.report -> 'packages') arr(item_object)\r\n\tWHERE \r\n\t\tarr.item_object ->> 'upgrade' = 'yes'\r\n\t) AS s2\r\n\t\r\n\tLEFT JOIN (\t\r\n\tSELECT s1.hostname,\r\n          arr\r\n\tFROM\r\n\t\t(\tSELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->'hostname' AS hostname,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTIMESTAMP,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treport\r\n\t\t\tFROM reports\r\n\t\t\tWHERE report->'host_info'->>'hostname' = ${hostname:singlequote}\r\n\t\t\tORDER BY report->'host_info'->'hostname',\r\n\t\t\t\t\t\t\t\t\t\tTIMESTAMP DESC\r\n\t\t) AS s1,\r\n\t\tjsonb_array_elements(s1.report -> 'packages') arr(item_object)\r\n\tWHERE \r\n\t\tNOT (arr.item_object ? 'upgrade')\r\n\t) AS s3 ON s2.arr->>'name' = s3.arr->>'name'\r\n\r\nGROUP BY s2.hostname, s2.arr, s3.arr;",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "reports",
          "timeColumn": "\"timestamp\"",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Upgrade list for ${hostname}",
      "type": "table"
    }
  ],
  "refresh": false,
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_POSTGRESQL-GODIN}",
        "definition": "SELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->>'hostname' FROM reports;",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Hostname",
        "multi": false,
        "name": "hostname",
        "options": [],
        "query": "SELECT DISTINCT ON (report->'host_info'->'hostname') report->'host_info'->>'hostname' FROM reports;",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "hidden": true
  },
  "timezone": "",
  "title": "GOdin",
  "uid": "HAjGJln7z",
  "version": 28,
  "description": "Sample dashboard for GOdin metrics collector"
}