[stable/fluent-bit] add a servicemonitor resource for Prometheus operator (#14416)

* [stable/fluent-bit] add a servicemonitor resource for Prometheus operator

Signed-off-by: Sébastien Prud'homme <sebastien.prudhomme@gmail.com>

* [stable/fluent-bit] check API availability

Signed-off-by: Sébastien Prud'homme <sebastien.prudhomme@gmail.com>
This commit is contained in:
Sébastien Prud'homme
2019-07-04 00:42:13 -07:00
committed by Kubernetes Prow Robot
parent 0502da7e1d
commit d2025d2e81
4 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: fluent-bit
version: 2.3.0
version: 2.4.0
appVersion: 1.2.1
description: Fast and Lightweight Log/Data Forwarder for Linux, BSD and OSX
keywords:
+5
View File
@@ -130,6 +130,11 @@ The following table lists the configurable parameters of the Fluent-Bit chart an
| `metrics.service.labels` | Additional labels for the fluent-bit metrics service definition, specified as a map. | None |
| `metrics.service.port` | Port on where metrics should be exposed | `2020` |
| `metrics.service.type` | Service type for metrics | `ClusterIP` |
| `metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` |
| `metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}` |
| `metrics.serviceMonitor.namespace` | Optional namespace in which to create ServiceMonitor | `nil` |
| `metrics.serviceMonitor.interval` | Scrape interval. If not set, the Prometheus default scrape interval is used | `nil` |
| `metrics.serviceMonitor.scrapeTimeout` | Scrape timeout. If not set, the Prometheus default scrape timeout is used | `nil` |
| `trackOffsets` | Specify whether to track the file offsets for tailing docker logs. This allows fluent-bit to pick up where it left after pod restarts but requires access to a `hostPath` | `false` |
| `testFramework.image` | `test-framework` image repository. | `dduportal/bats` |
| `testFramework.tag` | `test-framework` image tag. | `0.4.0` |
@@ -0,0 +1,34 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "fluent-bit.fullname" . }}
{{- if .Values.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
{{- end }}
labels:
app: {{ template "fluent-bit.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 "fluent-bit.name" . }}
release: {{ .Release.Name }}
{{- end }}
+6
View File
@@ -28,6 +28,12 @@ metrics:
# prometheus.io/scrape: "true"
port: 2020
type: ClusterIP
serviceMonitor:
enabled: false
additionalLabels: {}
# namespace: monitoring
# interval: 30s
# scrapeTimeout: 10s
# When enabled, fluent-bit will keep track of tailing offsets across pod restarts.
trackOffsets: false