1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-30 19:35:06 +00:00

feat: add cluster select and relabling config for ServiceMonitors (#7659)

* feat: add cluster select and relabling config for ServiceMonitors

Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>

* feat: add cluster select and relabling config for ServiceMonitors

Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>

---------

Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
This commit is contained in:
Frank Jogeleit 2023-06-26 16:24:15 +02:00 committed by GitHub
parent e5ceebe4a9
commit 8aef874d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 139 additions and 33 deletions

View file

@ -383,6 +383,8 @@ The chart values are organised per component.
| admissionController.serviceMonitor.scrapeTimeout | string | `"25s"` | Timeout if metrics can't be retrieved in given time interval |
| admissionController.serviceMonitor.secure | bool | `false` | Is TLS required for endpoint |
| admissionController.serviceMonitor.tlsConfig | object | `{}` | TLS Configuration for endpoint |
| admissionController.serviceMonitor.relabelings | list | `[]` | RelabelConfigs to apply to samples before scraping |
| admissionController.serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion. |
| admissionController.tracing.enabled | bool | `false` | Enable tracing |
| admissionController.tracing.address | string | `nil` | Traces receiver address |
| admissionController.tracing.port | string | `nil` | Traces receiver port |
@ -444,6 +446,8 @@ The chart values are organised per component.
| backgroundController.serviceMonitor.scrapeTimeout | string | `"25s"` | Timeout if metrics can't be retrieved in given time interval |
| backgroundController.serviceMonitor.secure | bool | `false` | Is TLS required for endpoint |
| backgroundController.serviceMonitor.tlsConfig | object | `{}` | TLS Configuration for endpoint |
| backgroundController.serviceMonitor.relabelings | list | `[]` | RelabelConfigs to apply to samples before scraping |
| backgroundController.serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion. |
| backgroundController.tracing.enabled | bool | `false` | Enable tracing |
| backgroundController.tracing.address | string | `nil` | Traces receiver address |
| backgroundController.tracing.port | string | `nil` | Traces receiver port |
@ -513,6 +517,8 @@ The chart values are organised per component.
| cleanupController.serviceMonitor.scrapeTimeout | string | `"25s"` | Timeout if metrics can't be retrieved in given time interval |
| cleanupController.serviceMonitor.secure | bool | `false` | Is TLS required for endpoint |
| cleanupController.serviceMonitor.tlsConfig | object | `{}` | TLS Configuration for endpoint |
| cleanupController.serviceMonitor.relabelings | list | `[]` | RelabelConfigs to apply to samples before scraping |
| cleanupController.serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion. |
| cleanupController.tracing.enabled | bool | `false` | Enable tracing |
| cleanupController.tracing.address | string | `nil` | Traces receiver address |
| cleanupController.tracing.port | string | `nil` | Traces receiver port |
@ -578,6 +584,8 @@ The chart values are organised per component.
| reportsController.serviceMonitor.scrapeTimeout | string | `"25s"` | Timeout if metrics can't be retrieved in given time interval |
| reportsController.serviceMonitor.secure | bool | `false` | Is TLS required for endpoint |
| reportsController.serviceMonitor.tlsConfig | object | `{}` | TLS Configuration for endpoint |
| reportsController.serviceMonitor.relabelings | list | `[]` | RelabelConfigs to apply to samples before scraping |
| reportsController.serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion. |
| reportsController.tracing.enabled | bool | `false` | Enable tracing |
| reportsController.tracing.address | string | `nil` | Traces receiver address |
| reportsController.tracing.port | string | `nil` | Traces receiver port |
@ -596,6 +604,7 @@ The chart values are organised per component.
| grafana.configMapName | string | `"{{ include \"kyverno.fullname\" . }}-grafana"` | Configmap name template. |
| grafana.namespace | string | `nil` | Namespace to create the grafana dashboard configmap. If not set, it will be created in the same namespace where the chart is deployed. |
| grafana.annotations | object | `{}` | Grafana dashboard configmap annotations. |
| grafana.labels | object | `{"grafana_dashboard":"1"}` | Grafana dashboard configmap labels |
### Webhooks cleanup

View file

@ -0,0 +1,31 @@
---
admissionController:
serviceMonitor:
enabled: true
relabelings:
- action: labeldrop
regex: container
cleanupController:
serviceMonitor:
enabled: true
relabelings:
- action: labeldrop
regex: container
backgroundController:
serviceMonitor:
enabled: true
relabelings:
- action: labeldrop
regex: container
reportsController:
serviceMonitor:
enabled: true
relabelings:
- action: labeldrop
regex: container
grafana:
enabled: true

View file

@ -129,7 +129,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_results_total{rule_result=\"fail\"}[24h]))*100/sum(increase(kyverno_policy_results_total{}[24h]))",
"expr": "sum(increase(kyverno_policy_results_total{rule_result=\"fail\", cluster=~\"$cluster\"}[24h]))*100/sum(increase(kyverno_policy_results_total{cluster=~\"$cluster\"}[24h]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -186,7 +186,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{policy_type=\"cluster\"}==1) by (policy_name))",
"expr": "count(count(kyverno_policy_rule_info_total{policy_type=\"cluster\",cluster=~\"$cluster\"}==1) by (policy_name))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -244,7 +244,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{policy_type=\"namespaced\"}==1) by (policy_name))",
"expr": "count(count(kyverno_policy_rule_info_total{policy_type=\"namespaced\", cluster=~\"$cluster\"}==1) by (policy_name))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -313,7 +313,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_results_total{rule_result=\"fail\", policy_background_mode=\"true\"}[24h]))*100/sum(increase(kyverno_policy_results_total{policy_background_mode=\"true\"}[24h]))",
"expr": "sum(increase(kyverno_policy_results_total{rule_result=\"fail\", policy_background_mode=\"true\", cluster=~\"$cluster\"}[24h]))*100/sum(increase(kyverno_policy_results_total{policy_background_mode=\"true\", cluster=~\"$cluster\"}[24h]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -370,7 +370,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"validate\"}==1)",
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"validate\", cluster=~\"$cluster\"}==1)",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -428,7 +428,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"mutate\"}==1)",
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"mutate\", cluster=~\"$cluster\"}==1)",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -486,7 +486,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"generate\"}==1)",
"expr": "count(kyverno_policy_rule_info_total{rule_type=\"generate\", cluster=~\"$cluster\"}==1)",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -572,7 +572,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_results_total{rule_execution_cause=\"admission_request\"}[5m])) by (rule_result)",
"expr": "sum(increase(kyverno_policy_results_total{rule_execution_cause=\"admission_request\", cluster=~\"$cluster\"}[5m])) by (rule_result)",
"interval": "",
"legendFormat": "{{rule_result}}",
"refId": "A"
@ -678,7 +678,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_results_total{rule_execution_cause=\"background_scan\"}[5m])) by (rule_result)",
"expr": "sum(increase(kyverno_policy_results_total{rule_execution_cause=\"background_scan\", cluster=~\"$cluster\"}[5m])) by (rule_result)",
"interval": "",
"legendFormat": "{{rule_result}}",
"refId": "A"
@ -785,7 +785,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_result=\"fail\"}[5m])) by (policy_name, policy_type)) by (policy_type)",
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_result=\"fail\", cluster=~\"$cluster\"}[5m])) by (policy_name, policy_type)) by (policy_type)",
"interval": "",
"legendFormat": "{{policy_type}}",
"refId": "A"
@ -891,7 +891,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_execution_cause=\"admission_request\"}[5m])) by (policy_name, rule_result)) by (rule_result)",
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_execution_cause=\"admission_request\", cluster=~\"$cluster\"}[5m])) by (policy_name, rule_result)) by (rule_result)",
"interval": "",
"legendFormat": "{{rule_result}}",
"refId": "A"
@ -997,7 +997,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_execution_cause=\"background_scan\"}[5m])) by (policy_name, rule_result)) by (rule_result)",
"expr": "sum(sum(increase(kyverno_policy_results_total{rule_execution_cause=\"background_scan\", cluster=~\"$cluster\"}[5m])) by (policy_name, rule_result)) by (rule_result)",
"interval": "",
"legendFormat": "{{rule_result}}",
"refId": "A"
@ -1120,7 +1120,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{}==1) by (policy_name, policy_type)) by (policy_type)",
"expr": "count(count(kyverno_policy_rule_info_total{cluster=~\"$cluster\"}==1) by (policy_name, policy_type)) by (policy_type)",
"interval": "",
"legendFormat": "{{policy_type}}",
"refId": "A"
@ -1225,7 +1225,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{}==1) by (policy_name, policy_validation_mode)) by (policy_validation_mode)",
"expr": "count(count(kyverno_policy_rule_info_total{cluster=~\"$cluster\"}==1) by (policy_name, policy_validation_mode)) by (policy_validation_mode)",
"interval": "",
"legendFormat": "audit",
"refId": "A"
@ -1325,7 +1325,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{policy_background_mode=\"true\"}==1) by (policy_name, policy_type)) by (policy_type)",
"expr": "count(count(kyverno_policy_rule_info_total{policy_background_mode=\"true\", cluster=~\"$cluster\"}==1) by (policy_name, policy_type)) by (policy_type)",
"interval": "",
"legendFormat": "{{policy_type}}",
"refId": "A"
@ -1419,7 +1419,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(count(kyverno_policy_rule_info_total{policy_namespace!=\"-\"}==1) by (policy_name, policy_namespace)) by (policy_namespace)",
"expr": "count(count(kyverno_policy_rule_info_total{policy_namespace!=\"-\", cluster=~\"$cluster\"}==1) by (policy_name, policy_namespace)) by (policy_namespace)",
"interval": "",
"legendFormat": "{{policy_namespace}}",
"refId": "A"
@ -1524,7 +1524,7 @@
"targets": [
{
"exemplar": true,
"expr": "count(kyverno_policy_rule_info_total{}==1) by (rule_type)",
"expr": "count(kyverno_policy_rule_info_total{cluster=~\"$cluster\"}==1) by (rule_type)",
"interval": "",
"legendFormat": "{{rule_type}}",
"refId": "A"
@ -1635,7 +1635,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(rate(kyverno_policy_execution_duration_seconds_sum{}[5m])) by (rule_type) / sum(rate(kyverno_policy_execution_duration_seconds_count{}[5m])) by (rule_type)",
"expr": "sum(rate(kyverno_policy_execution_duration_seconds_sum{cluster=~\"$cluster\"}[5m])) by (rule_type) / sum(rate(kyverno_policy_execution_duration_seconds_count{cluster=~\"$cluster\"}[5m])) by (rule_type)",
"interval": "",
"legendFormat": "{{rule_type}}",
"refId": "A"
@ -1739,7 +1739,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(rate(kyverno_policy_execution_duration_seconds_sum{}[5m])) by (policy_type) / sum(rate(kyverno_policy_execution_duration_seconds_count{}[5m])) by (policy_type)",
"expr": "sum(rate(kyverno_policy_execution_duration_seconds_sum{cluster=~\"$cluster\"}[5m])) by (policy_type) / sum(rate(kyverno_policy_execution_duration_seconds_count{cluster=~\"$cluster\"}[5m])) by (policy_type)",
"interval": "",
"legendFormat": "{{policy_type}}",
"refId": "A"
@ -1835,7 +1835,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(kyverno_policy_execution_duration_seconds_sum{}) / sum(kyverno_policy_execution_duration_seconds_count{})",
"expr": "sum(kyverno_policy_execution_duration_seconds_sum{cluster=~\"$cluster\"}) / sum(kyverno_policy_execution_duration_seconds_count{cluster=~\"$cluster\"})",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -1891,7 +1891,7 @@
"targets": [
{
"exemplar": true,
"expr": "avg(sum(kyverno_policy_execution_duration_seconds_sum{}) by (policy_name, policy_type) / sum(kyverno_policy_execution_duration_seconds_count{}) by (policy_name, policy_type))",
"expr": "avg(sum(kyverno_policy_execution_duration_seconds_sum{cluster=~\"$cluster\"}) by (policy_name, policy_type) / sum(kyverno_policy_execution_duration_seconds_count{cluster=~\"$cluster\"}) by (policy_name, policy_type))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -1959,7 +1959,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(rate(kyverno_admission_review_duration_seconds_sum{}[5m])) by (resource_request_operation) / sum(rate(kyverno_admission_review_duration_seconds_count{}[5m])) by (resource_request_operation)",
"expr": "sum(rate(kyverno_admission_review_duration_seconds_sum{cluster=~\"$cluster\"}[5m])) by (resource_request_operation) / sum(rate(kyverno_admission_review_duration_seconds_count{cluster=~\"$cluster\"}[5m])) by (resource_request_operation)",
"interval": "",
"legendFormat": "Resource Operation: {{resource_request_operation}}",
"refId": "A"
@ -2054,7 +2054,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(rate(kyverno_admission_review_duration_seconds_sum{}[5m])) by (resource_kind) / sum(rate(kyverno_admission_review_duration_seconds_count{}[5m])) by (resource_kind)",
"expr": "sum(rate(kyverno_admission_review_duration_seconds_sum{cluster=~\"$cluster\"}[5m])) by (resource_kind) / sum(rate(kyverno_admission_review_duration_seconds_count{cluster=~\"$cluster\"}[5m])) by (resource_kind)",
"interval": "",
"legendFormat": "Resource Kind: {{resource_kind}}",
"refId": "A"
@ -2151,7 +2151,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_admission_requests_total{}[5m]))",
"expr": "sum(increase(kyverno_admission_requests_total{cluster=~\"$cluster\"}[5m]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -2207,7 +2207,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(kyverno_admission_review_duration_seconds_sum{})/sum(kyverno_admission_review_duration_seconds_count{})",
"expr": "sum(kyverno_admission_review_duration_seconds_sum{cluster=~\"$cluster\"})/sum(kyverno_admission_review_duration_seconds_count{cluster=~\"$cluster\"})",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -2285,7 +2285,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_changes_total{}[5m])) by (policy_change_type)",
"expr": "sum(increase(kyverno_policy_changes_total{cluster=~\"$cluster\"}[5m])) by (policy_change_type)",
"interval": "",
"legendFormat": "Change type: {{policy_change_type}}",
"refId": "A"
@ -2389,7 +2389,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_changes_total{}[5m])) by (policy_type)",
"expr": "sum(increase(kyverno_policy_changes_total{cluster=~\"$cluster\"}[5m])) by (policy_type)",
"interval": "",
"legendFormat": "{{policy_type}}",
"refId": "A"
@ -2485,7 +2485,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_policy_changes_total{}[24h]))",
"expr": "sum(increase(kyverno_policy_changes_total{cluster=~\"$cluster\"}[24h]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -2541,7 +2541,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(rate(kyverno_policy_changes_total{}[5m]))",
"expr": "sum(rate(kyverno_policy_changes_total{cluster=~\"$cluster\"}[5m]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -2615,7 +2615,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_admission_requests_total{}[5m])) by (resource_request_operation)",
"expr": "sum(increase(kyverno_admission_requests_total{cluster=~\"$cluster\"}[5m])) by (resource_request_operation)",
"interval": "",
"legendFormat": "Resource Operation: {{resource_request_operation}}",
"refId": "A"
@ -2716,7 +2716,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_admission_requests_total{}[5m])) by (resource_kind)",
"expr": "sum(increase(kyverno_admission_requests_total{cluster=~\"$cluster\"}[5m])) by (resource_kind)",
"interval": "",
"legendFormat": "Resource Kind: {{resource_kind}}",
"refId": "A"
@ -2813,7 +2813,7 @@
"targets": [
{
"exemplar": true,
"expr": "sum(increase(kyverno_admission_requests_total{}[24h]))",
"expr": "sum(increase(kyverno_admission_requests_total{cluster=~\"$cluster\"}[24h]))",
"interval": "",
"legendFormat": "",
"refId": "A"
@ -2839,6 +2839,20 @@
"regex": "",
"type": "datasource"
}
,{
"allValue": ".*",
"datasource": "${DS_PROMETHEUS_KYVERNO}",
"definition": "label_values(kyverno_policy_results_total, cluster)",
"hide": 0,
"includeAll": true,
"label": "Cluster",
"multi": true,
"name": "cluster",
"options": [],
"query": "label_values(kyverno_policy_results_total, cluster)",
"refresh": 2,
"type": "query"
}
]
},
"time": {

View file

@ -29,4 +29,12 @@ spec:
tlsConfig:
{{- toYaml .Values.admissionController.serviceMonitor.tlsConfig | nindent 8 }}
{{- end }}
{{- with .Values.admissionController.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.admissionController.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end -}}

View file

@ -30,5 +30,13 @@ spec:
tlsConfig:
{{- toYaml .Values.backgroundController.serviceMonitor.tlsConfig | nindent 8 }}
{{- end }}
{{- with .Values.backgroundController.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.backgroundController.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end -}}
{{- end -}}

View file

@ -30,5 +30,13 @@ spec:
tlsConfig:
{{- toYaml .Values.cleanupController.serviceMonitor.tlsConfig | nindent 8 }}
{{- end }}
{{- with .Values.cleanupController.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.cleanupController.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end -}}
{{- end -}}

View file

@ -7,7 +7,7 @@ metadata:
annotations:
{{- toYaml .Values.grafana.annotations | nindent 4 }}
labels:
grafana_dashboard: "1"
{{- toYaml .Values.grafana.labels | nindent 4 }}
data:
{{ (.Files.Glob "grafana/*").AsConfig | indent 2 }}
{{- end -}}

View file

@ -30,5 +30,13 @@ spec:
tlsConfig:
{{- toYaml .Values.reportsController.serviceMonitor.tlsConfig | nindent 8 }}
{{- end }}
{{- with .Values.reportsController.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.reportsController.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end -}}
{{- end -}}

View file

@ -322,6 +322,10 @@ grafana:
# -- Grafana dashboard configmap annotations.
annotations: {}
# -- Grafana dashboard configmap labels
labels:
grafana_dashboard: "1"
# Features configuration
features:
admissionReports:
@ -817,6 +821,10 @@ admissionController:
secure: false
# -- TLS Configuration for endpoint
tlsConfig: {}
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion.
metricRelabelings: []
tracing:
# -- Enable tracing
@ -1032,6 +1040,10 @@ backgroundController:
secure: false
# -- TLS Configuration for endpoint
tlsConfig: {}
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion.
metricRelabelings: []
tracing:
# -- Enable tracing
@ -1300,6 +1312,10 @@ cleanupController:
secure: false
# -- TLS Configuration for endpoint
tlsConfig: {}
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion.
metricRelabelings: []
tracing:
# -- Enable tracing
@ -1535,6 +1551,10 @@ reportsController:
secure: false
# -- TLS Configuration for endpoint
tlsConfig: {}
# -- RelabelConfigs to apply to samples before scraping
relabelings: []
# -- MetricRelabelConfigs to apply to samples before ingestion.
metricRelabelings: []
tracing:
# -- Enable tracing