From d5a2b0b79237434437c30756d51017d740883e48 Mon Sep 17 00:00:00 2001
From: Minh Danh <minhdanh.ngo@gmail.com>
Date: Mon, 26 Aug 2019 11:39:53 +0700
Subject: [PATCH] Add support for additional labels and scrapeTimeout for
 serviceMonitors

---
 production/helm/loki/templates/servicemonitor.yaml     | 6 ++++++
 production/helm/loki/values.yaml                       | 2 ++
 production/helm/promtail/Chart.yaml                    | 2 +-
 production/helm/promtail/templates/servicemonitor.yaml | 6 ++++++
 production/helm/promtail/values.yaml                   | 2 ++
 5 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/production/helm/loki/templates/servicemonitor.yaml b/production/helm/loki/templates/servicemonitor.yaml
index 191c0852..44358327 100644
--- a/production/helm/loki/templates/servicemonitor.yaml
+++ b/production/helm/loki/templates/servicemonitor.yaml
@@ -8,6 +8,9 @@ metadata:
     chart: {{ template "loki.chart" . }}
     release: {{ .Release.Name }}
     heritage: {{ .Release.Service }}
+    {{- if .Values.serviceMonitor.additionalLabels }}
+{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4 }}
+    {{- end }}
 spec:
   selector:
     matchLabels:
@@ -21,4 +24,7 @@ spec:
     {{- if .Values.serviceMonitor.interval }}
     interval: {{ .Values.serviceMonitor.interval }}
     {{- end }}
+    {{- if .Values.serviceMonitor.scrapeTimeout }}
+    scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
+    {{- end }}
 {{- end }}
diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml
index 603bac50..826e5ca7 100644
--- a/production/helm/loki/values.yaml
+++ b/production/helm/loki/values.yaml
@@ -169,3 +169,5 @@ updateStrategy:
 serviceMonitor:
   enabled: false
   interval: ""
+  additionalLabels: {}
+  # scrapeTimeout: 10s
diff --git a/production/helm/promtail/Chart.yaml b/production/helm/promtail/Chart.yaml
index cbd5bb21..e0d24bea 100644
--- a/production/helm/promtail/Chart.yaml
+++ b/production/helm/promtail/Chart.yaml
@@ -1,5 +1,5 @@
 name: promtail
-version: 0.12.0
+version: 0.12.1
 appVersion: v0.3.0
 kubeVersion: "^1.10.0-0"
 description: "Responsible for gathering logs and sending them to Loki"
diff --git a/production/helm/promtail/templates/servicemonitor.yaml b/production/helm/promtail/templates/servicemonitor.yaml
index cd3fe027..43f8aac8 100644
--- a/production/helm/promtail/templates/servicemonitor.yaml
+++ b/production/helm/promtail/templates/servicemonitor.yaml
@@ -8,6 +8,9 @@ metadata:
     chart: {{ template "promtail.chart" . }}
     release: {{ .Release.Name }}
     heritage: {{ .Release.Service }}
+    {{- if .Values.serviceMonitor.additionalLabels }}
+{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4 }}
+    {{- end }}
 spec:
   selector:
     matchLabels:
@@ -21,4 +24,7 @@ spec:
     {{- if .Values.serviceMonitor.interval }}
     interval: {{ .Values.serviceMonitor.interval }}
     {{- end }}
+    {{- if .Values.serviceMonitor.scrapeTimeout }}
+    scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
+    {{- end }}
 {{- end }}
diff --git a/production/helm/promtail/values.yaml b/production/helm/promtail/values.yaml
index 52373505..43559f14 100644
--- a/production/helm/promtail/values.yaml
+++ b/production/helm/promtail/values.yaml
@@ -128,3 +128,5 @@ config:
 serviceMonitor:
   enabled: false
   interval: ""
+  additionalLabels: {}
+  # scrapeTimeout: 10s
-- 
GitLab