File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ TOKEN "read" READ
2+ TAGS "pagerduty"
3+
4+ NODE notifications
5+ SQL >
6+ %
7+ SELECT
8+ event_time,
9+ toStartOfHour(event_time) as hour,
10+ event.event.data.id as incident_id
11+ FROM pagerduty
12+ WHERE event_type IN ['incident.triggered', 'incident.escalated']
13+ AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
14+ AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
15+ {% if defined(service_id) and service_id != '' %}
16+ AND event.event.data.service.id::String = {{String(service_id)}}
17+ {% end %}
18+
19+ NODE interruptions
20+ SQL >
21+ %
22+ SELECT
23+ hour,
24+ count() as interruptions,
25+ toDayOfWeek(hour) as day_of_week,
26+ toHour(hour) as hour_of_day
27+ FROM (
28+ SELECT
29+ hour,
30+ incident_id,
31+ min(event_time) as first_notification
32+ FROM notifications
33+ GROUP BY hour, incident_id
34+ HAVING dateDiff('second',
35+ lagInFrame(first_notification) OVER (ORDER BY first_notification),
36+ first_notification) > 60
37+ OR lagInFrame(first_notification) OVER (ORDER BY first_notification) IS NULL
38+ )
39+ GROUP BY hour
40+
41+
42+ NODE interruptions_summary
43+ SQL >
44+ %
45+ SELECT
46+ hour,
47+ interruptions,
48+ multiIf(
49+ hour_of_day >= 9 AND hour_of_day < 17 AND day_of_week >= 1 AND day_of_week <= 5, 'business',
50+ hour_of_day >= 23 OR hour_of_day < 7, 'sleep',
51+ 'off'
52+ ) as hour_type
53+ FROM interruptions
54+ ORDER BY hour ASC
You can’t perform that action at this time.
0 commit comments