-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummarize.sql
62 lines (47 loc) · 1.13 KB
/
summarize.sql
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
--
-- Spark SQL query to aggregate and summarize structured logs.
--
SELECT
'Total number of log entries' AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
UNION
SELECT
CONCAT('Total number of ', log_level, ' log entries') AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
GROUP BY log_level
UNION
SELECT
CONCAT('Total number of log entries in ', log_year) AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
GROUP BY log_year
UNION
SELECT
CONCAT('Total number of log entries on ', log_month, ' month of the year') AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
GROUP BY log_month
UNION
SELECT
CONCAT('Total number of log entries on ', log_day, ' day of the month') AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
GROUP BY log_day
UNION
SELECT
CONCAT('Total number of log entries on ', log_hour, ' hour of the day') AS ANALYSIS,
COUNT(*) AS VALUE
FROM structured_logs
GROUP BY log_hour
UNION
SELECT
'Average log entry length' AS ANALYSIS,
AVG(log_length) AS VALUE
FROM structured_logs
UNION
SELECT
'Average log message length' AS ANALYSIS,
AVG(log_message_length) AS VALUE
FROM structured_logs