Skip to content

Commit

Permalink
Chart: Implement ServiceMonitor limits. (#12251)
Browse files Browse the repository at this point in the history
  • Loading branch information
yypastushenko authored Oct 29, 2024
1 parent d0a0430 commit 260976b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
5 changes: 5 additions & 0 deletions charts/ingress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"` | |
Expand Down
15 changes: 15 additions & 0 deletions charts/ingress-nginx/templates/controller-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
50 changes: 50 additions & 0 deletions charts/ingress-nginx/tests/controller-servicemonitor_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions charts/ingress-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down

0 comments on commit 260976b

Please sign in to comment.