diff --git a/charts/alertmanager/Chart.yaml b/charts/alertmanager/Chart.yaml index 87e3b80a45e0..710bbd216a6f 100644 --- a/charts/alertmanager/Chart.yaml +++ b/charts/alertmanager/Chart.yaml @@ -6,7 +6,7 @@ icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/a sources: - https://github.com/prometheus/alertmanager type: application -version: 1.8.2 +version: 1.8.3 appVersion: v0.26.0 kubeVersion: ">=1.19.0-0" keywords: diff --git a/charts/alertmanager/templates/_helpers.tpl b/charts/alertmanager/templates/_helpers.tpl index 827b6ee9f7da..1d6f69a2c0af 100644 --- a/charts/alertmanager/templates/_helpers.tpl +++ b/charts/alertmanager/templates/_helpers.tpl @@ -90,3 +90,22 @@ Allow overriding alertmanager namespace {{- .Release.Namespace -}} {{- end -}} {{- end -}} + +{{/* Sets default scrape limits for servicemonitor */}} +{{- define "servicemonitor.scrapeLimits" -}} +{{- with .sampleLimit }} +sampleLimit: {{ . }} +{{- end }} +{{- with .targetLimit }} +targetLimit: {{ . }} +{{- end }} +{{- with .labelLimit }} +labelLimit: {{ . }} +{{- end }} +{{- with .labelNameLengthLimit }} +labelNameLengthLimit: {{ . }} +{{- end }} +{{- with .labelValueLengthLimit }} +labelValueLengthLimit: {{ . }} +{{- end }} +{{- end }} diff --git a/charts/alertmanager/templates/servicemonitor.yaml b/charts/alertmanager/templates/servicemonitor.yaml new file mode 100644 index 000000000000..74a4650104dc --- /dev/null +++ b/charts/alertmanager/templates/servicemonitor.yaml @@ -0,0 +1,64 @@ +{{- if .Values.prometheus.monitor.enabled }} +{{- $apiVersion := .Values.prometheus.monitor.apiVersion | default "monitoring.coreos.com/v1" }} +{{- if .Capabilities.APIVersions.Has (printf "%s/ServiceMonitor" $apiVersion) }} +apiVersion: {{ $apiVersion }} +kind: ServiceMonitor +metadata: + name: {{ include "alertmanager.fullname" . }} + namespace: {{ include "alertmanager.namespace" . }} + labels: + {{- include "alertmanager.labels" . | nindent 4 }} + {{- with .Values.prometheus.monitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + jobLabel: {{ default "app.kubernetes.io/name" .Values.prometheus.monitor.jobLabel }} + {{- include "servicemonitor.scrapeLimits" .Values.prometheus.monitor | nindent 2 }} + {{- with .Values.prometheus.monitor.podTargetLabels }} + podTargetLabels: + {{- toYaml . | nindent 4 }} + {{- end }} + selector: + matchLabels: + {{- with .Values.prometheus.monitor.selectorOverride }} + {{- toYaml . | nindent 6 }} + {{- else }} + {{- include "alertmanager.selectorLabels" . | nindent 6 }} + {{- end }} + {{- with .Values.prometheus.monitor.attachMetadata }} + attachMetadata: + {{- toYaml . | nindent 4 }} + {{- end }} + endpoints: + - port: http + scheme: {{ .Values.prometheus.monitor.scheme }} + {{- with .Values.prometheus.monitor.basicAuth }} + basicAuth: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.prometheus.monitor.bearerTokenFile }} + bearerTokenFile: {{ . }} + {{- end }} + {{- with .Values.prometheus.monitor.tlsConfig }} + tlsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.prometheus.monitor.proxyUrl }} + proxyUrl: {{ . }} + {{- end }} + {{- with .Values.prometheus.monitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.prometheus.monitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + {{- with .Values.prometheus.monitor.relabelings }} + relabelings: + {{- tpl (toYaml .) $ | nindent 8 }} + {{- end }} + {{- with .Values.prometheus.monitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/alertmanager/values.schema.json b/charts/alertmanager/values.schema.json index 1cab60e23bbf..eaee15540322 100644 --- a/charts/alertmanager/values.schema.json +++ b/charts/alertmanager/values.schema.json @@ -143,7 +143,11 @@ "type": "string" }, "global": { - "properties": {}, + "properties": { + "imagePullSecrets": { + "type": "array" + } + }, "type": "object" }, "hostAliases": { @@ -338,6 +342,105 @@ "priorityClassName": { "type": "string" }, + "prometheus": { + "properties": { + "monitor": { + "properties": { + "additionalLabels": { + "properties": { + "app.kubernetes.io/vendor": { + "type": "string" + } + }, + "type": "object" + }, + "apiVersion": { + "type": "string" + }, + "attachMetadata": { + "properties": {}, + "type": "object" + }, + "basicAuth": { + "properties": {}, + "type": "object" + }, + "bearerTokenFile": { + "type": "null" + }, + "enabled": { + "type": "boolean" + }, + "interval": { + "type": "string" + }, + "jobLabel": { + "type": "string" + }, + "labelLimit": { + "type": "integer" + }, + "labelNameLengthLimit": { + "type": "integer" + }, + "labelValueLengthLimit": { + "type": "integer" + }, + "metricRelabelings": { + "type": "array" + }, + "podTargetLabels": { + "type": "array" + }, + "proxyUrl": { + "type": "string" + }, + "relabelings": { + "items": { + "properties": { + "action": { + "type": "string" + }, + "regex": { + "type": "string" + }, + "sourceLabels": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "type": "array" + }, + "sampleLimit": { + "type": "integer" + }, + "scheme": { + "type": "string" + }, + "scrapeTimeout": { + "type": "string" + }, + "selectorOverride": { + "properties": {}, + "type": "object" + }, + "targetLimit": { + "type": "integer" + }, + "tlsConfig": { + "properties": {}, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, "readinessProbe": { "properties": { "httpGet": { diff --git a/charts/alertmanager/values.yaml b/charts/alertmanager/values.yaml index 185eb9b74b26..230578c5f24f 100644 --- a/charts/alertmanager/values.yaml +++ b/charts/alertmanager/values.yaml @@ -375,3 +375,64 @@ testFramework: annotations: "helm.sh/hook": test-success # "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" + +prometheus: + monitor: + enabled: true + + additionalLabels: + app.kubernetes.io/vendor: kubesphere + + jobLabel: "" + + # List of pod labels to add to node exporter metrics + # https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitor + podTargetLabels: [] + + scheme: http + basicAuth: {} + bearerTokenFile: + tlsConfig: {} + + ## proxyUrl: URL of a proxy that should be used for scraping. + ## + proxyUrl: "" + + ## Override serviceMonitor selector + ## + selectorOverride: {} + + ## Attach node metadata to discovered targets. Requires Prometheus v2.35.0 and above. + ## + attachMetadata: {} + + relabelings: + - sourceLabels: + - service + regex: '^{{ include "alertmanager.fullname" . }}-headless$' + action: keep + metricRelabelings: [] + interval: "" + scrapeTimeout: 10s + ## prometheus.monitor.apiVersion ApiVersion for the serviceMonitor Resource(defaults to "monitoring.coreos.com/v1") + apiVersion: "" + + ## SampleLimit defines per-scrape limit on number of scraped samples that will be accepted. + ## + sampleLimit: 0 + + ## TargetLimit defines a limit on the number of scraped targets that will be accepted. + ## + targetLimit: 0 + + ## Per-scrape limit on number of labels that will be accepted for a sample. Only valid in Prometheus versions 2.27.0 and newer. + ## + labelLimit: 0 + + ## Per-scrape limit on length of labels name that will be accepted for a sample. Only valid in Prometheus versions 2.27.0 and newer. + ## + labelNameLengthLimit: 0 + + ## Per-scrape limit on length of labels value that will be accepted for a sample. Only valid in Prometheus versions 2.27.0 and newer. + ## + labelValueLengthLimit: 0