Grafana dashboard: Trivy Vulnerabilities
Description: Dashboard for Kube Trivy Exporter 
https://github.com/kaidotdev/kube-trivy-exporter

For image details install also this dashboard https://grafana.com/grafana/dashboards/12330


{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.7.3"
    },
    {
      "type": "panel",
      "id": "grafana-piechart-panel",
      "name": "Pie Chart",
      "version": "1.5.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "$$hashKey": "object:7",
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Dashboard for Kube Trivy Exporter \nhttps://github.com/kaidotdev/kube-trivy-exporter\n\nFor image details install also this dashboard https://grafana.com/grafana/dashboards/12330",
  "editable": true,
  "gnetId": 12331,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 2,
        "x": 0,
        "y": 0
      },
      "id": 18,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "first"
          ],
          "defaults": {
            "mappings": [
              {
                "$$hashKey": "object:178",
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 2,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "dark-red",
                  "value": null
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "count(trivy_vulnerabilities{severity=\"CRITICAL\"})",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM vulnerability\nWHERE\n  severity = 'critical'",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "title": "Critical",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 2,
        "x": 2,
        "y": 0
      },
      "id": 48,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [
              {
                "$$hashKey": "object:135",
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 100,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "semi-dark-red",
                  "value": null
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "count(trivy_vulnerabilities{severity=\"HIGH\"})",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM vulnerability\nWHERE\n  severity = 'high'",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "title": "High",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 2,
        "x": 4,
        "y": 0
      },
      "id": 26,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [
              {
                "$$hashKey": "object:221",
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 100,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "dark-orange",
                  "value": null
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "count(trivy_vulnerabilities{severity=\"MEDIUM\"})",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM vulnerability\nWHERE\n  severity = 'medium'",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "title": "Medium",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 2,
        "x": 6,
        "y": 0
      },
      "id": 20,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [
              {
                "$$hashKey": "object:264",
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 100,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "light-blue",
                  "value": null
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "count(trivy_vulnerabilities{severity=\"LOW\"})",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM vulnerability\nWHERE\n  severity = 'low'",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "title": "Low",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "gridPos": {
        "h": 5,
        "w": 2,
        "x": 8,
        "y": 0
      },
      "id": 52,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [
              {
                "$$hashKey": "object:315",
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 100,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "light-purple",
                  "value": null
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.3",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "count(trivy_vulnerabilities{severity=\"UNKNOWN\"})",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM host",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "title": "Unkown",
      "type": "gauge"
    },
    {
      "aliasColors": {},
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Severiy",
        "threshold": 0
      },
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "80%",
      "format": "short",
      "gridPos": {
        "h": 5,
        "w": 7,
        "x": 10,
        "y": 0
      },
      "id": 43,
      "interval": "",
      "legend": {
        "show": true,
        "sideWidth": 200,
        "sort": "current",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": 3,
      "nullPointMode": "connected",
      "pieType": "pie",
      "pluginVersion": "6.7.3",
      "strokeWidth": 1,
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "expr": "sum(trivy_vulnerabilities) by (severity)",
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{severity}}",
          "metricColumn": "name",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroupAlias(create_date,336h),\n  ip AS metric,\n  count(id) AS count\nFROM host\nWHERE\n  $__timeFilter(create_date) AND owned = 'true' AND workspace_id=1\nGROUP BY 1,2\nORDER BY 1,2,3",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": "30d",
      "title": "Vulneribilities Pie",
      "type": "grafana-piechart-panel",
      "valueName": "current"
    },
    {
      "columns": [],
      "datasource": "${DS_PROMETHEUS}",
      "fontSize": "100%",
      "gridPos": {
        "h": 15,
        "w": 17,
        "x": 0,
        "y": 5
      },
      "id": 54,
      "pageSize": null,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "$$hashKey": "object:571",
          "alias": "Time",
          "align": "auto",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "$$hashKey": "object:1680",
          "alias": "",
          "align": "auto",
          "colorMode": "cell",
          "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,
          "link": false,
          "mappingType": 1,
          "pattern": "/severity/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "$$hashKey": "object:2010",
          "alias": "TOTAL Vulnerabilities",
          "align": "auto",
          "colorMode": "cell",
          "colors": [
            "#56A64B",
            "#FF780A",
            "#E02F44"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Value #A",
          "thresholds": [
            "50"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "$$hashKey": "object:2082",
          "alias": "CRITICAL Vulnerabilities",
          "align": "auto",
          "colorMode": "row",
          "colors": [
            "#C4162A",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Value #B",
          "thresholds": [
            "2"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "$$hashKey": "object:2257",
          "alias": "HIGH Vulnerabilities",
          "align": "auto",
          "colorMode": "cell",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "Value #C",
          "thresholds": [
            "50"
          ],
          "type": "number",
          "unit": "short"
        },
        {
          "$$hashKey": "object:2709",
          "alias": "",
          "align": "auto",
          "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,
          "link": true,
          "linkTooltip": "Drill down",
          "linkUrl": "/d/VTc2usgGz/trivy-vulneribilities-image-overview?orgId=1&var-image=$__cell",
          "mappingType": 1,
          "pattern": "image",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "$$hashKey": "object:572",
          "alias": "",
          "align": "left",
          "colorMode": null,
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "decimals": 0,
          "pattern": "/.*/",
          "thresholds": [
            ""
          ],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "expr": "sort(sum(trivy_vulnerabilities) by (image))",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "Image",
          "refId": "A"
        },
        {
          "expr": "sum(trivy_vulnerabilities{severity=\"CRITICAL\"}) by (image)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "B",
          "refId": "B"
        },
        {
          "expr": "sum(trivy_vulnerabilities{severity=\"HIGH\"}) by (image)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "B",
          "refId": "C"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Image Vulnerabilities",
      "transform": "table",
      "type": "table"
    }
  ],
  "refresh": "15m",
  "schemaVersion": 22,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-30d",
    "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": "Trivy Vulnerabilities",
  "uid": "BQnjzl-iz",
  "variables": {
    "list": []
  },
  "version": 11
}