Grafana dashboard: Trivy: Workload Vulnerabilities
Description: Access https://github.com/lucasafonsokremer/trivy-vulnerability-exporter


{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.1.2"
    },
    {
      "type": "panel",
      "id": "piechart",
      "name": "Pie chart",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "$$hashKey": "object:7",
        "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"
      }
    ]
  },
  "description": "Access https://github.com/lucasafonsokremer/trivy-vulnerability-exporter",
  "editable": true,
  "gnetId": 17046,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": null,
      "description": "",
      "gridPos": {
        "h": 2,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 62,
      "options": {
        "content": "<p style=\"text-align: center\">This project is maintained by https://github.com/lucasafonsokremer/trivy-vulnerability-exporter</p>           ",
        "mode": "html"
      },
      "pluginVersion": "8.1.2",
      "title": "Reference",
      "type": "text"
    },
    {
      "collapsed": false,
      "datasource": null,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 2
      },
      "id": 58,
      "panels": [],
      "title": "Workload: vulnerabilities overview",
      "type": "row"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "$$hashKey": "object:178",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 2,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-red",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 0,
        "y": 3
      },
      "id": 18,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "count(trivy_image_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": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": null,
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "$$hashKey": "object:135",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 50,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "orange",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 3,
        "y": 3
      },
      "id": 48,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "count(trivy_image_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": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "$$hashKey": "object:221",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "yellow",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 6,
        "y": 3
      },
      "id": 26,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "count(trivy_image_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": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "$$hashKey": "object:264",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "light-blue",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 9,
        "y": 3
      },
      "id": 20,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "count(trivy_image_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": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "$$hashKey": "object:315",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#908d91",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 12,
        "y": 3
      },
      "id": 52,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "count(trivy_image_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": "stat"
    },
    {
      "datasource": null,
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            }
          },
          "mappings": []
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 9,
        "x": 15,
        "y": 3
      },
      "id": 56,
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "values": [
            "value"
          ]
        },
        "pieType": "pie",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "targets": [
        {
          "exemplar": true,
          "expr": "sum(trivy_image_vulnerabilities) by (severity)",
          "format": "time_series",
          "interval": "",
          "legendFormat": "{{severity}}",
          "refId": "A"
        }
      ],
      "title": "Vulnerabilities overview",
      "transformations": [
        {
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "names": [
                "Time",
                "CRITICAL",
                "HIGH",
                "LOW",
                "MEDIUM"
              ]
            }
          }
        }
      ],
      "type": "piechart"
    },
    {
      "collapsed": false,
      "datasource": null,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 12
      },
      "id": 60,
      "panels": [],
      "title": "Workload: details",
      "type": "row"
    },
    {
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "left",
            "displayMode": "auto"
          },
          "decimals": 0,
          "displayName": "",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "rgba(50, 172, 45, 0.97)",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Time"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Time"
              },
              {
                "id": "custom.align",
                "value": null
              }
            ]
          },
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/severity/"
            },
            "properties": [
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "custom.align",
                "value": null
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #A"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "TOTAL Vulnerabilities"
              },
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "custom.align",
                "value": null
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "#7c7e7c",
                      "value": null
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #B"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "CRITICAL Vulnerabilities"
              },
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "custom.align",
                "value": null
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "#C4162A",
                      "value": null
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #C"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "HIGH Vulnerabilities"
              },
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "custom.align",
                "value": null
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "orange",
                      "value": null
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "image"
            },
            "properties": [
              {
                "id": "unit",
                "value": "short"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "links",
                "value": [
                  {
                    "targetBlank": false,
                    "title": "Drill down",
                    "url": "/d/VTc2usgGz/trivy-vulneribilities-image-overview?orgId=1&var-image=$__cell"
                  }
                ]
              },
              {
                "id": "custom.align",
                "value": null
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 26,
        "w": 24,
        "x": 0,
        "y": 13
      },
      "id": 54,
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "CRITICAL Vulnerabilities"
          }
        ]
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "exemplar": true,
          "expr": "sum(trivy_image_vulnerabilities{severity=\"CRITICAL\"}) by (workloadName, image)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "A",
          "refId": "B"
        },
        {
          "exemplar": true,
          "expr": "sum(trivy_image_vulnerabilities{severity=\"HIGH\"}) by (workloadName, image)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "B",
          "refId": "C"
        },
        {
          "exemplar": true,
          "expr": "sort(sum(trivy_image_vulnerabilities) by (workloadName, image))",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "C",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Image Vulnerabilities",
      "transformations": [
        {
          "id": "merge",
          "options": {
            "reducers": []
          }
        },
        {
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "names": [
                "image",
                "workloadName",
                "Value #B",
                "Value #C",
                "Value #A"
              ]
            }
          }
        }
      ],
      "type": "table"
    }
  ],
  "refresh": "",
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-1h",
    "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: Workload Vulnerabilities",
  "uid": "1oVwWun4k",
  "version": 50
}