-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
dashboards.md
309 lines (270 loc) · 14.7 KB
/
dashboards.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# Dashboards
Dashboards are an extension of kobs via the [Dashboard Custom Resource Definition](https://github.com/kobsio/kobs/blob/main/deploy/kustomize/crds/kobs.io_dashboards.yaml). Dashboards are used to add additional information for teams and applications via all the configured plugins.
You can access all dashboards via the **Dashboards** item on the home page of kobs.
![Home](assets/home.png)
On the dashboards page it will show all dashboards from all clusters and namespaces. When you click on one of the dashboards an modal will be shown, where you can provide the default cluster and namespace and placeholders
![Dashboards](assets/dashboards.png)
The dashboards page is only there to explore all the available dashboards, but for your daily work you should add the dashboards as reference in your [Team](./teams#dashboard) and [Applications](./applications#dashboard).
## Specification
In the following you can found the specification for the Dashboard CRD. On the bottom of this page you also have a complete example for a Dashboard CR.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| description | string | Provide a descriptions for the dashboard with additional details. | No |
| placeholders | [[]Placeholder](#placeholder) | A list of placeholders, which can be directly set by the user. | No |
| variables | [[]Variable](#Variable) | A list of variables, where the values are loaded by the specified plugin. | No |
| rows | [[]Row](#row) | A list of rows for the dashboard. | Yes |
### Placeholder
Placeholders are providing a way to use custom values in the dashboard. The value for a placeholder must be set by the user in the dashboards reference of a [Team](./teams#dashboard) or an [Applications](./applications#dashboard).
The value of a placeholder can be used via the following templating string: `{{ .<placeholder-name> }}`. This string is then replaced with the provided value when the dashboard is loaded.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| name | string | The name for the placeholder, which can be used in the dashboard via `{{ .<placeholder-name> }}`. | Yes |
| description | string | An optional description, to provide more information how the placeholder is used. | No |
### Variable
Variables can be used to select between different values in the dashboard. To use the variable in the dashboard, the following templating string can be used: `{% .<variable-name> %}`.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| name | string | The name of the variable, which can be used in the dashboard via `{% .<variable-name> %}`. | Yes |
| label | string | An optional label, which is shown in the UI instead of the variable name. | No |
| hide | boolean | Hide the variable in the UI. | No |
| plugin | [Variable Plugin](#variable-plugin) | The plugin, which should be used to get the values for the variable. | Yes |
!!! note
Dashboards are also supporting some special variables, which always can be used and must not be defined by a users. These variables are:
- `__timeStart`: The start time of the selected time range in seconds.
- `__timeEnd`: The end time of the selected time range in seconds.
These variables can then be used via `{{ .__timeStart }}` and `{{ .__timeEnd }}` in the dashboard.
### Variable Plugin
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| name | string | The name of the plugin, this must be `core` or the name of an configured Prometheus instance. | Yes |
| options | [Variable Plugin Options](#variable-plugin-options) | Plugin specific options to retrieve the values for the variable. | Yes |
### Variable Plugin Options
If the `core` plugin is used to get the values for a variable the options from the following table can be used. The `clusters` type let you select a cluster from all the loaded cluster, the `plugins` type let you select the name of all configured plugins and the `static` type let you specify a list of static values.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| type | string | The type for the `core` plugin. This must be `clusters`, `plugins` or `static`. | Yes |
| items | []string | A list of static values for the `static` type. | Yes |
??? note "Example"
```yaml
---
apiVersion: kobs.io/v1beta1
kind: Dashboard
spec:
variables:
- name: cluster
label: Cluster
plugin:
name: core
options:
type: clusters
- name: plugin
label: Plugins
plugin:
name: core
options:
type: plugins
- name: mystaticvalues
label: My Static Values
plugin:
name: core
options:
type: static
items:
- myvalue1
- myvalue2
- myvalue3
```
If a Prometheus instance is used to get the variable values, the options from the following table can be used.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| type | string | The query type to get the values for the variable. At the moment this must be `labelValues` | Yes |
| label | string | The Prometheus label which should be used to get the values for the variable. | Yes |
| query | string | The PromQL query. | Yes |
| allowAll | boolean | If this is set to `true` an additional option for the variable will be added, which contains all other values. | No |
### Row
A row can be used to create logical groups in the dashboard.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| title | string | The title for a row. | No |
| description | string | The description for the row, to provide additional details about the content of the row. | No |
| size | number | The size of the row. This must be a value between `1` and `12`. The default value is `2`. You can also use the special value `-1` to not limit the height of the row. | No |
| panels | [[]Panel](#panel) | A list of panels for the row. | Yes |
### Panel
All specified panels are rendered in a 12 column grid and they are containing the plugin specification.
| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| title | string | The title of the panel. | Yes |
| description | string | An optional description with additional information about the panel. | No |
| colSpan | number | The number of columns, which should be used by the panel. This must be a number between `1` and `12`. The default value is `12`. | No |
| rowSpan | number | The number of rows, which should be used by the panel. This must be a number between `1` and `12`. The default value is `1`. | No |
| plugin | [Plugin](../plugins/getting-started.md#specification) | The plugin which should be displayed in the panel. | Yes |
## Example
The following dashboard, shows the CPU and Memory usage of a selected Pod. When this dashboard is used in via a team or application, it is possible to set the namespace and a regular expression to pre select all the Pods. These values are then used to get the names of all Pods and a user can then select the name of a Pod via the `var_pod` variable.
The dashboard only uses the Prometheus plugin to show the CPU Usage, Memory Usage, the Network Usage and some other information via different charts and tables.
```yaml
---
apiVersion: kobs.io/v1beta1
kind: Dashboard
metadata:
name: resource-usage
namespace: kobs
spec:
description: Resources Usage of Pods
placeholders:
- name: namespace
description: Namespace for the Pods
- name: pod
description: Pod selector
variables:
- name: var_pod
label: Pod
plugin:
name: prometheus
options:
type: labelValues
label: pod
query: container_cpu_usage_seconds_total{namespace="{{ .namespace }}", image!="", pod=~"{{ .pod }}", container!="POD", container!=""}
allowAll: false
rows:
- size: 1
panels:
- title: CPU Usage
colSpan: 4
plugin:
name: prometheus
options:
type: sparkline
unit: Cores
queries:
- query: sum(rate(container_cpu_usage_seconds_total{namespace="{{ .namespace }}", image!="", pod=~"{% .var_pod %}", container!="POD", container!=""}[2m]))
- title: Memory Usage
colSpan: 4
plugin:
name: prometheus
options:
type: sparkline
unit: MiB
queries:
- query: sum(container_memory_working_set_bytes{namespace="{{ .namespace }}", pod=~"{% .var_pod %}", container!="POD", container!=""}) / 1024 / 1024
- title: Restarts
colSpan: 4
plugin:
name: prometheus
options:
type: sparkline
queries:
- query: kube_pod_container_status_restarts_total{namespace="{{ .namespace }}", pod=~"{% .var_pod %}"}
- size: 3
panels:
- title: CPU Usage
colSpan: 6
plugin:
name: prometheus
options:
type: line
unit: Cores
legend: table
queries:
- label: "Usage: {% .container %}"
query: sum(rate(container_cpu_usage_seconds_total{namespace="{{ .namespace }}", image!="", pod=~"{% .var_pod %}", container!="POD", container!=""}[2m])) by (container)
- label: "Request: {% .container %}"
query: sum(kube_pod_container_resource_requests{namespace="{{ .namespace }}", resource="cpu", pod=~"{% .var_pod %}", container!="POD", container!=""}) by (container)
- label: "Limits: {% .container %}"
query: sum(kube_pod_container_resource_limits{namespace="{{ .namespace }}", resource="cpu", pod=~"{% .var_pod %}", container!="POD", container!=""}) by (container)
- title: Memory Usage
colSpan: 6
plugin:
name: prometheus
options:
type: line
unit: MiB
legend: table
queries:
- label: "Usage: {% .container %}"
query: sum(container_memory_working_set_bytes{namespace="{{ .namespace }}", pod=~"{% .var_pod %}", container!="POD", container!=""}) by (container) / 1024 / 1024
- label: "Request: {% .container %}"
query: sum(kube_pod_container_resource_requests{namespace="{{ .namespace }}", resource="memory", pod=~"{% .var_pod %}", container!="POD", container!=""}) by (container) / 1024 / 1024
- label: "Limits: {% .container %}"
query: sum(kube_pod_container_resource_limits{namespace="{{ .namespace }}", resource="memory", pod=~"{% .var_pod %}", container!="POD", container!=""}) by (container) / 1024 / 1024
- title: Network
size: 3
panels:
- title: Bandwidth
colSpan: 12
plugin:
name: prometheus
options:
type: area
unit: bytes/s
queries:
- label: Received
query: sum(irate(container_network_receive_bytes_total{namespace="{{ .namespace }}", pod="{% .var_pod %}"}[2m])) by (pod)
- label: Transmitted
query: -sum(irate(container_network_transmit_bytes_total{namespace="{{ .namespace }}", pod="{% .var_pod %}"}[2m])) by (pod)
- title: Rate of Packets
colSpan: 6
plugin:
name: prometheus
options:
type: area
unit: bytes/s
queries:
- label: Received
query: sum(irate(container_network_receive_packets_total{namespace=~"{{ .namespace }}", pod=~"{% .var_pod %}"}[2m])) by (pod)
- label: Transmitted
query: -sum(irate(container_network_transmit_packets_total{namespace=~"{{ .namespace }}", pod=~"{% .var_pod %}"}[2m])) by (pod)
- title: Rate of Packets Dropped
colSpan: 6
plugin:
name: prometheus
options:
type: area
unit: bytes/s
queries:
- label: Received
query: sum(irate(container_network_receive_packets_dropped_total{namespace=~"{{ .namespace }}", pod=~"{% .var_pod %}"}[2m])) by (pod)
- label: Transmitted
query: -sum(irate(container_network_transmit_packets_dropped_total{namespace=~"{{ .namespace }}", pod=~"{% .var_pod %}"}[2m])) by (pod)
- title: "Resource Usage for all Pods"
panels:
- title: Table
plugin:
name: prometheus
options:
type: table
queries:
- label: "{% .pod %}"
query: sum(rate(container_cpu_usage_seconds_total{namespace="{{ .namespace }}", image!="", pod=~"{{ .pod }}", container!="POD", container!=""}[2m])) by (pod)
- label: "{% .pod %}"
query: sum(kube_pod_container_resource_requests{namespace="{{ .namespace }}", resource="cpu", pod=~"{{ .pod }}", container!="POD", container!=""}) by (pod)
- label: "{% .pod %}"
query: sum(kube_pod_container_resource_limits{namespace="{{ .namespace }}", resource="cpu", pod=~"{{ .pod }}", container!="POD", container!=""}) by (pod)
- label: "{% .pod %}"
query: sum(container_memory_working_set_bytes{namespace="{{ .namespace }}", pod=~"{{ .pod }}", container!="POD", container!=""}) by (pod) / 1024 / 1024
- label: "{% .pod %}"
query: sum(kube_pod_container_resource_requests{namespace="{{ .namespace }}", resource="memory", pod=~"{{ .pod }}", container!="POD", container!=""}) by (pod) / 1024 / 1024
- label: "{% .pod %}"
query: sum(kube_pod_container_resource_limits{namespace="{{ .namespace }}", resource="memory", pod=~"{{ .pod }}", container!="POD", container!=""}) by (pod) / 1024 / 1024
columns:
- name: pod
title: Pod
- name: value-1
title: CPU Usage
unit: Cores
- name: value-2
title: CPU Requests
unit: Cores
- name: value-3
title: CPU Limits
unit: Cores
- name: value-4
title: Memory Usage
unit: MiB
- name: value-5
title: Memory Requests
unit: MiB
- name: value-6
title: Memory Limits
unit: MiB
```
![Dashboard](assets/dashboard.png)