From d62c5c2875ca1b697cbdbfd939f5a76aca7933f1 Mon Sep 17 00:00:00 2001 From: Piotr Szwed Date: Sun, 14 Jun 2020 19:11:23 +0200 Subject: [PATCH 1/3] Added ServiceMonitor/Prometheus Operator support as like in fluent-bit package --- .../templates/fluent-bit-configmap.yaml | 5 +++ .../templates/fluent-bit-service.yaml | 30 ++++++++++++++++ .../templates/fluent-bit-servicemonitor.yaml | 34 +++++++++++++++++++ charts/humio-fluentbit/values.yaml | 19 +++++++++++ 4 files changed, 88 insertions(+) create mode 100644 charts/humio-fluentbit/templates/fluent-bit-service.yaml create mode 100644 charts/humio-fluentbit/templates/fluent-bit-servicemonitor.yaml diff --git a/charts/humio-fluentbit/templates/fluent-bit-configmap.yaml b/charts/humio-fluentbit/templates/fluent-bit-configmap.yaml index ad31ef0..ef05532 100644 --- a/charts/humio-fluentbit/templates/fluent-bit-configmap.yaml +++ b/charts/humio-fluentbit/templates/fluent-bit-configmap.yaml @@ -7,6 +7,11 @@ metadata: k8s-app: {{ .Release.Name }} data: fluent-bit-service.conf: {{- toYaml .Values.serviceConfig | indent 2 }} +{{- if .Values.metrics.enabled }} + HTTP_Server On + HTTP_Listen 0.0.0.0 + HTTP_Port 2020 +{{- end }} fluent-bit-input.conf: {{- toYaml .Values.inputConfig | indent 2 }} diff --git a/charts/humio-fluentbit/templates/fluent-bit-service.yaml b/charts/humio-fluentbit/templates/fluent-bit-service.yaml new file mode 100644 index 0000000..02f1813 --- /dev/null +++ b/charts/humio-fluentbit/templates/fluent-bit-service.yaml @@ -0,0 +1,30 @@ +{{- if .Values.metrics.enabled }} +apiVersion: v1 +kind: Service +metadata: +{{- if .Values.metrics.service.annotations }} + annotations: +{{ toYaml .Values.metrics.service.annotations | indent 4 }} +{{- end }} + name: {{ template "humio-fluentbit.fullname" . }}-metrics + labels: + app: {{ template "humio-fluentbit.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + {{- if .Values.metrics.service }} + {{- range $key, $value := .Values.metrics.service.labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + type: {{ .Values.metrics.service.type}} + sessionAffinity: None + ports: + - port: {{ .Values.metrics.service.port }} + targetPort: metrics + name: metrics + selector: + app: {{ template "humio-fluentbit.name" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/charts/humio-fluentbit/templates/fluent-bit-servicemonitor.yaml b/charts/humio-fluentbit/templates/fluent-bit-servicemonitor.yaml new file mode 100644 index 0000000..5a9bd5b --- /dev/null +++ b/charts/humio-fluentbit/templates/fluent-bit-servicemonitor.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "humio-fluentbit.fullname" . }} + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + app: {{ template "humio-fluentbit.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + {{- if .Values.metrics.serviceMonitor.additionalLabels }} +{{ toYaml .Values.metrics.serviceMonitor.additionalLabels | indent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: /api/v1/metrics/prometheus + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ include "humio-fluentbit.name" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/charts/humio-fluentbit/values.yaml b/charts/humio-fluentbit/values.yaml index 4accc5d..343e54e 100644 --- a/charts/humio-fluentbit/values.yaml +++ b/charts/humio-fluentbit/values.yaml @@ -18,6 +18,25 @@ fullnameOverride: "" tokenSecretName: "" tokenSecretKeyName: token +metrics: + enabled: true + service: + # labels: + # key: value + annotations: {} + # In order for Prometheus to consume metrics automatically use the following annotations: + # prometheus.io/path: "/api/v1/metrics/prometheus" + # prometheus.io/port: "2020" + # prometheus.io/scrape: "true" + port: 2020 + type: ClusterIP + serviceMonitor: + enabled: true + additionalLabels: {} + # namespace: monitoring + # interval: 30s + # scrapeTimeout: 10s + resources: limits: cpu: 100m From 3d5a3564d9b7e8d012eca6acb2c39d79213a0aec Mon Sep 17 00:00:00 2001 From: Piotr Szwed Date: Sun, 14 Jun 2020 19:22:22 +0200 Subject: [PATCH 2/3] Set metrics defaults to false --- charts/humio-fluentbit/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/humio-fluentbit/values.yaml b/charts/humio-fluentbit/values.yaml index 343e54e..a28c2fe 100644 --- a/charts/humio-fluentbit/values.yaml +++ b/charts/humio-fluentbit/values.yaml @@ -19,7 +19,7 @@ tokenSecretName: "" tokenSecretKeyName: token metrics: - enabled: true + enabled: false service: # labels: # key: value @@ -31,7 +31,7 @@ metrics: port: 2020 type: ClusterIP serviceMonitor: - enabled: true + enabled: false additionalLabels: {} # namespace: monitoring # interval: 30s From c2e7026833078a42eb98dfe12b23d21f48ce5326 Mon Sep 17 00:00:00 2001 From: Piotr Szwed Date: Sun, 14 Jun 2020 19:29:51 +0200 Subject: [PATCH 3/3] Removed obsolete annotations as it was moved to Service and ServiceMonitor config --- charts/humio-fluentbit/templates/fluent-bit-ds.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/charts/humio-fluentbit/templates/fluent-bit-ds.yaml b/charts/humio-fluentbit/templates/fluent-bit-ds.yaml index 2c74b4f..49e84b7 100644 --- a/charts/humio-fluentbit/templates/fluent-bit-ds.yaml +++ b/charts/humio-fluentbit/templates/fluent-bit-ds.yaml @@ -21,10 +21,6 @@ spec: k8s-app: {{ .Release.Name }} version: v1 kubernetes.io/cluster-service: "true" - annotations: - prometheus.io/scrape: "true" - prometheus.io/port: "2020" - prometheus.io/path: /api/v1/metrics/prometheus spec: {{- if .Values.es.autodiscovery }} initContainers: