forked from UpHabit/bull_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bull.dashboard.py
executable file
·150 lines (142 loc) · 4.59 KB
/
bull.dashboard.py
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
#!/usr/bin/env bash
''':'
TOP="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FILE="$TOP/$(basename "${BASH_SOURCE[0]}")"
if [[ ! -d "$TOP/.venv" ]] ; then
echo "Creating venv in $TOP/.venv"
python3 -m venv "$TOP/.venv"
fi
source "$TOP/.venv/bin/activate"
if ! pip show grafanalib >/dev/null 2>&1 ; then
echo "Installing grafanalib"
pip install grafanalib
fi
exec generate-dashboard "$FILE" "$@"
'''
from grafanalib.core import *
prefix = 'bull'
dashboard = Dashboard(
title="Bull Queue",
links=[DashboardLink(
uri='https://github.com/UpHabit/bull_exporter',
title='About Bull',
type='link',
dashboard=None,
)],
rows=[
Row(panels=[
Graph(
title="Queue Length",
dataSource='Prometheus',
transparent=True,
targets=[
Target(
expr=f'sum({prefix}_queue_waiting) by (prefix, queue)',
legendFormat="{{ queue }}",
refId='A',
),
],
yAxes=[
YAxis(format=OPS_FORMAT),
YAxis(format=OPS_FORMAT),
],
),
Graph(
title="Queue Length",
dataSource='Prometheus',
transparent=True,
targets=[
Target(
expr=f'sum({prefix}_queue_waiting / rate({prefix}_queue_completed[5m])) by (queue, prefix)',
legendFormat="{{ queue }}",
refId='A',
),
],
yAxes=[
YAxis(format=OPS_FORMAT),
YAxis(format=OPS_FORMAT),
],
),
]),
Row(panels=[
Graph(
title="Queue States",
dataSource='Prometheus',
transparent=True,
seriesOverrides=[{
"alias": "Complete Rate",
"yaxis": 2
}, {
"alias": "Fail Rate",
"yaxis": 2
}],
yAxes=[
YAxis(format='short'),
YAxis(format='opm'),
],
targets=[
Target(
expr=f'sum(rate({prefix}_queue_completed[5m])) * 60',
legendFormat="Complete Rate",
refId='A',
),
Target(
expr=f'sum(rate({prefix}_queue_failed[5m])) * 60',
legendFormat="Fail Rate",
refId='B',
),
Target(
expr=f'sum({prefix}_queue_active)',
legendFormat="Active",
refId='C',
),
Target(
expr=f'sum({prefix}_queue_waiting)',
legendFormat="Waiting",
refId='D',
),
Target(
expr=f'sum({prefix}_queue_delayed)',
legendFormat="Delayed",
refId='E',
),
Target(
expr=f'sum({prefix}_queue_failed)',
legendFormat="Failed",
refId='F',
),
],
),
Graph(
title="Failures By Queue",
dataSource='Prometheus',
transparent=True,
targets=[
Target(
expr=f'max({prefix}_queue_failed) by (queue)',
legendFormat="{{ queue }}",
refId='A',
)
]
),
]),
Row(panels=[
Graph(
title="Job Duration 90th Percentile",
dataSource='Prometheus',
transparent=True,
yAxes=[
YAxis(format=MILLISECONDS_FORMAT),
YAxis(format=MILLISECONDS_FORMAT),
],
targets=[
Target(
expr=f'sum({prefix}_queue_complete_duration {{ quantile = "0.9" }}) by (queue)',
legendFormat="{{ queue }}",
refId='A',
)
]
),
]),
],
).auto_panel_ids()