Chart: Implement ServiceMonitor limits. (#12251)

This commit is contained in:
yypastushenko 2024-10-30 00:49:25 +02:00 committed by GitHub
parent d0a04308c8
commit 260976b8d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 80 additions and 0 deletions

View file

@ -399,12 +399,17 @@ metadata:
| controller.metrics.serviceMonitor.additionalLabels | object | `{}` | |
| controller.metrics.serviceMonitor.annotations | object | `{}` | Annotations to be added to the ServiceMonitor. |
| controller.metrics.serviceMonitor.enabled | bool | `false` | |
| controller.metrics.serviceMonitor.labelLimit | int | `0` | Per-scrape limit on number of labels that will be accepted for a sample. |
| controller.metrics.serviceMonitor.labelNameLengthLimit | int | `0` | Per-scrape limit on length of labels name that will be accepted for a sample. |
| controller.metrics.serviceMonitor.labelValueLengthLimit | int | `0` | Per-scrape limit on length of labels value that will be accepted for a sample. |
| controller.metrics.serviceMonitor.metricRelabelings | list | `[]` | |
| controller.metrics.serviceMonitor.namespace | string | `""` | |
| controller.metrics.serviceMonitor.namespaceSelector | object | `{}` | |
| controller.metrics.serviceMonitor.relabelings | list | `[]` | |
| controller.metrics.serviceMonitor.sampleLimit | int | `0` | Defines a per-scrape limit on the number of scraped samples that will be accepted. |
| controller.metrics.serviceMonitor.scrapeInterval | string | `"30s"` | |
| controller.metrics.serviceMonitor.targetLabels | list | `[]` | |
| controller.metrics.serviceMonitor.targetLimit | int | `0` | Defines a limit on the number of scraped targets that will be accepted. |
| controller.minAvailable | int | `1` | Minimum available pods set in PodDisruptionBudget. Define either 'minAvailable' or 'maxUnavailable', never both. |
| controller.minReadySeconds | int | `0` | `minReadySeconds` to avoid killing pods before we are ready # |
| controller.name | string | `"controller"` | |

View file

@ -47,4 +47,19 @@ spec:
{{- if .Values.controller.metrics.serviceMonitor.targetLabels }}
targetLabels: {{ toYaml .Values.controller.metrics.serviceMonitor.targetLabels | nindent 2 }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.labelLimit }}
labelLimit: {{ .Values.controller.metrics.serviceMonitor.labelLimit }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.labelNameLengthLimit }}
labelNameLengthLimit: {{ .Values.controller.metrics.serviceMonitor.labelNameLengthLimit }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.labelValueLengthLimit }}
labelValueLengthLimit: {{ .Values.controller.metrics.serviceMonitor.labelValueLengthLimit }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.sampleLimit }}
sampleLimit: {{ .Values.controller.metrics.serviceMonitor.sampleLimit }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.targetLimit }}
targetLimit: {{ .Values.controller.metrics.serviceMonitor.targetLimit }}
{{- end }}
{{- end }}

View file

@ -27,3 +27,53 @@ tests:
path: metadata.annotations
value:
my-little-annotation: test-value
- it: should create a ServiceMonitor with `labelLimit` if `controller.metrics.serviceMonitor.labelLimit` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.labelLimit: 20
asserts:
- equal:
path: spec.labelLimit
value: 20
- it: should create a ServiceMonitor with `labelNameLengthLimit` if `controller.metrics.serviceMonitor.labelNameLengthLimit` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.labelNameLengthLimit: 50
asserts:
- equal:
path: spec.labelNameLengthLimit
value: 50
- it: should create a ServiceMonitor with `labelValueLengthLimit` if `controller.metrics.serviceMonitor.labelValueLengthLimit` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.labelValueLengthLimit: 50
asserts:
- equal:
path: spec.labelValueLengthLimit
value: 50
- it: should create a ServiceMonitor with `sampleLimit` if `controller.metrics.serviceMonitor.sampleLimit` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.sampleLimit: 5000
asserts:
- equal:
path: spec.sampleLimit
value: 5000
- it: should create a ServiceMonitor with `targetLimit` if `controller.metrics.serviceMonitor.targetLimit` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.targetLimit: 100
asserts:
- equal:
path: spec.targetLimit
value: 100

View file

@ -882,6 +882,16 @@ controller:
targetLabels: []
relabelings: []
metricRelabelings: []
# -- Per-scrape limit on number of labels that will be accepted for a sample.
labelLimit: 0
# -- Per-scrape limit on length of labels name that will be accepted for a sample.
labelNameLengthLimit: 0
# -- Per-scrape limit on length of labels value that will be accepted for a sample.
labelValueLengthLimit: 0
# -- Defines a per-scrape limit on the number of scraped samples that will be accepted.
sampleLimit: 0
# -- Defines a limit on the number of scraped targets that will be accepted.
targetLimit: 0
prometheusRule:
enabled: false
additionalLabels: {}