Files
a13labs.infra/terraform/modules/apps/grafana/resources/trivy-vulnerabilities-dashboard.json
T
alexandre.pires 255ba6aec9 feat(trivy): Enhance Trivy report generation and metrics handling
- Updated `generate_report.sh` to include additional scanners and output paths.
- Enhanced `send_report.py` with new data classes for misconfigurations and vulnerabilities.
- Improved parsing logic for Trivy output, supporting both Kubernetes and image scans.
- Added Prometheus metrics generation for various scan results, including misconfigurations and vulnerabilities.
- Introduced unit tests for parsing Trivy output and generating Prometheus metrics.
- Modified Terraform variables for SMTP port type and added Pushgateway URL variable.
2026-05-22 23:41:26 +02:00

1073 lines
36 KiB
JSON

{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 6,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum(trivy_misconfiguration_failures{namespace=~\"${namespace:regex}\"})",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Total Failed Checks",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 1
}
]
},
"unit": "short"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "name"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "Drilldown to resource checks",
"url": "/d/trivy-vuln-overview/trivy-vulnerabilities-overview?var-datasource=${datasource}&var-namespace=${namespace}&var-resource_namespace=${__data.fields.namespace}&var-resource_kind=${__data.fields.kind}&var-resource_name=${__data.fields.name}",
"targetBlank": false
}
]
}
]
}
]
},
"gridPos": {
"h": 6,
"w": 6,
"x": 6,
"y": 0
},
"id": 2,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum(trivy_misconfiguration_successes{namespace=~\"${namespace:regex}\"})",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Total Passed Checks",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 12,
"x": 12,
"y": 0
},
"id": 6,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum(trivy_misconfiguration_failures{namespace=~\"${namespace:regex}\"}) / clamp_min(sum(trivy_misconfiguration_failures{namespace=~\"${namespace:regex}\"}) + sum(trivy_misconfiguration_successes{namespace=~\"${namespace:regex}\"}), 1)",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Failure Ratio",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 20,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 2,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 6
},
"id": 3,
"options": {
"legend": {
"calcs": [],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (severity) (trivy_misconfiguration{status=\"FAIL\",namespace=~\"${namespace:regex}\"})",
"legendFormat": "{{severity}}",
"range": true,
"refId": "A"
}
],
"title": "Failed Checks by Severity",
"type": "timeseries"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 6
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (namespace) (trivy_misconfiguration{status=\"FAIL\",namespace=~\"${namespace:regex}\"})",
"legendFormat": "{{namespace}}",
"range": true,
"refId": "A"
}
],
"title": "Failed Checks by Namespace",
"type": "barchart"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 14
},
"id": 5,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Failed Checks"
}
]
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (namespace, kind, name, type) (trivy_misconfiguration{status=\"FAIL\",namespace=~\"${namespace:regex}\"})",
"format": "table",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Top Affected Resources",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"job": true,
"instance": true
},
"indexByName": {},
"renameByName": {
"Value": "Failed Checks"
}
}
}
],
"type": "table"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Check ID"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "Open Trivy Primary URL",
"url": "${__data.fields.primary_url}",
"targetBlank": true
},
{
"title": "Search in Aqua AVD",
"url": "https://avd.aquasec.com/search/?q=${__value.raw}",
"targetBlank": true
}
]
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 24
},
"id": 7,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Failed Checks"
}
]
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (check_id, title, check_namespace, primary_url, severity) (trivy_misconfiguration{status=\"FAIL\",namespace=~\"${namespace:regex}\"})",
"format": "table",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Top Failed Checks (What Is Misconfigured)",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"job": true,
"instance": true
},
"indexByName": {},
"renameByName": {
"Value": "Failed Checks",
"check_id": "Check ID",
"check_namespace": "Check Namespace",
"primary_url": "Primary URL",
"title": "Check Title"
}
}
}
],
"type": "table"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Check ID"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "Open Trivy Primary URL",
"url": "${__data.fields.primary_url}",
"targetBlank": true
},
{
"title": "Search in Aqua AVD",
"url": "https://avd.aquasec.com/search/?q=${__value.raw}",
"targetBlank": true
}
]
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 36
},
"id": 8,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Failed Checks"
}
]
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (namespace, kind, name, check_id, title, check_namespace, primary_url, severity) (trivy_misconfiguration{status=\"FAIL\",namespace=~\"$resource_namespace\",kind=~\"$resource_kind\",name=~\"$resource_name\"})",
"format": "table",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Resource Drilldown: Failed Checks",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"job": true,
"instance": true
},
"indexByName": {},
"renameByName": {
"Value": "Failed Checks",
"check_id": "Check ID",
"check_namespace": "Check Namespace",
"primary_url": "Primary URL",
"title": "Check Title",
"kind": "Resource Kind",
"name": "Resource Name",
"namespace": "Resource Namespace"
}
}
}
],
"type": "table"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 8,
"x": 0,
"y": 48
},
"id": 9,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum(trivy_vulnerability_total{namespace=~\"${namespace:regex}\"})",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Total Vulnerabilities",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 20,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 2,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 16,
"x": 8,
"y": 48
},
"id": 10,
"options": {
"legend": {
"calcs": [],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (severity) (trivy_vulnerability_severity_count{namespace=~\"${namespace:regex}\"})",
"legendFormat": "{{severity}}",
"range": true,
"refId": "A"
}
],
"title": "Vulnerabilities by Severity",
"type": "timeseries"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Vulnerability ID"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "Open in NVD",
"url": "https://nvd.nist.gov/vuln/detail/${__value.raw}",
"targetBlank": true
},
{
"title": "Open in CVE.org",
"url": "https://www.cve.org/CVERecord?id=${__value.raw}",
"targetBlank": true
}
]
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 54
},
"id": 11,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Vulnerabilities"
}
]
},
"pluginVersion": "11.0.0",
"targets": [
{
"editorMode": "code",
"expr": "sum by (namespace, kind, name, severity, vulnerability_id, package, target) (trivy_vulnerability{namespace=~\"${namespace:regex}\"})",
"format": "table",
"instant": true,
"legendFormat": "",
"range": false,
"refId": "A"
}
],
"title": "Top Resource Vulnerabilities",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true,
"job": true,
"instance": true
},
"indexByName": {},
"renameByName": {
"Value": "Vulnerabilities",
"vulnerability_id": "Vulnerability ID",
"package": "Package",
"target": "Target"
}
}
}
],
"type": "table"
}
],
"refresh": "30s",
"schemaVersion": 39,
"style": "dark",
"tags": [
"trivy",
"security",
"vulnerabilities"
],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Prometheus",
"value": "Prometheus"
},
"hide": 0,
"includeAll": false,
"label": "Datasource",
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
{
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"datasource": "$datasource",
"definition": "label_values(trivy_misconfiguration, namespace)",
"hide": 0,
"includeAll": true,
"label": "Namespace",
"multi": true,
"name": "namespace",
"options": [],
"query": {
"query": "label_values(trivy_misconfiguration, namespace)",
"refId": "Prometheus-namespace"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"type": "query",
"allValue": ".*"
},
{
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"hide": 0,
"includeAll": true,
"label": "Resource Namespace",
"multi": false,
"name": "resource_namespace",
"options": [],
"query": "",
"refresh": 0,
"regex": "",
"skipUrlSync": false,
"type": "custom",
"allValue": ".*"
},
{
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"hide": 0,
"includeAll": true,
"label": "Resource Kind",
"multi": false,
"name": "resource_kind",
"options": [],
"query": "",
"refresh": 0,
"regex": "",
"skipUrlSync": false,
"type": "custom",
"allValue": ".*"
},
{
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"hide": 0,
"includeAll": true,
"label": "Resource Name",
"multi": false,
"name": "resource_name",
"options": [],
"query": "",
"refresh": 0,
"regex": "",
"skipUrlSync": false,
"type": "custom",
"allValue": ".*"
}
]
},
"time": {
"from": "now-7d",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Trivy Vulnerabilities Overview",
"uid": "trivy-vuln-overview",
"version": 1,
"weekStart": ""
}