Skip to content

Commit

Permalink
Helm: Allow label customization for servicemonitor (#113)
Browse files Browse the repository at this point in the history
eg.
``` yaml
serviceMonitor:
  additionalLabels:
    release: kube-prometheus-stack
```

Co-authored-by: Martin Helmich <[email protected]>
  • Loading branch information
LukeHandle and martin-helmich authored Jan 5, 2022
1 parent 2152476 commit 51d20ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions chart/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{{- if .Values.serviceMonitor -}}
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "kube-httpcache.fullname" . }}
labels:
{{- include "kube-httpcache.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "kube-httpcache.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
path: /metrics
interval: 10s
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end}}
10 changes: 9 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ rbac:
enabled: true

# create a prometheus operator ServiceMonitor
serviceMonitor: false
serviceMonitor:
enabled: false

additionalLabels: {}
## Scrape interval. If not set, the Prometheus default scrape interval is used.
interval: 10s
## Scrape Timeout. If not set, the Prometheus default scrape timeout is used.
scrapeTimeout: ""


podSecurityPolicy:
enabled: false
Expand Down

0 comments on commit 51d20ba

Please sign in to comment.