diff --git a/exporter-go/opa_scorecard_exporter b/exporter-go/opa_scorecard_exporter deleted file mode 100755 index 8632554..0000000 Binary files a/exporter-go/opa_scorecard_exporter and /dev/null differ diff --git a/grafana_opa_dashboard.png b/grafana_opa_dashboard.png index 1031fc2..a30260d 100644 Binary files a/grafana_opa_dashboard.png and b/grafana_opa_dashboard.png differ diff --git a/kube-prometheus-stack/cm-custom-dashboard.yaml b/kube-prometheus-stack/cm-custom-dashboard.yaml index 229cd08..c3a1f5a 100644 --- a/kube-prometheus-stack/cm-custom-dashboard.yaml +++ b/kube-prometheus-stack/cm-custom-dashboard.yaml @@ -7,353 +7,465 @@ metadata: data: opa-dashboard.json: |- { - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": 25, - "iteration": 1622541982959, - "links": [], - "panels": [ + "annotations": { + "list": [ { - "datasource": null, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "left", - "filterable": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "iteration": 1623664009501, + "links": [], + "panels": [ + { + "datasource": null, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "violating_name" - }, - "properties": [ - { - "id": "custom.width", - "value": 170 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "violating_kind" + "custom": { + "align": "left", + "displayMode": "auto", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null }, - "properties": [ - { - "id": "custom.width", - "value": 169 - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 2, - "options": { - "showHeader": true, - "sortBy": [] + { + "color": "red", + "value": 80 + } + ] + } }, - "pluginVersion": "7.5.5", - "targets": [ + "overrides": [ { - "exemplar": true, - "expr": "opa_scorecard_violations{violating_namespace=\"$namespace\"}", - "format": "table", - "instant": true, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "OPA Violations", - "transformations": [ + "matcher": { + "id": "byName", + "options": "violating_name" + }, + "properties": [ + { + "id": "custom.width", + "value": 170 + } + ] + }, { - "id": "filterFieldsByName", - "options": { - "include": { - "names": [ - "kind", - "name", - "violating_kind", - "violating_name", - "violation_msg" - ] + "matcher": { + "id": "byName", + "options": "violating_kind" + }, + "properties": [ + { + "id": "custom.width", + "value": 169 } - } + ] } - ], - "type": "table" + ] }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "fieldConfig": { - "defaults": { - "unit": "short" - }, - "overrides": [] - }, - "fill": 2, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 8 - }, - "hiddenSeries": false, - "id": 4, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.5", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "exemplar": true, - "expr": "count(opa_scorecard_violations{violating_namespace=\"$namespace\"})", - "interval": "", - "legendFormat": "Overall OPA violations per namespace", - "refId": "A" + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "8.0.0", + "targets": [ + { + "exemplar": true, + "expr": "opa_scorecard_constraint_violations{violating_namespace=\"$namespace\"}", + "format": "table", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "OPA Violations", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "kind", + "name", + "violating_kind", + "violating_name", + "violation_msg" + ] + } } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "OPA Violations Over Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] + } + ], + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "unit": "short" }, - "yaxes": [ - { - "$$hashKey": "object:107", - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "$$hashKey": "object:108", - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null + "overrides": [] + }, + "fill": 2, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 8 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.0.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "count(opa_scorecard_constraint_violations{violating_namespace=\"$namespace\"})", + "interval": "", + "legendFormat": "Overall OPA violations per namespace", + "refId": "A" } - } - ], - "refresh": false, - "schemaVersion": 27, - "style": "dark", - "tags": [], - "templating": { - "list": [ + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "OPA Violations Over Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ { - "current": { - "selected": false, - "text": "default", - "value": "default" - }, - "description": null, - "error": null, - "hide": 0, - "includeAll": false, + "$$hashKey": "object:107", + "format": "short", "label": null, - "multi": false, - "name": "datasource", - "options": [], - "query": "prometheus", - "queryValue": "", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" + "logBase": 1, + "max": null, + "min": null, + "show": true }, { - "allValue": null, - "current": { - "isNone": true, - "selected": false, - "text": "None", - "value": "" - }, - "datasource": null, - "definition": "label_values(kube_pod_info, cluster)", - "description": null, - "error": null, - "hide": 0, - "includeAll": false, + "$$hashKey": "object:108", + "format": "short", "label": null, - "multi": false, - "name": "cluster", - "options": [ - { - "isNone": true, - "selected": true, - "text": "None", - "value": "" - } - ], - "query": { - "query": "label_values(kube_pod_info, cluster)", - "refId": "StandardVariableQuery" + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": "${datasource}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "refresh": 0, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 15 + }, + "id": 8, + "options": { + "displayMode": "gradient", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "text": {} + }, + "pluginVersion": "8.0.0", + "targets": [ { - "allValue": null, - "current": { - "selected": false, - "text": "default", - "value": "default" + "exemplar": true, + "expr": "sum by (kind) (opa_scorecard_constraint_violations)", + "format": "time_series", + "interval": "", + "legendFormat": "{{kind}}", + "refId": "A" + } + ], + "title": "Total Violations by kind", + "transformations": [], + "type": "bargauge" + }, + { + "datasource": "${datasource}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - "datasource": "$datasource", - "definition": "", - "description": null, - "error": null, - "hide": 0, - "includeAll": false, - "label": null, - "multi": false, - "name": "namespace", - "options": [], - "query": { - "query": "label_values(kube_pod_info{cluster=\"$cluster\"}, namespace)", - "refId": "Prometheus-namespace-Variable-Query" + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "mappings": [] + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 15 + }, + "id": 6, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "sum(opa_scorecard_constraint_information{enforcementAction=\"dryrun\"})", + "interval": "", + "legendFormat": "enforcementAction=\"dryrun\"", + "refId": "A" + }, + { + "exemplar": true, + "expr": "sum(opa_scorecard_constraint_information{enforcementAction=\"deny\"})", + "hide": false, + "interval": "", + "legendFormat": "enforcementAction=\"deny\"", + "refId": "B" } - ] - }, - "time": { - "from": "now-2d", - "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": "UTC", - "title": "OPA Violations", - "uid": "YBgRZG6Mz", - "version": 23 - } \ No newline at end of file + "title": "Enforcement Actions", + "type": "piechart" + } + ], + "refresh": false, + "schemaVersion": 30, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "default", + "value": "default" + }, + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "datasource", + "options": [], + "query": "prometheus", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "allValue": null, + "current": { + "isNone": true, + "selected": false, + "text": "None", + "value": "" + }, + "datasource": null, + "definition": "label_values(kube_pod_info, cluster)", + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "cluster", + "options": [], + "query": { + "query": "label_values(kube_pod_info, cluster)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "selected": false, + "text": "prometheus", + "value": "prometheus" + }, + "datasource": "$datasource", + "definition": "", + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "namespace", + "options": [], + "query": { + "query": "label_values(kube_pod_info{cluster=\"$cluster\"}, namespace)", + "refId": "Prometheus-namespace-Variable-Query" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-5m", + "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": "UTC", + "title": "OPA Violations", + "uid": "YBgRZG6Mz", + "version": 1 + } diff --git a/kube-prometheus-stack/grafana-opa-dashboard.json b/kube-prometheus-stack/grafana-opa-dashboard.json index 32091da..b793e3c 100644 --- a/kube-prometheus-stack/grafana-opa-dashboard.json +++ b/kube-prometheus-stack/grafana-opa-dashboard.json @@ -1,351 +1,487 @@ { - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": 25, - "iteration": 1622636975471, - "links": [], - "panels": [ + "annotations": { + "list": [ { - "datasource": null, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "left", - "filterable": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "iteration": 1623664083456, + "links": [], + "panels": [ + { + "datasource": null, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "violating_name" - }, - "properties": [ - { - "id": "custom.width", - "value": 170 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "violating_kind" + "custom": { + "align": "left", + "displayMode": "auto", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null }, - "properties": [ - { - "id": "custom.width", - "value": 169 - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 2, - "options": { - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "7.5.5", - "targets": [ - { - "exemplar": true, - "expr": "opa_scorecard_violations{violating_namespace=\"$namespace\"}", - "format": "table", - "instant": true, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" + { + "color": "red", + "value": 80 + } + ] } - ], - "timeFrom": null, - "timeShift": null, - "title": "OPA Violations", - "transformations": [ + }, + "overrides": [ { - "id": "filterFieldsByName", - "options": { - "include": { - "names": [ - "kind", - "name", - "violating_kind", - "violating_name", - "violation_msg" - ] + "matcher": { + "id": "byName", + "options": "violating_name" + }, + "properties": [ + { + "id": "custom.width", + "value": 170 } - } - } - ], - "type": "table" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "fieldConfig": { - "defaults": { - "unit": "short" + ] }, - "overrides": [] - }, - "fill": 2, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 8 - }, - "hiddenSeries": false, - "id": 4, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.5", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ { - "exemplar": true, - "expr": "count(opa_scorecard_violations{violating_namespace=\"$namespace\"})", - "interval": "", - "legendFormat": "Overall OPA violations per namespace", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "OPA Violations Over Time", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ + "matcher": { + "id": "byName", + "options": "violating_kind" + }, + "properties": [ + { + "id": "custom.width", + "value": 169 + } + ] + }, { - "$$hashKey": "object:107", - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true + "matcher": { + "id": "byName", + "options": "kind" + }, + "properties": [ + { + "id": "custom.width", + "value": 321 + } + ] }, { - "$$hashKey": "object:108", - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true + "matcher": { + "id": "byName", + "options": "name" + }, + "properties": [ + { + "id": "custom.width", + "value": 313 + } + ] } - ], - "yaxis": { - "align": false, - "alignLevel": null + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "8.0.0", + "targets": [ + { + "exemplar": true, + "expr": "opa_scorecard_constraint_violations{violating_namespace=\"$namespace\"}", + "format": "table", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" } - } - ], - "refresh": false, - "schemaVersion": 27, - "style": "dark", - "tags": [], - "templating": { - "list": [ + ], + "timeFrom": null, + "timeShift": null, + "title": "OPA Violations", + "transformations": [ { - "current": { - "selected": false, - "text": "default", - "value": "default" - }, - "description": null, - "error": null, - "hide": 0, - "includeAll": false, + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "kind", + "name", + "violating_kind", + "violating_name", + "violation_msg" + ] + } + } + } + ], + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "fill": 2, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 8 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.0.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "count(opa_scorecard_constraint_violations{violating_namespace=\"$namespace\"})", + "interval": "", + "legendFormat": "Overall OPA violations per namespace", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "OPA Violations Over Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:107", + "format": "short", "label": null, - "multi": false, - "name": "datasource", - "options": [], - "query": "prometheus", - "queryValue": "", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" + "logBase": 1, + "max": null, + "min": null, + "show": true }, { - "allValue": null, - "current": { - "isNone": true, - "selected": false, - "text": "None", - "value": "" - }, - "datasource": null, - "definition": "label_values(kube_pod_info, cluster)", - "description": null, - "error": null, - "hide": 0, - "includeAll": false, + "$$hashKey": "object:108", + "format": "short", "label": null, - "multi": false, - "name": "cluster", - "options": [ - { - "isNone": true, - "selected": true, - "text": "None", - "value": "" - } - ], - "query": { - "query": "label_values(kube_pod_info, cluster)", - "refId": "StandardVariableQuery" + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": "${datasource}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - "refresh": 0, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 15 + }, + "id": 8, + "options": { + "displayMode": "gradient", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "text": {} + }, + "pluginVersion": "8.0.0", + "targets": [ { - "allValue": null, - "current": { - "selected": false, - "text": "default", - "value": "default" + "exemplar": true, + "expr": "sum by (kind) (opa_scorecard_constraint_violations)", + "format": "time_series", + "interval": "", + "legendFormat": "{{kind}}", + "refId": "A" + } + ], + "title": "Total Violations by kind", + "transformations": [], + "type": "bargauge" + }, + { + "datasource": "${datasource}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - "datasource": "$datasource", - "definition": "", - "description": null, - "error": null, - "hide": 0, - "includeAll": false, - "label": null, - "multi": false, - "name": "namespace", - "options": [], - "query": { - "query": "label_values(kube_pod_info{cluster=\"$cluster\"}, namespace)", - "refId": "Prometheus-namespace-Variable-Query" + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "mappings": [] + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 15 + }, + "id": 6, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "sum(opa_scorecard_constraint_information{enforcementAction=\"dryrun\"})", + "interval": "", + "legendFormat": "enforcementAction=\"dryrun\"", + "refId": "A" + }, + { + "exemplar": true, + "expr": "sum(opa_scorecard_constraint_information{enforcementAction=\"deny\"})", + "hide": false, + "interval": "", + "legendFormat": "enforcementAction=\"deny\"", + "refId": "B" } - ] - }, - "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": "UTC", - "title": "OPA Violations", - "uid": "YBgRZG6Mz", - "version": 23 - } \ No newline at end of file + "title": "Enforcement Actions", + "type": "piechart" + } + ], + "refresh": false, + "schemaVersion": 30, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "default", + "value": "default" + }, + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "datasource", + "options": [], + "query": "prometheus", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "allValue": null, + "current": { + "isNone": true, + "selected": false, + "text": "None", + "value": "" + }, + "datasource": null, + "definition": "label_values(kube_pod_info, cluster)", + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "cluster", + "options": [], + "query": { + "query": "label_values(kube_pod_info, cluster)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "selected": false, + "text": "prometheus", + "value": "prometheus" + }, + "datasource": "$datasource", + "definition": "", + "description": null, + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "namespace", + "options": [], + "query": { + "query": "label_values(kube_pod_info{cluster=\"$cluster\"}, namespace)", + "refId": "Prometheus-namespace-Variable-Query" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-5m", + "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": "UTC", + "title": "OPA Violations", + "uid": "YBgRZG6Mz", + "version": 1 +} \ No newline at end of file diff --git a/kube-prometheus-stack/values.yaml b/kube-prometheus-stack/values.yaml index a27cf99..0caa757 100644 --- a/kube-prometheus-stack/values.yaml +++ b/kube-prometheus-stack/values.yaml @@ -9,3 +9,7 @@ prometheus: - job_name: opa-exporter kubernetes_sd_configs: - role: service + +grafana: + plugins: + - grafana-piechart-panel \ No newline at end of file