Skip to content

Commit f5eac2e

Browse files
committed
added grafana dashboard
1 parent e9efb35 commit f5eac2e

4 files changed

Lines changed: 267 additions & 0 deletions

File tree

redis/versions/3.4.1/templates/_helpers.tpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ Redis Backup Policy Name
106106
{{- printf "%s-redis-backup-policy" .Release.Name }}
107107
{{- end }}
108108

109+
{{/*
110+
Grafana Folder Name
111+
*/}}
112+
{{- define "redis.grafanaFolder.name" -}}
113+
{{- printf "%s-redis-folder" .Release.Name }}
114+
{{- end }}
115+
116+
{{/*
117+
Grafana Dashboard Name
118+
*/}}
119+
{{- define "redis.grafanaDashboard.name" -}}
120+
{{- printf "%s-redis-dashboard" .Release.Name }}
121+
{{- end }}
122+
109123

110124
{{/* Validation */}}
111125

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
{{- if and (.Capabilities.APIVersions.Has "grafana.integreatly.org/v1beta1") .Values.grafana.dashboard.enabled }}
2+
apiVersion: grafana.integreatly.org/v1beta1
3+
kind: GrafanaDashboard
4+
metadata:
5+
name: {{ include "redis.grafanaDashboard.name" . }}
6+
spec:
7+
folder: {{ include "redis.grafanaFolder.name" . }}
8+
instanceSelector:
9+
matchLabels:
10+
{{- toYaml .Values.grafana.instanceSelector.matchLabels | nindent 6 }}
11+
json: |
12+
{
13+
"uid": "{{ .Release.Name }}-redis",
14+
"title": "Redis - {{ .Release.Name }}",
15+
"tags": ["redis"],
16+
"timezone": "browser",
17+
"schemaVersion": 38,
18+
"version": 1,
19+
"refresh": "30s",
20+
"time": {"from": "now-1h", "to": "now"},
21+
"templating": {
22+
"list": [
23+
{
24+
"type": "datasource",
25+
"name": "datasource",
26+
"label": "Datasource",
27+
"pluginId": "prometheus",
28+
"current": {}
29+
},
30+
{
31+
"type": "textbox",
32+
"name": "namespace",
33+
"label": "Namespace",
34+
"current": {
35+
"value": "{{ .Release.Namespace }}",
36+
"text": "{{ .Release.Namespace }}"
37+
},
38+
"options": [
39+
{
40+
"selected": true,
41+
"text": "{{ .Release.Namespace }}",
42+
"value": "{{ .Release.Namespace }}"
43+
}
44+
]
45+
},
46+
{
47+
"type": "query",
48+
"name": "pod",
49+
"label": "Pod",
50+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
51+
"definition": "label_values(container_cpu_usage_seconds_total{container=\"redis\", namespace=\"$namespace\"}, pod)",
52+
"query": {
53+
"query": "label_values(container_cpu_usage_seconds_total{container=\"redis\", namespace=\"$namespace\"}, pod)",
54+
"refId": "StandardVariableQuery"
55+
},
56+
"refresh": 2,
57+
"multi": true,
58+
"includeAll": true,
59+
"allValue": ".*",
60+
"current": {}
61+
}
62+
]
63+
},
64+
"panels": [
65+
{
66+
"id": 1,
67+
"title": "CPU Usage",
68+
"type": "timeseries",
69+
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
70+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
71+
"targets": [
72+
{
73+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
74+
"expr": "rate(container_cpu_usage_seconds_total{container=\"redis\", namespace=\"$namespace\", pod=~\"$pod\"}[5m])",
75+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
76+
"refId": "A"
77+
}
78+
],
79+
"fieldConfig": {
80+
"defaults": {
81+
"unit": "short",
82+
"color": {"mode": "palette-classic"},
83+
"custom": {"lineWidth": 1, "fillOpacity": 10}
84+
},
85+
"overrides": []
86+
},
87+
"options": {
88+
"tooltip": {"mode": "multi", "sort": "none"},
89+
"legend": {"displayMode": "list", "placement": "bottom"}
90+
}
91+
},
92+
{
93+
"id": 2,
94+
"title": "Memory Usage",
95+
"type": "timeseries",
96+
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
97+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
98+
"targets": [
99+
{
100+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
101+
"expr": "container_memory_working_set_bytes{container=\"redis\", namespace=\"$namespace\", pod=~\"$pod\"}",
102+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
103+
"refId": "A"
104+
}
105+
],
106+
"fieldConfig": {
107+
"defaults": {
108+
"unit": "bytes",
109+
"color": {"mode": "palette-classic"},
110+
"custom": {"lineWidth": 1, "fillOpacity": 10}
111+
},
112+
"overrides": []
113+
},
114+
"options": {
115+
"tooltip": {"mode": "multi", "sort": "none"},
116+
"legend": {"displayMode": "list", "placement": "bottom"}
117+
}
118+
}
119+
{{- if .Values.redis.exporter.enabled }},
120+
{
121+
"id": 3,
122+
"title": "Connected Clients",
123+
"type": "timeseries",
124+
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
125+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
126+
"targets": [
127+
{
128+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
129+
"expr": "redis_connected_clients{namespace=\"$namespace\", pod=~\"$pod\"}",
130+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
131+
"refId": "A"
132+
}
133+
],
134+
"fieldConfig": {
135+
"defaults": {
136+
"unit": "short",
137+
"color": {"mode": "palette-classic"},
138+
"custom": {"lineWidth": 1, "fillOpacity": 10}
139+
},
140+
"overrides": []
141+
},
142+
"options": {
143+
"tooltip": {"mode": "multi", "sort": "none"},
144+
"legend": {"displayMode": "list", "placement": "bottom"}
145+
}
146+
},
147+
{
148+
"id": 4,
149+
"title": "Redis Memory Used",
150+
"type": "timeseries",
151+
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
152+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
153+
"targets": [
154+
{
155+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
156+
"expr": "redis_memory_used_bytes{namespace=\"$namespace\", pod=~\"$pod\"}",
157+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
158+
"refId": "A"
159+
}
160+
],
161+
"fieldConfig": {
162+
"defaults": {
163+
"unit": "bytes",
164+
"color": {"mode": "palette-classic"},
165+
"custom": {"lineWidth": 1, "fillOpacity": 10}
166+
},
167+
"overrides": []
168+
},
169+
"options": {
170+
"tooltip": {"mode": "multi", "sort": "none"},
171+
"legend": {"displayMode": "list", "placement": "bottom"}
172+
}
173+
},
174+
{
175+
"id": 5,
176+
"title": "Commands Processed / sec",
177+
"type": "timeseries",
178+
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 16},
179+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
180+
"targets": [
181+
{
182+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
183+
"expr": "rate(redis_commands_processed_total{namespace=\"$namespace\", pod=~\"$pod\"}[5m])",
184+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
185+
"refId": "A"
186+
}
187+
],
188+
"fieldConfig": {
189+
"defaults": {
190+
"unit": "ops",
191+
"color": {"mode": "palette-classic"},
192+
"custom": {"lineWidth": 1, "fillOpacity": 10}
193+
},
194+
"overrides": []
195+
},
196+
"options": {
197+
"tooltip": {"mode": "multi", "sort": "none"},
198+
"legend": {"displayMode": "list", "placement": "bottom"}
199+
}
200+
},
201+
{
202+
"id": 6,
203+
"title": "Cache Hit Rate",
204+
"type": "timeseries",
205+
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 16},
206+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
207+
"targets": [
208+
{
209+
"datasource": {"type": "prometheus", "uid": "${datasource}"},
210+
"expr": "rate(redis_keyspace_hits_total{namespace=\"$namespace\", pod=~\"$pod\"}[5m]) / (rate(redis_keyspace_hits_total{namespace=\"$namespace\", pod=~\"$pod\"}[5m]) + rate(redis_keyspace_misses_total{namespace=\"$namespace\", pod=~\"$pod\"}[5m]))",
211+
"legendFormat": "{{ "{{" }}pod{{ "}}" }}",
212+
"refId": "A"
213+
}
214+
],
215+
"fieldConfig": {
216+
"defaults": {
217+
"unit": "percentunit",
218+
"min": 0,
219+
"max": 1,
220+
"color": {"mode": "palette-classic"},
221+
"custom": {"lineWidth": 1, "fillOpacity": 10}
222+
},
223+
"overrides": []
224+
},
225+
"options": {
226+
"tooltip": {"mode": "multi", "sort": "none"},
227+
"legend": {"displayMode": "list", "placement": "bottom"}
228+
}
229+
}
230+
{{- end }}
231+
]
232+
}
233+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if and (.Capabilities.APIVersions.Has "grafana.integreatly.org/v1beta1") .Values.grafana.dashboard.enabled }}
2+
apiVersion: grafana.integreatly.org/v1beta1
3+
kind: GrafanaFolder
4+
metadata:
5+
name: {{ include "redis.grafanaFolder.name" . }}
6+
spec:
7+
title: {{ .Values.grafana.folder }}
8+
instanceSelector:
9+
matchLabels:
10+
{{- toYaml .Values.grafana.instanceSelector.matchLabels | nindent 6 }}
11+
{{- end }}

redis/versions/3.4.1/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,12 @@ backup:
184184
bucket: my-backup-bucket
185185
cloudAccountName: my-backup-cloudaccount
186186
prefix: redis/backups # folder name where your backups will be stored
187+
188+
grafana:
189+
dashboard:
190+
enabled: false # K8s clusters only - set to true to provision the dashboard via the Grafana Operator
191+
folder: Redis # Grafana folder the dashboard is placed in
192+
datasource: Prometheus # name of the Prometheus datasource in your Grafana instance
193+
instanceSelector:
194+
matchLabels:
195+
dashboards: grafana # must match the label on your Grafana CR

0 commit comments

Comments
 (0)