mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
[stable/prometheus-redis-exporter] Adding abbility to use custom script (#14552)
* Added support for custom LUA scripts Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com> * Removed unnecessary comments Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com> * Bumping chart version and removed whitespaces Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com> * Removed unnecessary comments Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com> * Added documentation for script.keyname parameter Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com> * Restored imagePullSecret-part Signed-off-by: Alexander Zimmermann <alexander.zimmermann@mt-ag.com>
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
26a6d2b99e
commit
7ad89a87fd
@@ -2,7 +2,7 @@ apiVersion: v1
|
||||
appVersion: 0.28.0
|
||||
description: Prometheus exporter for Redis metrics
|
||||
name: prometheus-redis-exporter
|
||||
version: 2.0.0
|
||||
version: 2.0.1
|
||||
home: https://github.com/oliver006/redis_exporter
|
||||
sources:
|
||||
- https://github.com/oliver006/redis_exporter
|
||||
|
||||
@@ -66,6 +66,8 @@ The following table lists the configurable parameters and their default values.
|
||||
| `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 | |
|
||||
| `script.configmap` | Let you run a custom lua script from a configmap. The corresponding environment variable `REDIS_EXPORTER_SCRIPT` will be set automatically ||
|
||||
| `script.keyname` | Name of the key inside configmap which contains your script ||
|
||||
|
||||
For more information please refer to the [redis_exporter](https://github.com/oliver006/redis_exporter) documentation.
|
||||
|
||||
@@ -82,3 +84,35 @@ Alternatively, a YAML file that specifies the values for the parameters can be p
|
||||
```bash
|
||||
$ helm install --name my-release -f values.yaml stable/prometheus-redis-exporter
|
||||
```
|
||||
### Using a custom LUA-Script
|
||||
First, you need to deploy the script with a configmap. This is an example script from mentioned in the [redis_exporter-image repository](https://github.com/oliver006/redis_exporter/blob/master/contrib/sample_collect_script.lua)
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: prometheus-redis-exporter-script
|
||||
data:
|
||||
script: |-
|
||||
-- Example collect script for -script option
|
||||
-- This returns a Lua table with alternating keys and values.
|
||||
-- Both keys and values must be strings, similar to a HGETALL result.
|
||||
-- More info about Redis Lua scripting: https://redis.io/commands/eval
|
||||
|
||||
local result = {}
|
||||
|
||||
-- Add all keys and values from some hash in db 5
|
||||
redis.call("SELECT", 5)
|
||||
local r = redis.call("HGETALL", "some-hash-with-stats")
|
||||
if r ~= nil then
|
||||
for _,v in ipairs(r) do
|
||||
table.insert(result, v) -- alternating keys and values
|
||||
end
|
||||
end
|
||||
|
||||
-- Set foo to 42
|
||||
table.insert(result, "foo")
|
||||
table.insert(result, "42") -- note the string, use tostring() if needed
|
||||
|
||||
return result
|
||||
```
|
||||
If you want to use this script for collecting metrics, you could do this by just set `script.configmap` to the name of the configmap (e.g. `prometheus-redis-exporter-script`) and `script.keyname` to the configmap-key holding the script (eg. `script`). The required variables inside the container will be set automatically.
|
||||
|
||||
@@ -42,8 +42,17 @@ spec:
|
||||
env:
|
||||
- name: REDIS_ADDR
|
||||
value: {{ join "," .Values.redisAddress }}
|
||||
{{- if .Values.script }}
|
||||
- name: REDIS_EXPORTER_SCRIPT
|
||||
value: /script/script.lua
|
||||
{{- end }}
|
||||
{{- if .Values.env }}
|
||||
{{ toYaml .Values.env | indent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.script }}
|
||||
volumeMounts:
|
||||
- mountPath: /script
|
||||
name: script-mount
|
||||
{{- end }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
@@ -55,6 +64,15 @@ spec:
|
||||
port: exporter-port
|
||||
resources:
|
||||
{{ toYaml .Values.resources | indent 12 }}
|
||||
{{- if .Values.script }}
|
||||
volumes:
|
||||
- name: script-mount
|
||||
configMap:
|
||||
name: {{ .Values.script.configmap }}
|
||||
items:
|
||||
- key: {{ .Values.script.keyname }}
|
||||
path: script.lua
|
||||
{{- end }}
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{ toYaml .Values.nodeSelector | indent 8 }}
|
||||
|
||||
@@ -18,11 +18,11 @@ image:
|
||||
extraArgs: {}
|
||||
# Additional Environment variables
|
||||
env: {}
|
||||
# - name: REDIS_PASSWORD
|
||||
# valueFrom:
|
||||
# secretKeyRef:
|
||||
# key: redis-password
|
||||
# name: redis-config-0.0.2
|
||||
# - name: REDIS_PASSWORD
|
||||
# valueFrom:
|
||||
# secretKeyRef:
|
||||
# key: redis-password
|
||||
# name: redis-config-0.0.2
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 9121
|
||||
@@ -52,3 +52,8 @@ serviceMonitor:
|
||||
# labels:
|
||||
# Set timeout for scrape
|
||||
# timeout: 10s
|
||||
|
||||
# Used to mount a LUA-Script via config map and use it for metrics-collection
|
||||
# script:
|
||||
# configmap: prometheus-redis-exporter-script
|
||||
# keyname: script
|
||||
|
||||
Reference in New Issue
Block a user