From e4ea88e88e09d04c90992148ee5a51e7307dd09e Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 15 Feb 2019 00:03:38 +0300 Subject: [PATCH] Add beat-exporter Prometheus metrics (#11408) * Add beat-exporter Prometheus metrics from https://github.com/trustpilot/beat-exporter Signed-off-by: Denis Lavrushko Signed-off-by: Denis Lavrushko * fix DCO and bumped new version Signed-off-by: Denis Lavrushko * Remove blank lines Signed-off-by: Denis Lavrushko * add new line before EOF Signed-off-by: Denis Lavrushko * trailing spaces and newline at the end of file Signed-off-by: Denis Lavrushko --- stable/filebeat/Chart.yaml | 2 +- stable/filebeat/templates/daemonset.yaml | 13 ++++++++++ stable/filebeat/templates/service.yaml | 20 +++++++++++++++ stable/filebeat/values.yaml | 31 +++++++++++++++++++++++- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 stable/filebeat/templates/service.yaml diff --git a/stable/filebeat/Chart.yaml b/stable/filebeat/Chart.yaml index e4356b9290..3b718030ba 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.2.0 +version: 1.3.0 appVersion: 6.6.0 home: https://www.elastic.co/products/beats/filebeat sources: diff --git a/stable/filebeat/templates/daemonset.yaml b/stable/filebeat/templates/daemonset.yaml index 1c3cebd380..792e6ef5d9 100644 --- a/stable/filebeat/templates/daemonset.yaml +++ b/stable/filebeat/templates/daemonset.yaml @@ -108,6 +108,19 @@ spec: readOnly: true {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | indent 8 }} +{{- end }} +{{- if .Values.monitoring.enabled }} + - name: {{ template "filebeat.fullname" . }}-prometheus-exporter + image: "{{ .Values.monitoring.image.repository }}:{{ .Values.monitoring.image.tag }}" + imagePullPolicy: {{ .Values.monitoring.image.pullPolicy }} + args: +{{- if .Values.monitoring.args }} +{{ toYaml .Values.monitoring.args | indent 8 }} +{{- end }} +{{- if .Values.monitoring.resources }} + resources: +{{ toYaml .Values.monitoring.resources | indent 10 }} +{{- end }} {{- end }} volumes: - name: varlog diff --git a/stable/filebeat/templates/service.yaml b/stable/filebeat/templates/service.yaml new file mode 100644 index 0000000000..6b151dba71 --- /dev/null +++ b/stable/filebeat/templates/service.yaml @@ -0,0 +1,20 @@ +{{- if .Values.monitoring.enabled }} +kind: Service +apiVersion: v1 +metadata: + name: {{ template "filebeat.fullname" . }}-metrics + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "filebeat.name" . }} + chart: {{ template "filebeat.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + app: {{ template "filebeat.name" . }} + ports: + - name: metrics + port: {{ .Values.monitoring.exporterPort }} + targetPort: {{ .Values.monitoring.targetPort }} + protocol: TCP +{{ end }} \ No newline at end of file diff --git a/stable/filebeat/values.yaml b/stable/filebeat/values.yaml index 6aa4e4c5fc..8f52764109 100644 --- a/stable/filebeat/values.yaml +++ b/stable/filebeat/values.yaml @@ -44,7 +44,7 @@ config: # When a key contains a period, use this format for setting values on the command line: # --set config."http\.enabled"=true - http.enabled: false + http.enabled: true http.port: 5066 # Upload index template to Elasticsearch if Logstash output is enabled @@ -139,3 +139,32 @@ podSecurityPolicy: # seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*' # seccomp.security.alpha.kubernetes.io/defaultProfileName: 'docker/default' # apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' + +## Add Elastic beat-exporter for Prometheus +## https://github.com/trustpilot/beat-exporter +## Dont forget to enable http on config.http.enabled (exposing filebeat stats) +monitoring: + enabled: true + image: + repository: trustpilot/beat-exporter + tag: 0.1.1 + pullPolicy: IfNotPresent + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 200Mi + # requests: + # cpu: 100m + # memory: 100Mi + + # pass custom args. This is equivalent of Cmd in docker + args: [] + + ## default is ":9479". If changed, need pass argument "-web.listen-address <...>" + exporterPort: 9479 + ## Filebeat service port, which exposes Prometheus metrics + targetPort: 9479