diff --git a/config/grafana/dashboard.json b/config/grafana/dashboard.json new file mode 100644 index 00000000..6ca78a18 --- /dev/null +++ b/config/grafana/dashboard.json @@ -0,0 +1,921 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "8.0.1" + }, + { + "type": "panel", + "id": "heatmap", + "name": "Heatmap", + "version": "" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], + "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": null, + "iteration": 1624217784640, + "links": [], + "panels": [ + { + "cards": { + "cardPadding": null, + "cardRound": null + }, + "color": { + "cardColor": "#b4ff00", + "colorScale": "sqrt", + "colorScheme": "interpolateOranges", + "exponent": 0.5, + "mode": "spectrum" + }, + "dataFormat": "timeseries", + "datasource": "${DS_PROMETHEUS}", + "description": "", + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "heatmap": {}, + "hideZeroBuckets": false, + "highlightCards": true, + "id": 21, + "legend": { + "show": false + }, + "maxPerRow": 2, + "pluginVersion": "8.0.1", + "repeat": "controller_name", + "repeatDirection": "h", + "reverseYBuckets": false, + "targets": [ + { + "exemplar": false, + "expr": "sum by (le) (increase(workqueue_work_duration_seconds_bucket{service=\"capsule-controller-manager-metrics-service\",name=\"$controller_name\"}[1m]))", + "hide": false, + "interval": "", + "legendFormat": "", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "$controller_name reconcile latency", + "tooltip": { + "show": true, + "showHistogram": false + }, + "type": "heatmap", + "xAxis": { + "show": true + }, + "xBucketNumber": null, + "xBucketSize": null, + "yAxis": { + "decimals": null, + "format": "ms", + "logBase": 1, + "max": null, + "min": null, + "show": true, + "splitFactor": null + }, + "yBucketBound": "auto", + "yBucketNumber": null, + "yBucketSize": null + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 17, + "panels": [], + "title": "Requests", + "type": "row" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 17 + }, + "id": 22, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": false, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"200\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "200", + "queryType": "randomWalk", + "refId": "A" + }, + { + "exemplar": false, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"201\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "201", + "queryType": "randomWalk", + "refId": "E" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"403\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "403", + "queryType": "randomWalk", + "refId": "B" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"409\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "409", + "queryType": "randomWalk", + "refId": "C" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"500\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "500", + "queryType": "randomWalk", + "refId": "D" + } + ], + "title": "Rate & Errors", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 17 + }, + "id": 19, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": false, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"200\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "200", + "queryType": "randomWalk", + "refId": "A" + }, + { + "exemplar": false, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"201\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "201", + "queryType": "randomWalk", + "refId": "B" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"403\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "403", + "queryType": "randomWalk", + "refId": "C" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"409\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "409", + "queryType": "randomWalk", + "refId": "D" + }, + { + "exemplar": true, + "expr": "sum(rate(rest_client_requests_total{service=\"capsule-controller-manager-metrics-service\",code=\"500\"}[30s]))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "500", + "queryType": "randomWalk", + "refId": "E" + } + ], + "title": "Rate & Errors", + "type": "stat" + }, + { + "cards": { + "cardPadding": null, + "cardRound": null + }, + "color": { + "cardColor": "#b4ff00", + "colorScale": "sqrt", + "colorScheme": "interpolateOranges", + "exponent": 0.5, + "mode": "spectrum" + }, + "dataFormat": "timeseries", + "datasource": "${DS_PROMETHEUS}", + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 28 + }, + "heatmap": {}, + "hideZeroBuckets": false, + "highlightCards": true, + "id": 20, + "legend": { + "show": false + }, + "pluginVersion": "8.0.1", + "reverseYBuckets": false, + "targets": [ + { + "exemplar": false, + "expr": "sum by (le) (increase(rest_client_request_latency_seconds_bucket{service=\"capsule-controller-manager-metrics-service\"}[1m]))", + "hide": false, + "interval": "", + "legendFormat": "{{le}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Client Operator Latency", + "tooltip": { + "show": true, + "showHistogram": false + }, + "type": "heatmap", + "xAxis": { + "show": true + }, + "xBucketNumber": null, + "xBucketSize": null, + "yAxis": { + "decimals": null, + "format": "ms", + "logBase": 1, + "max": null, + "min": null, + "show": true, + "splitFactor": null + }, + "yBucketBound": "auto", + "yBucketNumber": null, + "yBucketSize": null + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 12, + "panels": [], + "title": "Saturation", + "type": "row" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 36 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "rate(process_cpu_seconds_total{service=\"capsule-controller-manager-metrics-service\"}[1m])", + "interval": "", + "legendFormat": "{{pod}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "CPU Usage", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 1, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 9, + "y": 36 + }, + "id": 24, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": false, + "expr": "process_resident_memory_bytes{service=\"capsule-controller-manager-metrics-service\"}", + "interval": "", + "legendFormat": "{{pod}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Memory Usage", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 3, + "x": 18, + "y": 36 + }, + "id": 5, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": { + "valueSize": 80 + }, + "textMode": "value_and_name" + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": true, + "expr": "sum(up{service=\"capsule-controller-manager-metrics-service\"})", + "interval": "", + "legendFormat": "Active Controllers", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Stats", + "transparent": true, + "type": "stat" + }, + { + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 44 + }, + "id": 10, + "title": "Workqueue", + "type": "row" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "service time to complete needed actions", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 45 + }, + "id": 7, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": true, + "expr": "histogram_quantile(0.99, sum(rate(workqueue_queue_duration_seconds_bucket{service=\"capsule-controller-manager-metrics-service\"}[1m])) by (instance, name, le))", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Workqueue latency", + "type": "stat" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "number of actions per unit time", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 45 + }, + "id": 8, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": true, + "expr": "sum(rate(workqueue_adds_total{service=\"capsule-controller-manager-metrics-service\"}[1m])) by (instance, name)", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Workqueue rate", + "type": "stat" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "number of actions waiting in the queue to be performed", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 16, + "y": 45 + }, + "id": 13, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.0.1", + "targets": [ + { + "exemplar": false, + "expr": "sum(rate(workqueue_depth{service=\"capsule-controller-manager-metrics-service\"}[1m])) by (instance, name)", + "format": "time_series", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "queryType": "randomWalk", + "refId": "A" + } + ], + "title": "Workqueue depth", + "type": "stat" + } + ], + "refresh": "1m", + "schemaVersion": 30, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(workqueue_work_duration_seconds_bucket{service=\"capsule-controller-manager-metrics-service\"},name)", + "description": null, + "error": null, + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "controller_name", + "options": [], + "query": { + "query": "label_values(workqueue_work_duration_seconds_bucket{service=\"capsule-controller-manager-metrics-service\"},name)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "capsule", + "uid": "nEFvaoR7z", + "version": 28 + } \ No newline at end of file diff --git a/config/prometheus/role.yaml b/config/prometheus/role.yaml new file mode 100644 index 00000000..cc789363 --- /dev/null +++ b/config/prometheus/role.yaml @@ -0,0 +1,18 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + control-plane: controller-manager + name: capsule-metrics-role + namespace: capsule-system +rules: +- apiGroups: + - "" + resources: + - services + - endpoints + - pods + verbs: + - get + - list + - watch diff --git a/config/prometheus/rolebinding.yaml b/config/prometheus/rolebinding.yaml new file mode 100644 index 00000000..b5c57a56 --- /dev/null +++ b/config/prometheus/rolebinding.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + control-plane: controller-manager + name: capsule-metrics-rolebinding + namespace: system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: capsule-metrics-role +subjects: +- kind: ServiceAccount + name: capsule + namespace: capsule-system