Skip to content

Commit

Permalink
fix(monitoring): add cluster labeling to single binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Umaaz committed Oct 10, 2023
1 parent 1785839 commit 7bfa5e8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/deep-distributed/templates/lib/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ include "deep.clusterName" $.ctx}}"
targetLabel: cluster
targetLabel: "{{ .clusterLabel }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/deep/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ spec:
replacement: "{{ include "deep.fullname" $ }}"
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ include "deep.clusterName" $.ctx}}"
targetLabel: cluster
- replacement: "{{ include "deep.clusterName" $ }}"
targetLabel: "{{ .clusterLabel }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
Expand Down
46 changes: 46 additions & 0 deletions charts/deep/unittests/serviceMonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
suite: test service monitor
chart:
version: 9.9.9+test
appVersion: 1.1.1+test
release:
name: deep
set:
monitoring:
enabled: true
serviceMonitor:
namespace: monitoring
labels:
release: prometheus
tests:
- it: should create correct servicemonitor
template: serviceMonitor.yaml
asserts:
- isKind:
of: ServiceMonitor
- matchRegex:
path: metadata.name
pattern: deep
- it: should have cluster label
template: serviceMonitor.yaml
asserts:
- equal:
path: spec.endpoints[0].relabelings[1].replacement
value: deep
- equal:
path: spec.endpoints[0].relabelings[1].targetLabel
value: cluster
- it: cluster label should use config
set:
config:
clusterName: "fromconfig"
monitoring:
serviceMonitor:
clusterLabel: "labelfromconfig"
template: serviceMonitor.yaml
asserts:
- equal:
path: spec.endpoints[0].relabelings[1].replacement
value: fromconfig
- equal:
path: spec.endpoints[0].relabelings[1].targetLabel
value: labelfromconfig

0 comments on commit 7bfa5e8

Please sign in to comment.