[stable/prometheus-redis-exporter] Add servicemonitor support (#14534)

* - Add support for servicemonitor to prometheus-redis-exporter

Signed-off-by: Mohamed Hazem <mhaz@hellofresh.com>

* - Add support for custom service labels
- Add missing doc for service.annotations

Signed-off-by: Mohamed Hazem <mhaz@hellofresh.com>
This commit is contained in:
Mohamed Hazem
2019-06-09 07:29:04 -07:00
committed by Kubernetes Prow Robot
parent e9e5d8d693
commit a5dd162541
5 changed files with 62 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v1
appVersion: 0.28.0
description: Prometheus exporter for Redis metrics
name: prometheus-redis-exporter
version: 1.0.3
version: 1.1.0
home: https://github.com/oliver006/redis_exporter
sources:
- https://github.com/oliver006/redis_exporter
@@ -52,12 +52,20 @@ The following table lists the configurable parameters and their default values.
| `resources` | cpu/memory resource requests/limits | {} |
| `service.type` | desired service type | `ClusterIP` |
| `service.port` | service external port | `9121` |
| `service.annotations` | Custom annotations for service | `{}` |
| `service.labels` | Additional custom labels for the service | `{}` |
| `redisAddress` | address of one or more redis nodes, comma separated | `redis://myredis:6379` |
| `annotations` | pod annotations for easier discovery | {} |
| `rbac.create` | Specifies whether RBAC resources should be created.| `true` |
| `rbac.pspEnabled` | Specifies whether a PodSecurityPolicy should be created.| `true` |
| `serviceAccount.create` | Specifies whether a service account should be created.| `true` |
| `serviceAccount.name` | Name of the service account.| |
| `serviceMonitor.enabled` | Use servicemonitor from prometheus operator | `false` |
| `serviceMonitor.namespace` | Namespace this servicemonitor is installed in | |
| `serviceMonitor.interval` | How frequently Prometheus should scrape | |
| `serviceMonitor.telemetryPath` | Path to redis-exporter telemtery-path | |
| `serviceMonitor.labels` | Labels for the servicemonitor passed to Prometheus Operator | `{}` |
| `serviceMonitor.timeout` | Timeout after which the scrape is ended | |
For more information please refer to the [redis_exporter](https://github.com/oliver006/redis_exporter) documentation.
@@ -7,6 +7,9 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
spec:
@@ -0,0 +1,35 @@
{{- if $.Values.serviceMonitor }}
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- if .Values.serviceMonitor.labels }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4}}
{{- end }}
name: {{ template "prometheus-redis-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: {{ .Values.service.port }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.telemetryPath }}
path: {{ .Values.serviceMonitor.telemetryPath }}
{{- end }}
{{- if .Values.serviceMonitor.timeout }}
scrapeTimeout: {{ .Values.serviceMonitor.timeout }}
{{- end }}
jobLabel: {{ template "prometheus-redis-exporter.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "prometheus-redis-exporter.name" . }}
release: {{ .Release.Name }}
{{- end }}
{{- end }}
@@ -27,6 +27,7 @@ service:
type: ClusterIP
port: 9121
annotations: {}
labels: {}
# prometheus.io/path: /metrics
# prometheus.io/port: "9121"
# prometheus.io/scrape: "true"
@@ -36,3 +37,17 @@ annotations: {}
# prometheus.io/path: /metrics
# prometheus.io/port: "9121"
# prometheus.io/scrape: "true"
serviceMonitor:
# When set true then use a ServiceMonitor to configure scraping
enabled: false
# Set the namespace the ServiceMonitor should be deployed
# namespace: monitoring
# Set how frequently Prometheus should scrape
# interval: 30s
# Set path to redis-exporter telemtery-path
# telemetryPath: /metrics
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
# labels:
# Set timeout for scrape
# timeout: 10s