From b0298e4f359baba704df9060b33a577ecc12e477 Mon Sep 17 00:00:00 2001 From: Tom Riley <11618735+thomasriley@users.noreply.github.com> Date: Mon, 18 Feb 2019 22:54:11 +0000 Subject: [PATCH] Add optional support for configuring Prometheus scrape ServiceMonitor (#11451) * Add optional support for configuring Prometheus scrape via Prometheus-Operator ServiceMonitor Signed-off-by: thomasriley * Bump Chart version Signed-off-by: thomasriley * Fix linting error Signed-off-by: thomasriley * Make the namespace value optional and remove the unnecessary telemetryPath & interval options Signed-off-by: thomasriley * Re-add interval and metrics path options but make them optional Signed-off-by: thomasriley --- stable/filebeat/Chart.yaml | 2 +- stable/filebeat/templates/servicemonitor.yaml | 30 +++++++++++++++++++ stable/filebeat/values.yaml | 11 +++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 stable/filebeat/templates/servicemonitor.yaml diff --git a/stable/filebeat/Chart.yaml b/stable/filebeat/Chart.yaml index 3b718030ba..8ce01f4c54 100644 --- a/stable/filebeat/Chart.yaml +++ b/stable/filebeat/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 description: A Helm chart to collect Kubernetes logs with filebeat icon: https://www.elastic.co/assets/blt47799dcdcf08438d/logo-elastic-beats-lt.svg name: filebeat -version: 1.3.0 +version: 1.4.0 appVersion: 6.6.0 home: https://www.elastic.co/products/beats/filebeat sources: diff --git a/stable/filebeat/templates/servicemonitor.yaml b/stable/filebeat/templates/servicemonitor.yaml new file mode 100644 index 0000000000..6eb5ff1950 --- /dev/null +++ b/stable/filebeat/templates/servicemonitor.yaml @@ -0,0 +1,30 @@ +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.monitoring.serviceMonitor.enabled ) ( .Values.monitoring.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: +{{- if .Values.monitoring.serviceMonitor.labels }} + labels: +{{ toYaml .Values.monitoring.serviceMonitor.labels | indent 4}} +{{- end }} + name: {{ template "filebeat.fullname" . }}-prometheus-exporter +{{- if .Values.monitoring.serviceMonitor.namespace }} + namespace: {{ .Values.monitoring.serviceMonitor.namespace }} +{{- end }} +spec: + endpoints: + - targetPort: {{ .Values.monitoring.exporterPort }} +{{- if .Values.monitoring.serviceMonitor.interval }} + interval: {{ .Values.monitoring.serviceMonitor.interval }} +{{- end }} +{{- if .Values.monitoring.serviceMonitor.telemetryPath }} + path: {{ .Values.monitoring.serviceMonitor.telemetryPath }} +{{- end }} + jobLabel: {{ template "filebeat.fullname" . }}-prometheus-exporter + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ template "filebeat.name" . }} + release: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/stable/filebeat/values.yaml b/stable/filebeat/values.yaml index 8f52764109..5d8606c2b1 100644 --- a/stable/filebeat/values.yaml +++ b/stable/filebeat/values.yaml @@ -145,6 +145,17 @@ podSecurityPolicy: ## Dont forget to enable http on config.http.enabled (exposing filebeat stats) monitoring: enabled: true + serviceMonitor: + # When set true and if Prometheus Operator is installed then use a ServiceMonitor to configure scraping + enabled: true + # Set the namespace the ServiceMonitor should be deployed + # namespace: monitoring + # Set how frequently Prometheus should scrape + # interval: 30s + # Set path to beats-exporter telemtery-path + # telemetryPath: /metrics + # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator + # labels: image: repository: trustpilot/beat-exporter tag: 0.1.1