-
Notifications
You must be signed in to change notification settings - Fork 251
/
0096.yml
106 lines (103 loc) · 3.43 KB
/
0096.yml
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
version: 96
description: Worker pool errors statistics
methods:
get_worker_pool_error_stats_last_24_hours:
description: |
Returns total number of errors for given worker pool or all worker pools
broken down by hour.
There will be a breakdown for the last 24h even if there are no errors.
mode: read
serviceName: worker_manager
args: worker_pool_id_in text
returns: table (hour timestamptz, count integer)
body: |-
begin
-- fill in missing hours and add zeroes for them
RETURN query
WITH hours AS (
SELECT generate_series(
date_trunc('hour', now() - interval '23 hours'),
date_trunc('hour', now()), -- including now
interval '1 hour'
) as hour
)
SELECT
hours.hour,
COALESCE(worker_pool_errors.count, 0)::int
FROM hours
LEFT JOIN (
SELECT
date_trunc('hour', reported) as hour,
count(*) as count
FROM worker_pool_errors
WHERE
(worker_pool_id = worker_pool_id_in or worker_pool_id_in is null)
GROUP BY hour
) worker_pool_errors ON worker_pool_errors.hour = hours.hour;
end
get_worker_pool_error_stats_last_7_days:
description: |
Returns total number of errors for given worker pool or all worker pools
broken down by hour.
There will be a breakdown for the last 7 days even if there are no errors.
mode: read
serviceName: worker_manager
args: worker_pool_id_in text
returns: table (day timestamptz, count integer)
body: |-
begin
-- fill in missing hours and add zeroes for them
RETURN query
WITH days AS (
SELECT generate_series(
date_trunc('day', now() - interval '6 days'),
date_trunc('day', now()), -- including now
interval '1 day'
) as day
)
SELECT
days.day,
COALESCE(worker_pool_errors.count, 0)::int
FROM days
LEFT JOIN (
SELECT
date_trunc('day', reported) as day,
count(*) as count
FROM worker_pool_errors
WHERE
(worker_pool_id = worker_pool_id_in or worker_pool_id_in is null)
GROUP BY day
) worker_pool_errors ON worker_pool_errors.day = days.day;
end
get_worker_pool_error_titles:
description: |
Returns errors grouped by title for given worker pool or all worker pools
mode: read
serviceName: worker_manager
args: worker_pool_id_in text
returns: table (title text, count integer)
body: |-
begin
RETURN query
SELECT worker_pool_errors.title, count(*)::int
FROM worker_pool_errors
WHERE
(worker_pool_id = worker_pool_id_in or worker_pool_id_in is null)
GROUP BY worker_pool_errors.title;
end
get_worker_pool_error_codes:
description: |
Returns errors grouped by error code for given worker pool or all worker pools
mode: read
serviceName: worker_manager
args: worker_pool_id_in text
returns: table (code text, count integer)
body: |-
begin
RETURN query
SELECT COALESCE(worker_pool_errors.extra->>'code', 'other'), count(*)::int
FROM worker_pool_errors
WHERE
(worker_pool_id = worker_pool_id_in or worker_pool_id_in is null)
GROUP BY worker_pool_errors.extra->>'code';
end