-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanalytics.sql
executable file
·36 lines (28 loc) · 1.1 KB
/
analytics.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
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
# Firewall Log Analytics
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
# Views
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
DROP VIEW IF EXISTS `analytics_ports`;
CREATE VIEW `analytics_ports` AS
SELECT
ip_protocol_name,
dport,
COUNT(*) as num
FROM `log`
WHERE `timestamp` BETWEEN (NOW() - INTERVAL 14 DAY) AND NOW()
GROUP BY dport
ORDER BY num DESC;
DROP VIEW IF EXISTS `analytics_protocols`;
CREATE VIEW `analytics_protocols` AS
SELECT
ip_protocol_name,
COUNT(*) as num
FROM `log`
WHERE `timestamp` BETWEEN (NOW() - INTERVAL 14 DAY) AND NOW()
GROUP BY ip_protocol
ORDER BY num DESC;