Skip to content

Commit 837ae39

Browse files
ido177k.romanikhin
authored andcommitted
add statsd service monitor into helm chart
1 parent d65ff01 commit 837ae39

8 files changed

Lines changed: 1581 additions & 1 deletion

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ repos:
541541
^docs/apache-airflow-providers-amazon/secrets-backends/aws-ssm-parameter-store\.rst$|
542542
git|
543543
^helm-tests/tests/chart_utils/helm_template_generator\.py$|
544+
^helm-tests/tests/chart_utils/ingress-networking-v1beta1\.json$|
545+
^helm-tests/tests/chart_utils/servicemonitor-monitoring-v1\.yaml$|
544546
package-lock\.json$|
545547
^.*\.(png|gif|jp[e]?g|svg|tgz|lock)$|
546548
^\.pre-commit-config\.yaml$|

airflow-core/tests/unit/charts/helm_template_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
crd_lookup = {
4444
"keda.sh/v1alpha1::ScaledObject": "https://raw.githubusercontent.com/kedacore/keda/v2.0.0/config/crd/bases/keda.sh_scaledobjects.yaml",
45+
"monitoring.coreos.com/v1::ServiceMonitor": "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/heads/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml",
4546
# This object type was removed in k8s v1.22.0
4647
"networking.k8s.io/v1beta1::Ingress": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.21.0/ingress-networking-v1beta1.json",
4748
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/}}
19+
20+
######################################
21+
## Airflow Statsd ServiceMonitor
22+
######################################
23+
{{- if and .Values.statsd.enabled .Values.statsd.serviceMonitor.enabled }}
24+
apiVersion: monitoring.coreos.com/v1
25+
kind: ServiceMonitor
26+
metadata:
27+
name: {{ include "airflow.fullname" . }}-statsd
28+
namespace: {{ default .Release.Namespace .Values.statsd.serviceMonitor.namespace | quote }}
29+
labels:
30+
tier: airflow
31+
component: statsd-service-monitor
32+
release: {{ .Release.Name }}
33+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
34+
heritage: {{ .Release.Service }}
35+
app.kubernetes.io/component: metrics
36+
{{- with .Values.statsd.serviceMonitor.labels }}
37+
{{- toYaml . | nindent 4 }}
38+
{{- end }}
39+
spec:
40+
endpoints:
41+
- path: /metrics
42+
honorLabels: {{ .Values.statsd.serviceMonitor.honorLabels }}
43+
port: statsd-scrape
44+
{{- if .Values.statsd.serviceMonitor.interval }}
45+
interval: {{ .Values.statsd.serviceMonitor.interval }}
46+
{{- end }}
47+
{{- if .Values.statsd.serviceMonitor.scrapeTimeout }}
48+
scrapeTimeout: {{ .Values.statsd.serviceMonitor.scrapeTimeout }}
49+
{{- end }}
50+
selector:
51+
matchLabels:
52+
tier: airflow
53+
component: statsd
54+
namespaceSelector:
55+
matchNames:
56+
- {{ .Release.Namespace }}
57+
{{- end }}

chart/values.schema.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8092,6 +8092,50 @@
80928092
],
80938093
"additionalProperties": false
80948094
}
8095+
},
8096+
"serviceMonitor": {
8097+
"description": "ServiceMonitor configuration for Prometheus scraping of StatsD metrics.",
8098+
"type": "object",
8099+
"x-docsSection": "Kubernetes",
8100+
"properties": {
8101+
"enabled": {
8102+
"description": "Enables creation of a ServiceMonitor for StatsD metrics scraping.",
8103+
"type": "boolean",
8104+
"default": false
8105+
},
8106+
"honorLabels": {
8107+
"description": "If true, keeps original metric labels as exported by the app. If false, Prometheus may override them.",
8108+
"type": "boolean",
8109+
"default": true
8110+
},
8111+
"interval": {
8112+
"description": "Scrape interval for Prometheus (e.g., 30s, 1m, etc.).",
8113+
"type": "string",
8114+
"default": "10s"
8115+
},
8116+
"scrapeTimeout": {
8117+
"description": "Timeout for the metrics scrape request.",
8118+
"type": "string",
8119+
"default": ""
8120+
},
8121+
"labels": {
8122+
"description": "Additional labels to attach to the ServiceMonitor object.",
8123+
"type": "object",
8124+
"default": {},
8125+
"additionalProperties": {
8126+
"type": "string"
8127+
}
8128+
},
8129+
"namespace": {
8130+
"description": "Namespace where the ServiceMonitor will be created. If not set, defaults to .Release.Namespace.",
8131+
"type": [
8132+
"string",
8133+
"null"
8134+
],
8135+
"default": null
8136+
}
8137+
},
8138+
"additionalProperties": false
80958139
}
80968140
}
80978141
},

chart/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,28 @@ statsd:
27102710
# Environment variables to add to statsd container
27112711
env: []
27122712

2713+
# StatsD Service Monitor
2714+
serviceMonitor:
2715+
# Enables creation of a ServiceMonitor for StatsD metrics scraping.
2716+
enabled: false
2717+
2718+
# If true, keeps original metric labels as exported by the app.
2719+
# If false, Prometheus may override them.
2720+
honorLabels: true
2721+
2722+
# Scrape interval for Prometheus (e.g., 30s, 1m, etc.).
2723+
interval: 10s
2724+
2725+
# Timeout for the metrics scrape request.
2726+
scrapeTimeout: ""
2727+
2728+
# Additional labels to attach to the ServiceMonitor object.
2729+
labels: {}
2730+
2731+
# (Optional) Namespace where the ServiceMonitor will be created.
2732+
# If not set, defaults to .Release.Namespace.
2733+
# namespace: "monitoring"
2734+
27132735
# PgBouncer settings
27142736
pgbouncer:
27152737
# Enable PgBouncer

helm-tests/tests/chart_utils/helm_template_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747

4848
crd_lookup = {
4949
# https://raw.githubusercontent.com/kedacore/keda/v2.0.0/config/crd/bases/keda.sh_scaledobjects.yaml
50-
"keda.sh/v1alpha1::ScaledObject": f"{MY_DIR.as_posix()}/keda.sh_scaledobjects.yaml"
50+
"keda.sh/v1alpha1::ScaledObject": f"{MY_DIR.as_posix()}/keda.sh_scaledobjects.yaml",
51+
# https://github.com/prometheus-operator/prometheus-operator/blob/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
52+
"monitoring.coreos.com/v1::ServiceMonitor": f"{MY_DIR.as_posix()}/servicemonitor-monitoring-v1.yaml",
5153
}
5254

5355

0 commit comments

Comments
 (0)