Add optional support for configuring Prometheus scrape ServiceMonitor (#11451)

* Add optional support for configuring Prometheus scrape via Prometheus-Operator ServiceMonitor

Signed-off-by: thomasriley <twriley@outlook.com>

* Bump Chart version

Signed-off-by: thomasriley <twriley@outlook.com>

* Fix linting error

Signed-off-by: thomasriley <twriley@outlook.com>

* Make the namespace value optional and remove the unnecessary telemetryPath & interval options

Signed-off-by: thomasriley <twriley@outlook.com>

* Re-add interval and metrics path options but make them optional

Signed-off-by: thomasriley <twriley@outlook.com>
This commit is contained in:
Tom Riley
2019-02-18 14:54:11 -08:00
committed by Kubernetes Prow Robot
parent 482af9cb85
commit b0298e4f35
3 changed files with 42 additions and 1 deletions
+1 -1
View File
@@ -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:
@@ -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 }}
+11
View File
@@ -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