FortiAnalyzer-5.2.2 Dataset Reference
FortiAnalyzer-5.2.2 Dataset Reference
VERSION 5.2.2
FORTINET DOCUMENT LIBRARY
http://docs.fortinet.com
FORTINET BLOG
https://blog.fortinet.com
FORTIGATE COOKBOOK
http://cookbook.fortinet.com
FORTIGUARD CENTER
http://www.fortiguard.com
FEEDBACK
Email: [email protected]
05-522-268748-20150422
TABLE OF CONTENTS
Introduction 4
Overview 5
Understanding Datasets and Macros 6
Creating Custom Datasets 7
To create a custom dataset in the web-based manager 7
Testing SQL Query 8
Examples of SQL Query Errors 8
Examples of Custom Datasets 9
Example 1: Distribution of applications by type in the last 24 hours 10
Example 2: Top 100 applications by bandwidth in the last 24 hours 11
Log Database Tables 12
Dataset Reference List 16
Macro Reference List 173
Introduction
This document provides information about the various types of FortiAnalyzer datasets which are created based on the
FortiGate log SQL tables and messages. These datasets are used to create charts and reports.
It describes the procedure for creating custom datasets, and also lists the types of log tables used to assist in writing
SQL queries to create the datasets.
4 Dataset Reference
Fortinet Inc.
Overview
FortiAnalyzer uses the PostgreSQL and remote MySQL databases to store the log data generated by the FortiGate.
To create a chart based on the FortiGate logs in a local or remote database, you can use either the predefined
datasets, or create your own custom datasets by querying the logs in the SQL database in FortiAnalyzer.
5 Dataset Reference
Fortinet Inc.
Overview Understanding Datasets and Macros
If the FortiAnalyzer unit is not receiving data from a device, or logging is not enabled under System > Config > SQL
Database, it does not create log tables for that device.
Charts in FortiAnalyzer are generated based on the datasets. To create a chart, you can use either the predefined
datasets, or create your own custom datasets by querying the log messages in the SQL database on the FortiAnalyzer
unit. Both predefined and custom datasets can be cloned, but only custom datasets can be deleted. You can also view
the SQL query for a dataset, and test the query against specific devices or log arrays.
You can create custom reports that contain macros created based on predefined and custom datasets. Macros are
used to dynamically display the device log data as text in a report. They can be embedded within a text field of a
paragraph in a report layout in XML format. Macros display a single value, such as a user name, highest session count,
or highest bandwidth etc.
To view and configure datasets, go to Reports > Advanced > Dataset in the left navigation pane of the web-based
manager. For more information, refer to the Dataset section in the FortiAnalyzer Administration Guide.
To view and configure macros, go to Reports> Macro Library in the left navigation pane of the web-based manager.
For more information, refer to the Macro Library section in the FortiAnalyzer Administration Guide.
NOTE: FortiAnalyzer v5.0 Patch Release 5 introduced new datasets for SIP and SCCP. FortiAnalyzer v5.0 Patch
Release 6 introduced new datasets for Botnet (Botnet-Activity-By-Sources, Botnet-Infected-Hosts, Botnet-Sources, Botnet-
Timeline, and Detected-Botnet).
6 Dataset Reference
Fortinet Inc.
Creating Custom Datasets
This section describes the procedure to create datasets in the FortiAnalyzer web-based manager.
The following table describes the GUI fields of the New Dataset dialog box.
Field Description
7 Dataset Reference
Fortinet Inc.
Testing SQL Query
Field Description
Query Enter the SQL query syntax to retrieve the log data you want
from the SQL database.
You can verify the SQL query that you used to create the custom dataset before saving the dataset configuration by
testing and viewing the query results.
1. Click Test after entering the SQL query in the New Dataset dialog box.
The query results are displayed. If the query is not successful, an error message appears in the results pane.
Syntax Errors
You have an error in your SQL syntax (remote/MySQL) or ERROR: syntax error at or
near... (local/PostgreSQL)
l Check that SQL keywords are spelled correctly, and that the query is well-formed.
l Table and column names are demarked by grave accent (`) characters. Single (') and double (") quotation marks will
cause an error.
No data is covered.
l The query is correctly formed, but no data has been logged for the log type. Check that you have configured the
FortiAnalyzer unit to save that log type. Under System >
Config > SQL Database, ensure that the log type is checked.
Connection Errors
If well formed queries do not produce results, and logging is turned on for the log type, there may be a database
configuration problem with the remote database.
Dataset Reference 8
Fortinet Inc.
Examples of Custom Datasets
Ensure that:
Here is an example of creating a new MySQL database named fazlogs, and adding a user for the database:
#Mysql –u root –p
identified by ‘fazpassword’;
For more information about using SQL queries for creating datasets, refer to the
FortiAnalyzer™ and FortiGate™ Version 4.0 MR2 SQL Log Database Query Technical Note on the Fortinet
Documentation Library at docs.fortinet.com.
The following examples illustrate how to create custom datasets using the web-based manager GUI. Once created,
you can use the datasets to configure chart templates under Reports > Chart Library.
9 Dataset Reference
Fortinet Inc.
Examples of Custom Datasets
GUI Procedure
1. Go to Reports> Advanced > Dataset.
2. Click Create New.
3. Select Application Control under Log Type.
4. Enter a name, such as "apps_type_24hrs".
5. Select Last N Hours under Time Period.
6. Enter the query:
SELECT app_type, COUNT( * ) AS totalnum
FROM $log
WHERE $filter
AND app_type IS NOT NULL
GROUP BY app_type
ORDER BY totalnum DESC
Dataset Reference 10
Fortinet Inc.
Examples of Custom Datasets
Notes:
l $filter restricts the query result to the time period specified; in this case, it’s the past 24 hours.
l $log queries all application control logs
l The application control module classifies each firewall session in app_type. One firewall session may be classified
to multiple app_types. For example, an HTTPsession can be classified to: HTTP, Facebook, etc.
l Some app/app_types may not be able to detected, then the ‘app_type’ field may be null or ‘N/A’. These will be
ignored by this query.
The result is ordered by the total session number of the same app_type. The most frequent app_types will appear first.
NOTE:
l (timestamp-timestamp%3600) as hourstamp - this calculates an "hourstamp" to indicate bandwidth per hour.
l SUM( sent + rcvd ) AS volume - this calculates the total sent and received bytes.
l ORDER BY volume DESC - this orders the results by descending volume (largest volume first).
l LIMIT 100 - this lists only the top 100 applications.
11 Dataset Reference
Fortinet Inc.
Log Database Tables
The FortiAnalyzer and FortiGate units create SQL database tables to record log data. These tables are generated for
high log rate and low log rate devices.
<devtype>]-ADOM[<admon_oid><log-type>-timestamp]
and
<devtype>ADOM<adom_oid>-ALLELSE-<log-type>-<timestamp>-<delta-timestamp>
Example:
FGTADOM141-tlog-0, FGTADOM141-ALLELSE-tlog-0-0
<devtype> : "FGT/FMG/FML/FCT/FWB/FCH/FAZ/SYS/..."
{"FGT", "FortiGate"},
{"FMG", "FortiManager"},
{"SYS", "Syslog"},
{"FCT", "FortiClient"},
{"FML", "FortiMail"},
{"FWB", "FortiWeb"},
{"FCH", "FortiCache"},
{"FAZ", "FortiAnalyzer"},
{"FSA", "FortiSandbox"},
Traffic tlog The traffic log records all traffic to and through the FortiGate
interface.
Event elog The event log records management and activity events. For
example, when an administrator logs in or logs out of the web-
based manager.
Antivirus vlog The antivirus log records virus incidents in Web, FTP, and email
traffic.
12 Dataset Reference
Fortinet Inc.
Log Database Tables
Webfilter wlog The web filter log records HTTP FortiGate log rating errors
including web content blocking actions that the FortiGate unit
performs.
Attack attack_log The attack log records attacks that are detected and prevented
by the FortiGate unit.
Data Leak Prevention dlog The Data Leak Prevention log records log data that is con-
sidered sensitive and that should not be made public. This log
also records data that a company does not want entering their
network.
Application Control rlog The application control log records data detected by the
FortiGate unit and the action taken against the network traffic
depending on the application that is generating the traffic, for
example, instant messaging software, such as MSN Mes-
senger.
Spamfilter spamfilter_log The spam filter log records blocking of email address patterns
and content in SMTP, IMAP, and POP3 traffic.
Content clog The content log records all network content that is transmitted
through the network.
Netscan nlog The netscan log records data related to network security and
scan.
Sniffer xlog The sniffer log records each packet raw data for traffic bot-
tlenecks.
VOIP plog The VOIP log records detailed protocol specific logs for VOIP
traffic.
To view all the tables created in a database, use the following commands:
FortiAnalyzer and FortiGate logs also include log sub-types, which are types of log messages that are within the main
log type. For example, in the event log type there are the subtype admin log messages.
For more information on FortiGate Log Types and Messages, refer to the FortiOS/FortiGate Log Message Reference
Guide on the Fortinet Documentation Library at: docs.fortinet.com.
Dataset Reference 13
Fortinet Inc.
Log Database Tables
14 Dataset Reference
Fortinet Inc.
Log Database Tables
Dataset Reference 15
Fortinet Inc.
Dataset Reference List
The following table lists the available predefined data sets reported by FortiAnalyzer. For documentation and technical
support reference purposes, this table contains the dataset names, SQL query syntax for each dataset, and the log
category of the dataset.
select
$flex_timescale as hodex,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
hodex
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
hodex
16 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
$flex_timescale as hodex,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
hodex
order by
hodex
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
Dataset Reference 17
Fortinet Inc.
Dataset Reference List
select
app_group_name(app) as app_group,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
app_group
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
order by
sessions desc
18 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
app_group_name(app) as app_group,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
app_group
order by
sessions desc
select
coalesce(
nullifna(
root_domain(hostname)
),
ipstr(dstip)
) as domain,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
domain
order by
sessions desc
Dataset Reference 19
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(
root_domain(hostname)
),
ipstr(dstip)
) as domain,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and coalesce(
nullifna(
root_domain(hostname)
),
ipstr(`dstip`)
) is not null
group by
domain
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
20 Dataset Reference
Fortinet Inc.
Dataset Reference List
drop
table if exists pre_clt_list;
drop
table if exists cur_clt_list;
drop
table if exists allocated_ip; create temporary table pre_clt_list as ###
(select concat(interface, '.', devid) as intf, mac from $log where $last3day_
period $filter and logid_to_int(logid) = 26001 and dhcp_msg = 'Ack' group by
interface, devid, mac)###; create temporary table cur_clt_list as ###(select con-
cat(interface, '.', devid) as intf, mac from $log where $filter and logid_to_int
(logid) = 26001 and dhcp_msg = 'Ack' group by interface, devid, mac)###; create
temporary table allocated_ip as select distinct on (1) intf, cast
(used*100.0/total as decimal(18,2)) as percent_of_allocated_ip from ###(select
distinct on (1) concat(interface, '.', devid) as intf, used, total, itime from
$log where $filter and logid_to_int(logid)=26003 and total>0 order by 1, itime
desc)### t order by 1, itime desc; select t1.intf as interface, percent_of_alloc-
ated_ip, new_cli_count from allocated_ip t1 inner join (select intf, count(mac)
as new_cli_count from cur_clt_list where not exists (select 1 from pre_clt_list
where cur_clt_list.mac=pre_clt_list.mac) group by intf) t2 on t1.intf=t2.intf
order by interface, percent_of_allocated_ip desc
Dataset Reference 21
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
srcssid,
devtype,
coalesce(
nullifna(`srcname`),
`srcmac`
) as hostname_mac,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
group by
user_src,
srcssid,
devtype,
hostname_mac
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
hodex,
count(
distinct(user_src)
) as total_user
from
###(select $flex_timescale as hodex, coalesce(nullifna(`user`), nullifna(`un-
authuser`), ipstr(`srcip`)) as user_src from $log where $filter and logid_to_int
(logid) not in (4, 7, 14) group by hodex, user_src order by hodex)### t group by
hodex order by hodex
22 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
hostname,
catdesc,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
and hostname is not null
and (
utmaction not in ('block', 'blocked')
or action != 'deny'
)
group by
hostname,
catdesc
order by
requests desc
Dataset Reference 23
Fortinet Inc.
Dataset Reference List
select
domain,
string_agg(distinct catdesc, ', ') as agg_catdesc,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
###(select coalesce(nullifna(hostname), ipstr(`srcip`)) as domain, catdesc,
sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvd-
byte, 0)) as traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out from $log-
traffic where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and utmaction!='blocked' group by domain, catdesc having sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0))>0 order by bandwidth desc)### union all ###(select
coalesce(nullifna(hostname), ipstr(`srcip`)) as domain, catdesc, sum(coalesce
(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as
traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out from $log-webfilter where
$filter and (eventtype is null or logver = 52) and action!='blocked' group by
domain, catdesc having sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0))>0 order
by bandwidth desc)###) t group by domain, catdesc order by bandwidth desc
select
hostname,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
and hostname is not null
and (
utmaction in ('block', 'blocked')
or action = 'deny'
)
group by
hostname
order by
requests desc
24 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
devtype,
srcname,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
group by
user_src,
devtype,
srcname
order by
requests desc
Dataset Reference 25
Fortinet Inc.
Dataset Reference List
select
appid,
hostname,
catdesc,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
and hostname is not null
group by
appid,
hostname,
catdesc
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
26 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
devtype,
srcname,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
and (
utmaction in ('block', 'blocked')
or action = 'deny'
)
group by
user_src,
devtype,
srcname
order by
requests desc
Dataset Reference 27
Fortinet Inc.
Dataset Reference List
select
user_src,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as band-
width, sum(coalesce(rcvdbyte, 0)) as traffic_in, sum(coalesce(sentbyte, 0)) as
traffic_out from $log-traffic where $filter and logid_to_int(logid) not in (4,
7, 14) and utmevent in ('webfilter', 'banned-word', 'web-content', 'command-
block', 'script-filter') group by user_src having sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0))>0 order by bandwidth desc)### union all ###(select coalesce
(nullifna(`user`), ipstr(`srcip`)) as user_src, sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in, sum
(coalesce(sentbyte, 0)) as traffic_out from $log-webfilter where $filter and
(eventtype is null or logver = 52) group by user_src having sum(coalesce(sent-
byte, 0)+coalesce(rcvdbyte, 0))>0 order by bandwidth desc)###) t group by user_
src order by bandwidth desc
28 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
devtype,
srcname,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and utmevent in (
'webfilter', 'banned-word', 'web-content',
'command-block', 'script-filter'
)
group by
user_src,
devtype,
srcname
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
Dataset Reference 29
Fortinet Inc.
Dataset Reference List
select
appid,
hostname,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and catdesc in ('Streaming Media and Download')
group by
appid,
hostname
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
30 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and service in (
'smtp', 'SMTP', '25/tcp', '587/tcp',
'smtps', 'SMTPS', '465/tcp'
)
group by
user_src
order by
requests desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as requests
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and service in (
'pop3', 'POP3', '110/tcp', 'imap',
'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp'
)
group by
user_src
order by
requests desc
Dataset Reference 31
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and service in (
'smtp', 'SMTP', '25/tcp', '587/tcp',
'smtps', 'SMTPS', '465/tcp'
)
group by
user_src
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
32 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and service in (
'pop3', 'POP3', '110/tcp', 'imap',
'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp'
)
group by
user_src
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
virus,
(
case when virus like 'Riskware%' then 'Spyware' when virus like 'Adware%'
then 'Adware' else 'Virus' end
) as malware_type,
sum(totalnum) as totalnum
from
(
###(select virus, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by virus order by totalnum desc)### union all ###(select virus, count
(*) as totalnum from $log-virus where $filter and (eventtype is null or logver =
52) and nullifna(virus) is not null group by virus order by totalnum desc)###) t
group by virus, malware_type order by totalnum desc
Dataset Reference 33
Fortinet Inc.
Dataset Reference List
select
virus,
(
case when virus like 'Riskware%' then 'Spyware' when virus like 'Adware%'
then 'Adware' else 'Virus' end
) as malware_type,
sum(totalnum) as totalnum
from
(
###(select virus, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by virus order by totalnum desc)### union all ###(select virus, count
(*) as totalnum from $log-virus where $filter and (eventtype is null or logver =
52) and nullifna(virus) is not null group by virus order by totalnum desc)###) t
group by virus, malware_type order by totalnum desc
select
user_src,
sum(totalnum) as totalnum
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by user_src order by totalnum desc)### union all ###(select coalesce
(nullifna(`user`), ipstr(`srcip`)) as user_src, count(*) as totalnum from $log-
virus where $filter and (eventtype is null or logver = 52) and nullifna(virus)
is not null group by user_src order by totalnum desc)###) t group by user_src
order by totalnum desc
select
coalesce(
nullifna(`user`),
ipstr(`srcip`)
) as user_src,
count(*) as totalnum
from
$log
where
$filter
group by
user_src
order by
totalnum desc
34 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
dstip,
count(*) as totalnum
from
$log
where
$filter
and dstip is not null
group by
dstip
order by
totalnum desc
select
vpn_name,
sum(traffic_in + traffic_out) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
remip,
tunnelid,
vpn_name,
max(traffic_in) as traffic_in,
max(traffic_out) as traffic_out
from
###(select devid, vd, remip, vpn_trim(vpntunnel) as vpn_name, tunnelid,
max(coalesce(sentbyte, 0)) as traffic_out, max(coalesce(rcvdbyte, 0)) as
traffic_in from $log where $filter and subtype='vpn' and tunneltype like
'ipsec%' and (tunnelip is null or (tunnelip='0.0.0.0' and coalesce(logver, 0)!-
!=52)) and action in ('tunnel-stats', 'tunnel-down') and tunnelid is not null
group by devid, vd, remip, vpn_name, tunnelid)### t group by devid, vd, remip,
vpn_name, tunnelid) tt group by vpn_name having sum(traffic_in+traffic_out)>0
order by bandwidth desc
Dataset Reference 35
Fortinet Inc.
Dataset Reference List
select
user_src,
remip as remote_ip,
from_dtime(
min(s_time)
) as start_time,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
remip,
user_src,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, remip, coalesce(nullifna(`user`), ipstr(`remip`)) as
user_src, tunnelid, min(coalesce(dtime, 0)) as s_time, max(coalesce(dtime, 0))
as e_time, min(coalesce(sentbyte, 0)) as min_traffic_out, min(coalesce(rcvdbyte,
0)) as min_traffic_in, max(coalesce(sentbyte, 0)) as max_traffic_out, max
(coalesce(rcvdbyte, 0)) as max_traffic_in from $log where $filter and sub-
type='vpn' and tunneltype='ssl-tunnel' and action in ('tunnel-stats', 'tunnel-
down', 'tunnel-up') and coalesce(nullifna(`user`), ipstr(`remip`)) is not null
and tunnelid is not null group by devid, vd, user_src, remip, tunnelid)### t
group by devid, vd, user_src, remip, tunnelid) tt group by user_src, remote_ip
having sum(bandwidth)>0 order by bandwidth desc
36 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
vpn_name,
sum(traffic_out + traffic_in) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
tunnelid,
remip,
vpn_name,
max(traffic_in) as traffic_in,
max(traffic_out) as traffic_out
from
###(select devid, vd, remip, vpn_trim(vpntunnel) as vpn_name, tunnelid,
max(coalesce(sentbyte, 0)) as traffic_out, max(coalesce(rcvdbyte, 0)) as
traffic_in from $log where $filter and nullifna(vpntunnel) is not null and sub-
type='vpn' and tunneltype like 'ipsec%' and not (tunnelip is null or (tun-
nelip='0.0.0.0' and coalesce(logver, 0)!=52)) and action in ('tunnel-stats',
'tunnel-down') and tunnelid is not null group by devid, vd, remip, vpn_name, tun-
nelid)### t group by devid, vd, remip, vpn_name, tunnelid) tt group by vpn_name
having sum(traffic_out+traffic_in)>0 order by bandwidth desc
Dataset Reference 37
Fortinet Inc.
Dataset Reference List
select
coalesce(
xauthuser_agg,
user_agg,
ipstr(`remip`)
) as user_src,
remip,
from_dtime(
min(s_time)
) as start_time,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
string_agg(distinct xauthuser_agg, ' ') as xauthuser_agg,
string_agg(distinct user_agg, ' ') as user_agg,
remip,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, nullifna(`xauthuser`) as xauthuser_agg, nullifna
(`user`) as user_agg, remip, tunnelid, min(coalesce(dtime, 0)) as s_time, max
(coalesce(dtime, 0)) as e_time, min(coalesce(sentbyte, 0)) as min_traffic_out,
min(coalesce(rcvdbyte, 0)) as min_traffic_in, max(coalesce(sentbyte, 0)) as max_
traffic_out, max(coalesce(rcvdbyte, 0)) as max_traffic_in from $log where $fil-
ter and subtype='vpn' and tunneltype like 'ipsec%' and not (tunnelip is null or
(tunnelip='0.0.0.0' and coalesce(logver, 0)!=52)) and action in ('tunnel-stats',
'tunnel-down', 'tunnel-up') and tunnelid is not null group by devid, vd, xau-
thuser_agg, user_agg, remip, tunnelid)### t group by devid, vd, remip, tunnelid)
tt group by user_src, remip having sum(bandwidth)>0 order by bandwidth desc
38 Dataset Reference
Fortinet Inc.
Dataset Reference List
Dataset Reference 39
Fortinet Inc.
Dataset Reference List
select
coalesce(
xauthuser_agg,
user_agg,
ipstr(`remip`)
) as user_src,
from_dtime(
min(s_time)
) as start_time,
sum(duration) as duration,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
remip,
string_agg(distinct xauthuser_agg, ' ') as xauthuser_agg,
string_agg(distinct user_agg, ' ') as user_agg,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_duration) else max(max_
duration)- min(min_duration) end
) as duration,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, remip, nullifna(`xauthuser`) as xauthuser_agg, nul-
lifna(`user`) as user_agg, tunnelid, min(coalesce(dtime, 0)) as s_time, max
(coalesce(dtime, 0)) as e_time, max(coalesce(duration,0)) as max_duration, min
(coalesce(duration,0)) as min_duration, min(coalesce(sentbyte, 0)) as min_
traffic_out, min(coalesce(rcvdbyte, 0)) as min_traffic_in, max(coalesce(sent-
byte, 0)) as max_traffic_out, max(coalesce(rcvdbyte, 0)) as max_traffic_in from
$log where $filter and subtype='vpn' and tunneltype like 'ipsec%' and not (tun-
nelip is null or (tunnelip='0.0.0.0' and coalesce(logver, 0)!=52)) and action
in ('tunnel-stats', 'tunnel-down', 'tunnel-up') and tunnelid is not null group
by devid, vd, remip, xauthuser_agg, user_agg, tunnelid order by tunnelid)### t
group by devid, vd, remip, tunnelid) tt group by user_src having sum(bandwidth)
>0 order by duration desc
40 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
user_src,
remip as remote_ip,
from_dtime(
min(s_time)
) as start_time,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
user_src,
remip,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, coalesce(nullifna(`user`), ipstr(`remip`)) as user_
src, remip, tunnelid, min(coalesce(dtime, 0)) as s_time, max(coalesce(dtime, 0))
as e_time, min(coalesce(sentbyte, 0)) as min_traffic_out, min(coalesce(rcvdbyte,
0)) as min_traffic_in, max(coalesce(sentbyte, 0)) as max_traffic_out, max
(coalesce(rcvdbyte, 0)) as max_traffic_in from $log where $filter and sub-
type='vpn' and tunneltype='ssl-web' and action in ('tunnel-stats', 'tunnel-
down', 'tunnel-up') and coalesce(nullifna(`user`), ipstr(`remip`)) is not null
and tunnelid is not null group by devid, vd, user_src, remip, tunnelid)### t
group by devid, vd, user_src, remip, tunnelid) tt group by user_src, remote_ip
having sum(bandwidth)>0 order by bandwidth desc
Dataset Reference 41
Fortinet Inc.
Dataset Reference List
select
user_src,
tunneltype,
sum(duration) as duration,
sum(traffic_out + traffic_in) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
remip,
user_src,
tunneltype,
tunnelid,
max(duration) as duration,
max(traffic_in) as traffic_in,
max(traffic_out) as traffic_out
from
###(select devid, vd, remip, coalesce(nullifna(`user`), ipstr(`remip`)) as
user_src, tunnelid, tunneltype, max(coalesce(duration, 0)) as duration, max
(coalesce(sentbyte, 0)) as traffic_out, max(coalesce(rcvdbyte, 0)) as traffic_in
from $log where $filter and subtype='vpn' and tunneltype like 'ssl%' and action
in ('tunnel-stats', 'tunnel-down') and coalesce(nullifna(`user`), ipstr
(`remip`)) is not null and tunnelid is not null group by devid, vd, remip, user_
src, tunnelid, tunneltype)### t group by devid, vd, remip, user_src, tunnelid,
tunneltype) tt group by user_src, tunneltype having sum(traffic_out+traffic_in)
>0 order by duration desc
42 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
xauthuser_agg,
user_agg,
ipstr(`remip`)
) as user_src,
t_type as tunneltype,
from_dtime(
min(s_time)
) as start_time,
sum(duration) as duration,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
remip,
string_agg(distinct xauthuser_agg, ' ') as xauthuser_agg,
string_agg(distinct user_agg, ' ') as user_agg,
t_type,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_duration) else max(max_
duration)- min(min_duration) end
) as duration,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, remip, nullifna(`xauthuser`) as xauthuser_agg, nul-
lifna(`user`) as user_agg, (case when tunneltype like 'ipsec%' then 'ipsec' else
tunneltype end) as t_type, tunnelid, min(coalesce(dtime, 0)) as s_time, max
(coalesce(dtime, 0)) as e_time, max(coalesce(duration,0)) as max_duration, min
(coalesce(duration,0)) as min_duration, min(coalesce(sentbyte, 0)) as min_
traffic_out, min(coalesce(rcvdbyte, 0)) as min_traffic_in, max(coalesce(sent-
byte, 0)) as max_traffic_out, max(coalesce(rcvdbyte, 0)) as max_traffic_in from
$log where $filter and subtype='vpn' and (tunneltype like 'ssl%' or (tunneltype
like 'ipsec%' and not (tunnelip is null or (tunnelip='0.0.0.0' and coalesce
(logver, 0)!=52)))) and action in ('tunnel-stats', 'tunnel-down', 'tunnel-up')
and tunnelid is not null group by devid, vd, remip, xauthuser_agg, user_agg, t_
type, tunnelid)### t group by devid, vd, remip, t_type, tunnelid) tt group by
user_src, tunneltype having sum(bandwidth)>0 order by duration desc
Dataset Reference 43
Fortinet Inc.
Dataset Reference List
select
hodex,
sum(total_num) as total_num
from
(
select
hodex,
devid,
vd,
remip,
tunnelid,
sum(tunnelup) as total_num,
max(traffic_in) as traffic_in,
max(traffic_out) as traffic_out
from
###(select $flex_timescale as hodex, devid, vd, remip, tunnelid, (case
when action='tunnel-up' then 1 else 0 end) as tunnelup, max(coalesce(sentbyte,
0)) as traffic_out, max(coalesce(rcvdbyte, 0)) as traffic_in from $log where
$filter and subtype='vpn' and (tunneltype like 'ipsec%' or tunneltype like
'ssl%') and action in ('tunnel-up', 'tunnel-stats', 'tunnel-down') and tunnelid
is not null group by hodex, action, devid, vd, remip, tunnelid)### t group by
hodex, devid, vd, remip, tunnelid having max(tunnelup) > 0 and max(traffic_in)
+max(traffic_out)>0 )tt group by hodex order by total_num desc
select
f_user,
tunneltype,
sum(total_num) as total_num
from
###(select coalesce(nullifna(`xauthuser`), `user`) as f_user, tunneltype,
count(*) as total_num from $log where $filter and subtype='vpn' and (tun-
neltype='ipsec' or left(tunneltype, 3)='ssl') and action in ('ssl-login-fail',
'ipsec-login-fail') and coalesce(nullifna(`xauthuser`), nullifna(`user`)) is not
null group by f_user, tunneltype)### t group by f_user, tunneltype order by
total_num desc
44 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
xauthuser_agg,
user_agg,
ipstr(`remip`)
) as f_user,
t_type as tunneltype,
from_dtime(
min(s_time)
) as start_time,
sum(total_num) as total_num,
sum(duration) as duration
from
(
select
string_agg(distinct xauthuser_agg, ' ') as xauthuser_agg,
string_agg(distinct user_agg, ' ') as user_agg,
t_type,
devid,
vd,
remip,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_duration) else max(max_
duration)- min(min_duration) end
) as duration,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out,
sum(tunnelup) as total_num
from
###(select nullifna(`xauthuser`) as xauthuser_agg, nullifna(`user`) as
user_agg, devid, vd, remip, (case when tunneltype like 'ipsec%' then 'ipsec'
else tunneltype end) as t_type, tunnelid, sum((case when action='tunnel-up' then
1 else 0 end)) as tunnelup, min(coalesce(dtime, 0)) as s_time, max(coalesce
(dtime, 0)) as e_time, max(coalesce(duration,0)) as max_duration, min(coalesce
(duration,0)) as min_duration, min(coalesce(sentbyte, 0)) as min_traffic_out,
min(coalesce(rcvdbyte, 0)) as min_traffic_in, max(coalesce(sentbyte, 0)) as max_
traffic_out, max(coalesce(rcvdbyte, 0)) as max_traffic_in from $log where $fil-
ter and subtype='vpn' and (tunneltype like 'ipsec%' or tunneltype like 'ssl%')
and action in ('tunnel-up', 'tunnel-stats', 'tunnel-down') and tunnelid is not
null group by xauthuser_agg, user_agg, devid, vd, remip, t_type, tunnelid)### t
group by t_type, devid, vd, remip, tunnelid having max(tunnelup) > 0) tt group
by f_user, tunneltype having sum(bandwidth) > 0 order by total_num desc
Dataset Reference 45
Fortinet Inc.
Dataset Reference List
select
hodex,
sum(ssl_traffic_out + ssl_traffic_in) as ssl_bandwidth,
sum(
ipsec_traffic_out + ipsec_traffic_in
) as ipsec_bandwidth
from
(
select
hodex,
devid,
vd,
remip,
tunnelid,
(
case when t_type like 'ssl%' then max(traffic_in) else 0 end
) as ssl_traffic_in,
(
case when t_type like 'ssl%' then max(traffic_out) else 0 end
) as ssl_traffic_out,
(
case when t_type like 'ipsec%' then max(traffic_in) else 0 end
) as ipsec_traffic_in,
(
case when t_type like 'ipsec%' then max(traffic_out) else 0 end
) as ipsec_traffic_out
from
###(select $flex_timescale as hodex, devid, vd, remip, tunnelid, (case
when tunneltype like 'ipsec%' then 'ipsec' else tunneltype end) as t_type, max
(coalesce(sentbyte, 0)) as traffic_out, max(coalesce(rcvdbyte, 0)) as traffic_in
from $log where $filter and subtype='vpn' and (tunneltype like 'ipsec%' or tun-
neltype like 'ssl%') and action in ('tunnel-stats', 'tunnel-down') and tunnelid
is not null group by hodex, devid, vd, remip, t_type, tunnelid)### t group by
hodex, devid, t_type, vd, remip, tunnelid ) tt group by hodex order by hodex
46 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
vpntunnel,
tunneltype,
sum(traffic_out) as traffic_out,
sum(traffic_in) as traffic_in,
sum(bandwidth) as bandwidth,
sum(uptime) as uptime
from
(
select
vpntunnel,
tunneltype,
tunnelid,
devid,
vd,
sum(sent_end - sent_beg) as traffic_out,
sum(rcvd_end - rcvd_beg) as traffic_in,
sum(
sent_end - sent_beg + rcvd_end - rcvd_beg
) as bandwidth,
sum(duration_end - duration_beg) as uptime
from
###(select tunnelid, tunneltype, vpntunnel, devid, vd, min(coalesce(sent-
byte, 0)) as sent_beg, max(coalesce(sentbyte, 0)) as sent_end, min(coalesce(rcvd-
byte, 0)) as rcvd_beg, max(coalesce(rcvdbyte, 0)) as rcvd_end, min(coalesce
(duration, 0)) as duration_beg, max(coalesce(duration, 0)) as duration_end from
$log where $filter and subtype='vpn' and action='tunnel-stats' and tunneltype
like 'ipsec%' and (tunnelip is null or (tunnelip='0.0.0.0' and coalesce(logver,
0)!=52)) and nullifna(`user`) is null and tunnelid is not null group by tun-
nelid, tunneltype, vpntunnel, devid, vd order by tunnelid)### t group by vpn-
tunnel, tunneltype, tunnelid, devid, vd order by bandwidth desc) t group by
vpntunnel, tunneltype order by bandwidth desc
Dataset Reference 47
Fortinet Inc.
Dataset Reference List
select
user_src,
remip,
sum(traffic_out) as traffic_out,
sum(traffic_in) as traffic_in,
sum(bandwidth) as bandwidth,
sum(uptime) as uptime
from
(
select
user_src,
remip,
tunnelid,
devid,
vd,
sum(sent_end - sent_beg) as traffic_out,
sum(rcvd_end - rcvd_beg) as traffic_in,
sum(
sent_end - sent_beg + rcvd_end - rcvd_beg
) as bandwidth,
sum(duration_end - duration_beg) as uptime
from
###(select tunnelid, coalesce(nullifna(`xauthuser`), nullifna(`user`),
ipstr(`remip`)) as user_src, remip, devid, vd, min(coalesce(sentbyte, 0)) as
sent_beg, max(coalesce(sentbyte, 0)) as sent_end, min(coalesce(rcvdbyte, 0)) as
rcvd_beg, max(coalesce(rcvdbyte, 0)) as rcvd_end, min(coalesce(duration, 0)) as
duration_beg, max(coalesce(duration, 0)) as duration_end from $log where $filter
and subtype='vpn' and action='tunnel-stats' and tunneltype like 'ipsec%' and not
(tunnelip is null or (tunnelip='0.0.0.0' and coalesce(logver, 0)!=52)) and tun-
nelid is not null group by tunnelid, user_src, remip, devid, vd order by tun-
nelid)### t group by user_src, remip, tunnelid, devid, vd order by bandwidth
desc) t group by user_src, remip order by bandwidth desc
48 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
user_src,
remote_ip,
sum(traffic_out) as traffic_out,
sum(traffic_in) as traffic_in,
sum(bandwidth) as bandwidth,
sum(uptime) as uptime
from
(
select
user_src,
remip as remote_ip,
tunnelid,
devid,
vd,
sum(sent_end - sent_beg) as traffic_out,
sum(rcvd_end - rcvd_beg) as traffic_in,
sum(
sent_end - sent_beg + rcvd_end - rcvd_beg
) as bandwidth,
sum(duration_end - duration_beg) as uptime
from
###(select tunnelid, coalesce(nullifna(`user`), ipstr(`remip`)) as user_
src, remip, devid, vd, min(coalesce(sentbyte, 0)) as sent_beg, max(coalesce(sent-
byte, 0)) as sent_end, min(coalesce(rcvdbyte, 0)) as rcvd_beg, max(coalesce(rcvd-
byte, 0)) as rcvd_end, min(coalesce(duration, 0)) as duration_beg, max(coalesce
(duration, 0)) as duration_end from $log where $filter and subtype='vpn' and
action='tunnel-stats' and tunneltype in ('ssl-tunnel', 'ssl') and coalesce(nul-
lifna(`user`), ipstr(`remip`)) is not null and tunnelid is not null group by tun-
nelid, user_src, remip, devid, vd order by tunnelid)### t group by user_src,
remote_ip, tunnelid, devid, vd order by bandwidth desc) t group by user_src,
remote_ip order by bandwidth desc
Dataset Reference 49
Fortinet Inc.
Dataset Reference List
select
user_src,
remote_ip,
sum(traffic_out) as traffic_out,
sum(traffic_in) as traffic_in,
sum(bandwidth) as bandwidth,
sum(uptime) as uptime
from
(
select
user_src,
remip as remote_ip,
tunnelid,
devid,
vd,
sum(sent_end - sent_beg) as traffic_out,
sum(rcvd_end - rcvd_beg) as traffic_in,
sum(
sent_end - sent_beg + rcvd_end - rcvd_beg
) as bandwidth,
sum(duration_end - duration_beg) as uptime
from
###(select tunnelid, coalesce(nullifna(`user`), ipstr(`remip`)) as user_
src, remip, devid, vd, min(coalesce(sentbyte, 0)) as sent_beg, max(coalesce(sent-
byte, 0)) as sent_end, min(coalesce(rcvdbyte, 0)) as rcvd_beg, max(coalesce(rcvd-
byte, 0)) as rcvd_end, min(coalesce(duration, 0)) as duration_beg, max(coalesce
(duration, 0)) as duration_end from $log where $filter and subtype='vpn' and
action='tunnel-stats' and tunneltype='ssl-web' and coalesce(nullifna(`user`),
ipstr(`remip`)) is not null and tunnelid is not null group by tunnelid, user_
src, remip, devid, vd order by tunnelid)### t group by user_src, remote_ip, tun-
nelid, devid, vd having sum(sent_end-sent_beg+rcvd_end-rcvd_beg)>0 order by band-
width desc) t group by user_src, remote_ip order by bandwidth desc
50 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
`user` as f_user,
ui,
sum(
case when logid_to_int(logid)= 32001 then 1 else 0 end
) as total_num,
sum(
case when logid_to_int(logid)= 32003 then duration else 0 end
) as total_duration,
count(state) as total_change
from
$log
where
$filter
and nullifna(`user`) is not null
and logid_to_int(logid) in (32001, 32003)
group by
f_user,
ui
having
sum(
case when logid_to_int(logid)= 32001 then 1 else 0 end
)> 0
order by
total_num desc
select
$flex_timescale as dom,
sum(
case when logid_to_int(logid)= 32001 then 1 else 0 end
) as total_num,
count(state) as total_change
from
$log
where
$filter
and nullifna(`user`) is not null
and logid_to_int(logid) in (32001, 32003)
group by
dom
having
sum(
case when logid_to_int(logid)= 32001 then 1 else 0 end
)> 0
order by
dom
Dataset Reference 51
Fortinet Inc.
Dataset Reference List
select
`user` as f_user,
ui,
count(status) as total_failed
from
$log
where
$filter
and nullifna(`user`) is not null
and logid_to_int(logid) = 32002
group by
ui,
f_user
order by
total_failed desc
select
(
case when level in ('critical', 'alert', 'emergency') then 'Critical' when
level = 'error' then 'High' when level = 'warning' then 'Medium' when level =
'notice' then 'Low' else 'Info' end
) as severity,
count(*) as total_num
from
$log
where
$filter
and subtype = 'system'
group by
severity
order by
total_num desc
52 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
$flex_timescale as dom,
sum(
case when level in ('critical', 'alert', 'emergency') then 1 else 0 end
) as critical,
sum(
case when level = 'error' then 1 else 0 end
) as high,
sum(
case when level = 'warning' then 1 else 0 end
) as medium,
sum(
case when level = 'notice' then 1 else 0 end
) as low,
sum(
case when level = 'information'
or level = 'debug' then 1 else 0 end
) as info
from
$log
where
$filter
and subtype = 'system'
group by
dom
order by
dom
select
msg_desc as msg,
severity,
sum(count) as counts
from
###(select coalesce(nullifna(logdesc), msg) as msg_desc, (case when level in
('critical', 'alert', 'emergency') then 'Critical' when level='error' then
'High' when level='warning' then 'Medium' when level='notice' then 'Low' else
'Info' end) as severity, count(*) as count from $log where $filter and sub-
type='system' group by msg_desc, severity order by count desc)### t where sever-
ity='Critical' group by msg, severity order by counts desc
Dataset Reference 53
Fortinet Inc.
Dataset Reference List
select
msg_desc as msg,
severity,
sum(count) as counts
from
###(select coalesce(nullifna(logdesc), msg) as msg_desc, (case when level in
('critical', 'alert', 'emergency') then 'Critical' when level='error' then
'High' when level='warning' then 'Medium' when level='notice' then 'Low' else
'Info' end) as severity, count(*) as count from $log where $filter and sub-
type='system' group by msg_desc, severity order by count desc)### t where sever-
ity='High' group by msg, severity order by counts desc
select
msg_desc as msg,
severity,
sum(count) as counts
from
###(select coalesce(nullifna(logdesc), msg) as msg_desc, (case when level in
('critical', 'alert', 'emergency') then 'Critical' when level='error' then
'High' when level='warning' then 'Medium' when level='notice' then 'Low' else
'Info' end) as severity, count(*) as count from $log where $filter and sub-
type='system' group by msg_desc, severity order by count desc)### t where sever-
ity='Medium' group by msg, severity order by counts desc
select
srcip,
srcname
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, srcip, srcname from $log where $filter-exclude-var and logid_to_int
(logid) not in (4, 7, 14) group by user_src, srcip, srcname)### t where $filter-
var-only group by srcip, srcname
54 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
appid,
app,
dstip,
sum(sessions) as sessions,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, appid, app, dstip, count(*) as sessions, sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and
logid_to_int(logid) not in (4, 7, 14) and dstip is not null and nullifna(app) is
not null group by user_src, appid, app, dstip having sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0))>0 order by bandwidth desc)### t where $filter-var-only
group by appid, app, dstip order by bandwidth desc
select
sum(requests) as requests,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and logid_to_int
(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP', '25/tcp', '587/tcp',
'smtps', 'SMTPS', '465/tcp') group by user_src, sender order by requests desc)
### t where $filter-var-only
select
sum(requests) as requests,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, recipient, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and logid_to_int
(logid) not in (4, 7, 14) and recipient is not null and service in ('pop3',
'POP3', '110/tcp', 'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp',
'pop3s', 'POP3S', '995/tcp') group by user_src, recipient order by requests
desc)### t where $filter-var-only
Dataset Reference 55
Fortinet Inc.
Dataset Reference List
select
recipient,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, recipient, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and logid_to_int
(logid) not in (4, 7, 14) and service in ('pop3', 'POP3', '110/tcp', 'imap',
'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S', '995/tcp')
group by user_src, recipient order by requests desc)### t where $filter-var-only
and recipient is not null group by recipient having sum(bandwidth)>0 order by
bandwidth desc
select
sender,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and logid_to_int
(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP', '25/tcp', '587/tcp',
'smtps', 'SMTPS', '465/tcp') group by user_src, sender order by requests desc)
### t where $filter-var-only and sender is not null group by sender having sum
(bandwidth)>0 order by bandwidth desc
56 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
appid,
hostname,
sum(bandwidth) as bandwidth
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, appid, hostname, (case when utmaction='blocked' then 1 else
0 end) as blocked, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth
from $log-traffic where $filter-exclude-var and logid_to_int(logid) not in (4,
7, 14) and utmevent in ('webfilter', 'banned-word', 'web-content', 'command-
block', 'script-filter') and hostname is not null group by user_src, appid, host-
name, blocked order by bandwidth desc)### union all ###(select coalesce(nullifna
(`user`), ipstr(`srcip`)) as user_src, 0 as appid, hostname, (case when action-
n='blocked' then 1 else 0 end) as blocked, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-webfilter where $filter-exclude-var and
(eventtype is null or logver = 52) and hostname is not null group by user_src,
appid, hostname, blocked order by bandwidth desc)###) t where $filter-var-only
and blocked=0 group by appid, hostname order by bandwidth desc
select
appid,
hostname,
sum(requests) as requests
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, appid, hostname, (case when utmaction='blocked' then 1 else
0 end) as blocked, count(*) as requests from $log-traffic where $filter-exclude-
var and logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter',
'banned-word', 'web-content', 'command-block', 'script-filter') and hostname is
not null group by user_src, appid, hostname, blocked order by requests desc)###
union all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, 0
as appid, hostname, (case when action='blocked' then 1 else 0 end) as blocked,
count(*) as requests from $log-webfilter where $filter-exclude-var and (event-
type is null or logver = 52) and hostname is not null group by user_src, appid,
hostname, blocked order by requests desc)###) t where $filter-var-only and
blocked=1 group by appid, hostname order by requests desc
Dataset Reference 57
Fortinet Inc.
Dataset Reference List
select
virus,
sum(totalnum) as totalnum
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, virus, count(*) as totalnum from $log-traffic where $filter-
exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent is not null
and virus is not null group by user_src, virus order by totalnum desc)### union
all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log-virus where $filter-exclude-var and (eventtype is
null or logver = 52) and nullifna(virus) is not null group by user_src, virus
order by totalnum desc)###) t where $filter-var-only group by virus order by
totalnum desc
select
attack,
sum(attack_count) as attack_count
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, attack,
count(*) as attack_count from $log where $filter-exclude-var and nullifna
(attack) is not null group by user_src, attack order by attack_count desc)### t
where $filter-var-only group by attack order by attack_count desc
select
vuln,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, vuln, count
(*) as totalnum from $log where $filter-exclude-var and action='vuln-detection'
and vuln is not null group by user_src, vuln order by totalnum desc)### t where
$filter-var-only group by vuln order by totalnum desc
58 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
appid,
app,
sum(bandwidth) as bandwidth
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, appid, app, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as
bandwidth, count(*) as sessions from $log where $filter-exclude-var and logid_
to_int(logid) not in (4, 7, 14) and nullifna(app) is not null group by user_src,
appid, app order by sessions desc)### t where $filter-var-only group by appid,
app having sum(bandwidth)>0 order by bandwidth desc
select
appid,
app,
sum(sessions) as sessions
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))
as user_src, appid, app, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as
bandwidth, count(*) as sessions from $log where $filter-exclude-var and logid_
to_int(logid) not in (4, 7, 14) and nullifna(app) is not null group by user_src,
appid, app order by sessions desc)### t where $filter-var-only group by appid,
app order by sessions desc
Dataset Reference 59
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as dldn_user,
count(*) as session,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
dldn_user
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
60 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
app_group_name(app) as app_group,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
app_group
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
appcat,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(appcat) is not null
group by
appcat
order by
bandwidth desc
Dataset Reference 61
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
hodex,
count(
distinct(user_src)
) as total_user
from
###(select $flex_timescale as hodex, coalesce(nullifna(`user`), nullifna(`un-
authuser`), ipstr(`srcip`)) as user_src from $log where $filter and logid_to_int
(logid) not in (4, 7, 14) group by hodex, user_src order by hodex)### t group by
hodex order by hodex
62 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(
root_domain(hostname)
),
ipstr(`dstip`)
) as domain,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
appid,
domain
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
Dataset Reference 63
Fortinet Inc.
Dataset Reference List
select
coalesce(
cast(poluuid as text),
cast(policyid as text)
) as polid,
sum(
coalesce(rcvdbyte, 0) + coalesce(sentbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
polid
order by
bandwidth desc
64 Dataset Reference
Fortinet Inc.
Dataset Reference List
drop
table if exists stats_temp; create temporary table stats_temp(
total_sessions varchar(255),
total_bandwidth varchar(255),
ave_session varchar(255),
ave_bandwidth varchar(255),
active_date varchar(255),
total_users varchar(255),
total_app varchar(255),
total_dest varchar(255)
); insert into stats_temp (
total_sessions, total_bandwidth,
ave_session, ave_bandwidth
)
select
format_numeric_no_decimal(
sum(sessions)
) as total_sessions,
bandwidth_unit(
sum(bandwidth)
) as total_bandwidth,
format_numeric_no_decimal(
cast(
sum(sessions)/ $days_num as decimal(18, 0)
)
) as ave_session,
bandwidth_unit(
cast(
sum(bandwidth)/ $days_num as decimal(18, 0)
)
) as ave_bandwidth
from
###(select count(*) as sessions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte,
0)) as bandwidth from $log where $filter and logid_to_int(logid) not in (4, 7,
14))### t; update stats_temp set active_date=t1.dom from (select dom, sum(ses-
sions) as sessions from ###(select $DAY_OF_MONTH as dom, count(*) as sessions
from $log where $filter and logid_to_int(logid) not in (4, 7, 14) group by dom
order by sessions)### t group by dom order by sessions desc limit 1) as t1;
update stats_temp set total_users=t2.totalnum from (select format_numeric_no_
decimal(count(distinct(user_src))) as totalnum from ###(select distinct(coalesce
(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`))) as user_src from
$log where $filter and logid_to_int(logid) not in (4, 7, 14))### t ) as t2;
update stats_temp set total_app=t3.totalnum from (select format_numeric_no_
decimal(count(distinct(app_group_name(app)))) as totalnum from ###(select dis-
tinct(app_group_name(app)) as app from $log where $filter and logid_to_int
(logid) not in (4, 7, 14))### t ) as t3; update stats_temp set total_dest-
t=t4.totalnum from (select format_numeric_no_decimal(count(distinct(dstip))) as
totalnum from ###(select distinct(dstip) as dstip from $log where $filter and
logid_to_int(logid) not in (4, 7, 14))### t ) as t4; select 'Total Sessions' as
summary, total_sessions as stats from stats_temp union all select 'Total Bytes
Transferred' as summary, total_bandwidth as stats from stats_temp union all
select 'Most Active Date By Sessions' as summary, active_date as stats from
stats_temp union all select 'Total Users' as summary, total_users as stats from
stats_temp union all select 'Total Applications' as summary, total_app as stats
from stats_temp union all select 'Total Destinations' as summary, total_dest as
stats from stats_temp union all select 'Average Sessions Per Day' as summary,
ave_session as stats from stats_temp union all select 'Average Bytes Per Day' as
summary,
Dataset ave_bandwidth as stats from stats_temp
Reference 65
Fortinet Inc.
Dataset Reference List
select
$flex_timescale as hodex,
sum(crscore % 65536) as scores
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
hodex
having
sum(crscore % 65536)> 0
order by
hodex
select
$flex_timescale as hodex,
sum(crscore % 65536) as scores,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
hodex
having
sum(crscore % 65536)> 0
order by
hodex
66 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(crscore % 65536) as scores
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
user_src
having
sum(crscore % 65536)> 0
order by
scores desc
select
devtype,
coalesce(
nullifna(`srcname`),
nullifna(`srcmac`),
ipstr(`srcip`)
) as dev_src,
sum(crscore % 65536) as scores
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
devtype,
dev_src
having
sum(crscore % 65536)> 0
order by
scores desc
Dataset Reference 67
Fortinet Inc.
Dataset Reference List
drop
table if exists prd1_usr_tbl;
drop
table if exists prd2_usr_tbl; create temporary table prd1_usr_tbl as ###
(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`srcip`)) as f_
user, sum(crscore%65536) as sum_rp_score from $log where $pre_period $filter and
logid_to_int(logid) not in (4, 7, 14) and crscore is not null group by f_user
having sum(crscore%65536)>0 order by sum_rp_score desc)###; create temporary
table prd2_usr_tbl as ###(select coalesce(nullifna(`user`), nullifna(`un-
authuser`), ipstr(`srcip`)) as f_user, sum(crscore%65536) as sum_rp_score from
$log where $filter and logid_to_int(logid) not in (4, 7, 14) and crscore is not
null group by f_user having sum(crscore%65536)>0 order by sum_rp_score desc)###;
select t1.f_user, sum(t1.sum_rp_score) as t1_sum_score, sum(t2.sum_rp_score) as
t2_sum_score, (sum(t2.sum_rp_score)-sum(t1.sum_rp_score)) as delta from prd1_
usr_tbl as t1 inner join prd2_usr_tbl as t2 on t1.f_user=t2.f_user where t2.sum_
rp_score > t1.sum_rp_score group by t1.f_user order by delta desc
drop
table if exists prd1_dev_tbl;
drop
table if exists prd2_dev_tbl; create temporary table prd1_dev_tbl as ###
(select coalesce(nullifna(`srcname`),nullifna(`srcmac`), ipstr(`srcip`)) as f_
device, devtype, sum(crscore%65536) as sum_rp_score from $log where $pre_period
$filter and logid_to_int(logid) not in (4, 7, 14) and crscore is not null group
by f_device, devtype having sum(crscore%65536)>0 order by sum_rp_score desc)###;
create temporary table prd2_dev_tbl as ###(select coalesce(nullifna(`sr-
cname`),nullifna(`srcmac`), ipstr(`srcip`)) as f_device, devtype, sum
(crscore%65536) as sum_rp_score from $log where $filter and logid_to_int(logid)
not in (4, 7, 14) and crscore is not null group by f_device, devtype having sum
(crscore%65536)>0 order by sum_rp_score desc)###; select t1.f_device, t1.devtype
, sum(t1.sum_rp_score) as t1_sum_score, sum(t2.sum_rp_score) as t2_sum_score,
(sum(t2.sum_rp_score)-sum(t1.sum_rp_score)) as delta from prd1_dev_tbl as t1
inner join prd2_dev_tbl as t2 on t1.f_device=t2.f_device and t1.dev-
type=t2.devtype where t2.sum_rp_score > t1.sum_rp_score group by t1.f_device,
t1.devtype order by delta desc
68 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
(
case when severity = 'critical' then 'Critical' when severity = 'high' then
'High' when severity = 'medium' then 'Medium' when severity = 'low' then 'Low'
when severity = 'info' then 'Info' end
) as severity,
count(*) as totalnum
from
$log
where
$filter
group by
severity
order by
totalnum desc
select
attack,
severity,
sum(attack_count) as attack_count
from
###(select attack, severity, (case when severity = 'critical' then 1 when
severity = 'high' then 2 when severity = 'medium' then 3 when severity = 'low'
then 4 else 5 end) as severity_level, count(*) as attack_count from $log where
$filter and nullifna(attack) is not null group by attack, severity, severity_
level order by severity_level, attack_count desc)### t group by attack, sever-
ity, severity_level order by severity_level, attack_count desc
select
attack,
count(*) as attack_count
from
$log
where
$filter
and nullifna(attack) is not null
and action in (
'deny', 'blocked', 'reset', 'dropped'
)
group by
attack
order by
attack_count desc
Dataset Reference 69
Fortinet Inc.
Dataset Reference List
select
srcip,
hostname,
sum(totalnum) as totalnum
from
(
###(select srcip, hostname, count(*) as totalnum from $log-traffic where
$filter and logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and
virus is not null group by srcip, hostname order by totalnum desc)### union all
###(select srcip , ipstr(`dstip`) as hostname, count(*) as totalnum from $log-
virus where $filter and (eventtype is null or logver = 52) and nullifna(virus)
is not null group by srcip, hostname order by totalnum desc)###) t group by
srcip, hostname order by totalnum desc
select
$flex_timescale as hodex,
count(*) as totalnum
from
$log
where
$filter
group by
hodex
order by
hodex
select
hodex,
sum(totalnum) as totalnum
from
(
###(select $flex_timescale as hodex, count(*) as totalnum from $log-traffic
where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent is not null
and virus is not null group by hodex order by hodex desc)### union all ###
(select $flex_timescale as hodex, count(*) as totalnum from $log-virus where
$filter and (eventtype is null or logver = 52) and nullifna(virus) is not null
group by hodex order by hodex desc)###) t group by hodex order by hodex desc
70 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
user_src,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log where $filter group by user_src, virus order by
totalnum desc)### t where virus like 'Riskware%' group by user_src order by
totalnum desc
select
virus,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log where $filter group by user_src, virus order by
totalnum desc)### t where virus like 'Riskware%' group by virus order by total-
num desc
select
srcip,
hostname,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and virus like 'Riskware%'
group by
srcip,
hostname
order by
totalnum desc
Dataset Reference 71
Fortinet Inc.
Dataset Reference List
select
$flex_timescale as hodex,
count(*) as totalnum
from
$log
where
$filter
and virus like 'Riskware%'
group by
hodex
order by
hodex desc
select
user_src,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log where $filter group by user_src, virus order by
totalnum desc)### t where virus like 'Adware%' group by user_src order by total-
num desc
select
virus,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log where $filter group by user_src, virus order by
totalnum desc)### t where virus like 'Adware%' group by virus order by totalnum
desc
72 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
srcip,
hostname,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and virus like 'Adware%'
group by
srcip,
hostname
order by
totalnum desc
select
$flex_timescale as hodex,
count(*) as totalnum
from
$log
where
$filter
and virus like 'Adware%'
group by
hodex
order by
hodex desc
Dataset Reference 73
Fortinet Inc.
Dataset Reference List
select
$flex_timescale as timescale,
(
case when severity = 'critical' then 'Critical' when severity = 'high' then
'High' when severity = 'medium' then 'Medium' when severity = 'low' then 'Low'
when severity = 'info' then 'Info' end
) as severity,
count(*) as totalnum
from
$log
where
$filter
group by
timescale,
severity
order by
timescale
select
vuln_type,
count(*) as totalnum
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and vuln_type is not null
group by
vuln_type
order by
totalnum desc
74 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
attack,
vuln_type,
count(*) as totalnum
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and t1.severity = 'critical'
group by
attack,
vuln_type
order by
totalnum desc
select
attack,
vuln_type,
count(*) as totalnum
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and t1.severity = 'high'
group by
attack,
vuln_type
order by
totalnum desc
Dataset Reference 75
Fortinet Inc.
Dataset Reference List
select
attack,
vuln_type,
count(*) as totalnum
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and t1.severity = 'medium'
group by
attack,
vuln_type
order by
totalnum desc
select
attack,
vuln_type,
count(*) as totalnum
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and t1.severity = 'low'
group by
attack,
vuln_type
order by
totalnum desc
select
victim,
sum(cri_num) as critical,
sum(high_num) as high,
sum(med_num) as medium,
sum(cri_num + high_num + med_num) as totalnum
from
###(select dstip as victim, sum((case when severity='critical' then 1 else 0
end)) as cri_num, sum(case when severity='high' then 1 else 0 end) as high_num,
sum(case when severity='medium' then 1 else 0 end) as med_num from $log where
$filter and severity in ('critical', 'high', 'medium') group by victim)### t
group by victim order by totalnum desc
76 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
source,
sum(cri_num) as critical,
sum(high_num) as high,
sum(med_num) as medium,
sum(cri_num + high_num + med_num) as totalnum
from
###(select srcip as source, sum(case when severity='critical' then 1 else 0
end) as cri_num, sum(case when severity='high' then 1 else 0 end) as high_num,
sum(case when severity='medium' then 1 else 0 end) as med_num from $log where
$filter and severity in ('critical', 'high', 'medium') group by source)### t
group by source order by totalnum desc
select
attack,
(
case when t1.severity = 'critical' then 'Critical' when t1.severity = 'high'
then 'High' when t1.severity = 'medium' then 'Medium' when t1.severity = 'low'
then 'Low' when t1.severity = 'info' then 'Info' end
) as severity_name,
count(*) as totalnum,
vuln_type,
(
case when t1.severity = 'critical' then 0 when t1.severity = 'high' then 1
when t1.severity = 'medium' then 2 when t1.severity = 'low' then 3 when t1.-
severity = 'info' then 4 else 5 end
) as severity_number
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and nullifna(attack) is not null
and action in (
'deny', 'blocked', 'reset', 'dropped'
)
group by
attack,
t1.severity,
vuln_type
order by
severity_number,
totalnum desc
Dataset Reference 77
Fortinet Inc.
Dataset Reference List
select
attack,
(
case when t1.severity = 'critical' then 'Critical' when t1.severity = 'high'
then 'High' when t1.severity = 'medium' then 'Medium' when t1.severity = 'low'
then 'Low' when t1.severity = 'info' then 'Info' end
) as severity_name,
count(*) as totalnum,
vuln_type,
(
case when t1.severity = 'critical' then 0 when t1.severity = 'high' then 1
when t1.severity = 'medium' then 2 when t1.severity = 'low' then 3 when t1.-
severity = 'info' then 4 else 5 end
) as severity_number
from
$log t1
left join ips_mdata t2 on t1.attack = t2.name
where
$filter
and nullifna(attack) is not null
and action not in (
'deny', 'blocked', 'reset', 'dropped'
)
group by
attack,
t1.severity,
vuln_type
order by
severity_number,
totalnum desc
78 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
attack,
(
case when severity = 'critical' then 'Critical' when severity = 'high' then
'High' when severity = 'medium' then 'Medium' when severity = 'low' then 'Low'
when severity = 'info' then 'Info' end
) as severity,
count(*) as totalnum,
(
case when severity = 'critical' then 0 when severity = 'high' then 1 when
severity = 'medium' then 2 when severity = 'low' then 3 when severity = 'info'
then 4 else 5 end
) as severity_number
from
$log
where
$filter
and severity in ('critical', 'high', 'medium')
and upper(service) in ('HTTP', 'HTTPS')
group by
attack,
severity,
severity_number
order by
severity_number,
totalnum desc
select
(
case apstatus when 1 then 'rogue' when 2 then 'accepted' when 3 then 'sup-
pressed' else 'others' end
) as ap_full_status,
count(*) as totalnum
from
(
select
apstatus,
bssid,
ssid
from
###(select apstatus, bssid, ssid, count(*) as subtotal from $log where
$filter and apstatus is not null and apstatus!=0 and bssid is not null and
onwire='no' and logid_to_int(logid) in (43527, 43521, 43525) group by apstatus,
bssid, ssid order by subtotal desc)### t group by apstatus, bssid, ssid) t group
by ap_full_status order by totalnum desc
Dataset Reference 79
Fortinet Inc.
Dataset Reference List
select
(
case apstatus when 1 then 'rogue' when 2 then 'accepted' when 3 then 'sup-
pressed' else 'others' end
) as ap_full_status,
count(*) as totalnum
from
(
select
apstatus,
bssid,
ssid
from
###(select apstatus, bssid, ssid, count(*) as subtotal from $log where
$filter and apstatus is not null and apstatus!=0 and bssid is not null and
onwire='no' and logid_to_int(logid) in (43527, 43521, 43525) group by apstatus,
bssid, ssid order by subtotal desc)### t group by apstatus, bssid, ssid) t group
by ap_full_status order by totalnum desc
select
(
case apstatus when 1 then 'rogue' when 2 then 'accepted' when 3 then 'sup-
pressed' else 'others' end
) as ap_full_status,
count(*) as totalnum
from
(
select
apstatus,
bssid,
ssid
from
###(select apstatus, bssid, ssid, count(*) as subtotal from $log where
$filter and apstatus is not null and apstatus!=0 and bssid is not null and
onwire='yes' and logid_to_int(logid) in (43527, 43521, 43525) group by apstatus,
bssid, ssid order by subtotal desc)### t group by apstatus, bssid, ssid) t group
by ap_full_status order by totalnum desc
80 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
(
case apstatus when 1 then 'rogue' when 2 then 'accepted' when 3 then 'sup-
pressed' else 'others' end
) as ap_full_status,
count(*) as totalnum
from
(
select
apstatus,
bssid,
ssid
from
###(select apstatus, bssid, ssid, count(*) as subtotal from $log where
$filter and apstatus is not null and apstatus!=0 and bssid is not null and
onwire='yes' and logid_to_int(logid) in (43527, 43521, 43525) group by apstatus,
bssid, ssid order by subtotal desc)### t group by apstatus, bssid, ssid) t group
by ap_full_status order by totalnum desc
select
(
case when (
action like '%join%'
and logid_to_int(logid)= 43522
) then 'Authorized' else 'Unauthorized' end
) as ap_status,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid)= 43522
group by
ap_status
order by
totalnum desc
Dataset Reference 81
Fortinet Inc.
Dataset Reference List
select
(
case when (
action like '%join%'
and logid_to_int(logid)= 43522
) then 'Authorized' else 'Unauthorized' end
) as ap_status,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid)= 43522
group by
ap_status
order by
totalnum desc
select
(
case onwire when 'no' then 'off-wire' when 'yes' then 'on-wire' else 'oth-
ers' end
) as ap_status,
count(*) as totalnum
from
###(select onwire, ssid, bssid, count(*) as subtotal from $log where $filter
and apstatus=0 and bssid is not null and logid_to_int(logid) in (43521, 43525,
43527) group by onwire, ssid, bssid order by subtotal desc)### t group by ap_
status order by totalnum desc
select
(
case onwire when 'no' then 'off-wire' when 'yes' then 'on-wire' else 'oth-
ers' end
) as ap_status,
count(*) as totalnum
from
###(select onwire, ssid, bssid, count(*) as subtotal from $log where $filter
and apstatus=0 and bssid is not null and logid_to_int(logid) in (43521, 43525,
43527) group by onwire, ssid, bssid order by subtotal desc)### t group by ap_
status order by totalnum desc
82 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
(
case apstatus when 0 then 'unclassified' when 1 then 'rogue' when 2 then
'accepted' when 3 then 'suppressed' else 'others' end
) as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
rssi,
channel,
radioband,
from_dtime(
min(dtime)
) as first_seen,
from_dtime(
max(dtime)
) as last_seen,
detectionmethod,
itime,
onwire as on_wire
from
$log
where
$filter
and apstatus is not null
and bssid is not null
and onwire = 'no'
and logid_to_int(logid)= 43521
group by
ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
rssi,
channel,
radioband,
detectionmethod,
itime,
onwire,
apstatus
Dataset Reference 83
Fortinet Inc.
Dataset Reference List
select
(
case apstatus when 0 then 'unclassified' when 1 then 'rogue' when 2 then
'accepted' when 3 then 'suppressed' else 'others' end
) as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
rssi,
channel,
radioband,
from_dtime(
min(dtime)
) as first_seen,
from_dtime(
max(dtime)
) as last_seen,
detectionmethod,
itime,
onwire as on_wire
from
$log
where
$filter
and apstatus is not null
and bssid is not null
and onwire = 'yes'
and logid_to_int(logid)= 43521
group by
ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
rssi,
channel,
radioband,
detectionmethod,
itime,
onwire,
apstatus
84 Dataset Reference
Fortinet Inc.
Dataset Reference List
drop
table if exists ip_list; create temporary table ip_list as
select
ip,
lower(mac) as lmac,
sn,
ssid,
channel,
radioband,
min(dtime) as first,
max(dtime) as last
from
$log - event
where
$filter
and ip is not null
and mac is not null
and sn is not null
and ssid is not null
group by
ip,
lmac,
sn,
ssid,
channel,
radioband
order by
ip;
select
user_src,
ip,
lmac,
sn,
ssid,
channel,
radioband,
from_dtime(first) as first_seen,
from_dtime(last) as last_seen,
cast(
volume as decimal(18, 2)
) as bandwidth
from
(
select
*
from
ip_list
inner join (
select
user_src,
srcip,
sum(volume) as volume
from
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr
(`srcip`)) as user_src, srcip, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0))
as volume from $log-traffic where $filter-time and logid_to_int(logid) not in
(4, 7, 14) and srcip is not null group by user_src, srcip having sum(coalesce
(sentbyte,
Dataset Reference 0)+coalesce(rcvdbyte, 0))>0 order by volume desc)### t group by user_
85
Fortinet Inc.srcip order by user_src, srcip) t on ip_list.ip = t.srcip) t order by
src,
volume desc
Dataset Reference List
select
'accepted' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'no' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, logid, apstatus, max(dtime) as last_seen from $log where $fil-
ter and bssid is not null and logid_to_int(logid) in (43521, 43525) group by
devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest,
onwire, logid, apstatus order by last_seen desc)### t where apstatus=2 and
onwire='no' group by devid, vd, ssid, bssid, manuf, channel, radioband, detec-
tionmethod, snclosest order by last_seen desc
86 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
'accepted' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'yes' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, apstatus, max(dtime) as last_seen from $log where $filter and
bssid is not null and logid_to_int(logid) in (43521, 43525) group by devid, vd,
ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest, onwire,
apstatus order by last_seen desc)### t where apstatus=2 and onwire='yes' group
by devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest
order by last_seen desc
select
'rogue' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'no' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, logid, apstatus, max(dtime) as last_seen from $log where $fil-
ter and bssid is not null and logid in ('43521', '43525') group by devid, vd,
ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest, onwire,
logid, apstatus order by last_seen desc)### t where apstatus=1 and onwire='no'
group by devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest order by last_seen desc
Dataset Reference 87
Fortinet Inc.
Dataset Reference List
select
'rogue' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'yes' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, apstatus, max(dtime) as last_seen from $log where $filter and
bssid is not null and logid_to_int(logid) in (43521, 43525) group by devid, vd,
ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest, onwire,
apstatus order by last_seen desc)### t where apstatus=1 and onwire='yes' group
by devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest
order by last_seen desc
88 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
'suppressed' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'no' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, logid, apstatus, max(dtime) as last_seen from $log where $fil-
ter and bssid is not null and logid_to_int(logid) in (43521, 43525) group by
devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest,
onwire, logid, apstatus order by last_seen desc)### t where apstatus=3 and
onwire='no' group by devid, vd, ssid, bssid, manuf, channel, radioband, detec-
tionmethod, snclosest order by last_seen desc
select
'suppressed' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'yes' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, apstatus, max(dtime) as last_seen from $log where $filter and
bssid is not null and logid_to_int(logid) in (43521, 43525) group by devid, vd,
ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest, onwire,
apstatus order by last_seen desc)### t where apstatus=3 and onwire='yes' group
by devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest
order by last_seen desc
Dataset Reference 89
Fortinet Inc.
Dataset Reference List
select
'unclassified' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'no' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, logid, apstatus, max(dtime) as last_seen from $log where $fil-
ter and bssid is not null and logid_to_int(logid) in (43521, 43525) group by
devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest,
onwire, logid, apstatus order by last_seen desc)### t where apstatus=0 and
onwire='no' group by devid, vd, ssid, bssid, manuf, channel, radioband, detec-
tionmethod, snclosest order by last_seen desc
90 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
'unclassified' as ap_full_status,
devid,
vd,
ssid,
bssid,
manuf,
channel,
radioband,
from_dtime(
max(last_seen)
) as last_seen,
detectionmethod,
snclosest,
'yes' as on_wire
from
###(select devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod,
snclosest, onwire, apstatus, max(dtime) as last_seen from $log where $filter and
bssid is not null and logid_to_int(logid) in (43521, 43525) group by devid, vd,
ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest, onwire,
apstatus order by last_seen desc)### t where apstatus=0 and onwire='yes' group
by devid, vd, ssid, bssid, manuf, channel, radioband, detectionmethod, snclosest
order by last_seen desc
Dataset Reference 91
Fortinet Inc.
Dataset Reference List
select
coalesce(
xauthuser_agg,
user_agg,
ipstr(`remip`)
) as user_src,
from_dtime(
min(s_time)
) as start_time,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
select
devid,
vd,
string_agg(distinct xauthuser_agg, ' ') as xauthuser_agg,
string_agg(distinct user_agg, ' ') as user_agg,
remip,
tunnelid,
min(s_time) as s_time,
max(e_time) as e_time,
(
case when min(s_time)= max(e_time) then max(max_traffic_in)+ max(max_
traffic_out) else max(max_traffic_in)- min(min_traffic_in)+ max(max_traffic_out)
- min(min_traffic_out) end
) as bandwidth,
(
case when min(s_time)= max(e_time) then max(max_traffic_in) else max
(max_traffic_in)- min(min_traffic_in) end
) as traffic_in,
(
case when min(s_time)= max(e_time) then max(max_traffic_out) else max
(max_traffic_out)- min(min_traffic_out) end
) as traffic_out
from
###(select devid, vd, nullifna(`xauthuser`) as xauthuser_agg, nullifna
(`user`) as user_agg, remip, tunnelid, min(coalesce(dtime, 0)) as s_time, max
(coalesce(dtime, 0)) as e_time, min(coalesce(sentbyte, 0)) as min_traffic_out,
min(coalesce(rcvdbyte, 0)) as min_traffic_in, max(coalesce(sentbyte, 0)) as max_
traffic_out, max(coalesce(rcvdbyte, 0)) as max_traffic_in from $log where $fil-
ter and subtype='vpn' and tunneltype like 'ipsec%' and not (tunnelip is null or
(tunnelip='0.0.0.0' and coalesce(logver, 0)!=52)) and action in ('tunnel-
stats', 'tunnel-down', 'tunnel-up') and tunnelid is not null group by devid, vd,
xauthuser_agg, user_agg, remip, tunnelid order by tunnelid)### t group by devid,
vd, remip, tunnelid) tt group by user_src having sum(bandwidth)>0 order by band-
width desc
92 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
remip as remote_ip,
sum(traffic_in + traffic_out) as bandwidth
from
(
select
devid,
vd,
remip,
tunnelid,
max(traffic_in) as traffic_in,
max(traffic_out) as traffic_out
from
###(select devid, vd, remip, tunnelid, max(coalesce(sentbyte, 0)) as
traffic_out, max(coalesce(rcvdbyte, 0)) as traffic_in from $log where $filter
and subtype='vpn' and tunneltype like 'ssl%' and action in ('tunnel-stats', 'tun-
nel-down') and remip is not null and tunnelid is not null group by devid, vd,
remip, tunnelid order by tunnelid)### t group by devid, vd, remip, tunnelid) tt
group by remote_ip having sum(traffic_in+traffic_out)>0 order by bandwidth desc
select
hodex,
sum(allowed_request) as allowed_request,
sum(blocked_request) as blocked_request
from
(
###(select $flex_timescale as hodex, sum(case when utmaction!='blocked' then
1 else 0 end) as allowed_request, sum(case when utmaction='blocked' then 1 else
0 end) as blocked_request from $log-traffic where $filter and logid_to_int
(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-con-
tent', 'command-block', 'script-filter') group by hodex order by hodex)### union
all ###(select $flex_timescale as hodex, sum(case when action!='blocked' then 1
else 0 end) as allowed_request, sum(case when action='blocked' then 1 else 0
end) as blocked_request from $log-webfilter where $filter and (eventtype is null
or logver=52) group by hodex order by hodex)###) t group by hodex order by hodex
Dataset Reference 93
Fortinet Inc.
Dataset Reference List
select
hodex,
cast(
sum(delta)/ 60.0 as decimal(18, 2)
) as browsetime
from
###(select $flex_timescale as hodex, sum($browse_time) as delta from $log
where $filter and logid_to_int(logid) not in (4, 7, 14) group by hodex having
sum($browse_time)>0 order by delta desc)### t group by hodex order by hodex
select
hodex,
cast(
sum(delta)/ 60.0 as decimal(18, 2)
) as browsetime
from
###(select $flex_timescale as hodex, sum($browse_time2) as delta from $log
where $filter and logid_to_int(logid) not in (4, 7, 14) group by hodex having
sum($browse_time2)>0 order by delta desc)### t group by hodex order by hodex
select
user_src,
sum(requests) as requests
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, count(*) as requests from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-
word', 'web-content', 'command-block', 'script-filter') and coalesce(nullifna
(`user`), nullifna(`unauthuser`), ipstr(`srcip`)) is not null and utmac-
tion='blocked' group by user_src order by requests desc)### union all ###(select
coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, count(*) as requests
from $log-webfilter where $filter and (eventtype is null or logver = 52) and
coalesce(nullifna(`user`), ipstr(`srcip`)) is not null and action='blocked'
group by user_src order by requests desc)###) t group by user_src order by
requests desc
94 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
user_src,
sum(requests) as requests
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, count(*) as requests from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-
word', 'web-content', 'command-block', 'script-filter') and coalesce(nullifna
(`user`), nullifna(`unauthuser`), ipstr(`srcip`)) is not null and utmac-
tion!='blocked' group by user_src order by requests desc)### union all ###
(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, count(*) as
requests from $log-webfilter where $filter and (eventtype is null or logver =
52) and coalesce(nullifna(`user`), ipstr(`srcip`)) is not null and action!-
!='blocked' group by user_src order by requests desc)###) t group by user_src
order by requests desc
select
user_src,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, sum
($browse_time) as delta, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as
bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in, sum(coalesce(sentbyte, 0))
as traffic_out from $log where $filter group by user_src having sum($browse_
time)>0 order by delta desc)### t group by user_src order by browsetime desc
Dataset Reference 95
Fortinet Inc.
Dataset Reference List
select
domain,
catdesc,
sum(requests) as requests
from
(
###(select hostname as domain, catdesc, count(*) as requests from $log-
traffic where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null and utmaction='blocked' group by domain, catdesc order
by requests desc)### union all ###(select hostname as domain, catdesc, count(*)
as requests from $log-webfilter where $filter and (eventtype is null or logver =
52) and hostname is not null and catdesc is not null and action='blocked' group
by domain, catdesc order by requests desc)###) t group by domain, catdesc order
by requests desc
select
domain,
string_agg(distinct catdesc, ', ') as agg_catdesc,
sum(requests) as requests
from
(
###(select hostname as domain, catdesc, count(*) as requests from $log-
traffic where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null and utmaction!='blocked' group by domain, catdesc order
by requests desc)### union all ###(select hostname as domain, catdesc, count(*)
as requests from $log-webfilter where $filter and (eventtype is null or logver =
52) and hostname is not null and catdesc is not null and action!='blocked' group
by domain, catdesc order by requests desc)###) t group by domain order by
requests desc
96 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
domain,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
(
###(select coalesce(nullifna(root_domain(hostname)), 'other') as domain, sum
(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvd-
byte, 0)) as traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out from $log-
traffic where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and catdesc in ('Streaming Media and Download') group by domain having sum
(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0))>0 order by bandwidth desc)###
union all ###(select coalesce(nullifna(root_domain(hostname)), 'other') as
domain, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum
(coalesce(rcvdbyte, 0)) as traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out
from $log-webfilter where $filter and (eventtype is null or logver = 52) and cat-
desc in ('Streaming Media and Download') group by domain having sum(coalesce
(sentbyte, 0)+coalesce(rcvdbyte, 0))>0 order by bandwidth desc)###) t group by
domain order by bandwidth desc
select
catdesc,
sum(requests) as requests
from
(
###(select catdesc, count(*) as requests from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-
word', 'web-content', 'command-block', 'script-filter') and catdesc is not null
and utmaction='blocked' group by catdesc order by requests desc)### union all
###(select catdesc, count(*) as requests from $log-webfilter where $filter and
(eventtype is null or logver = 52) and catdesc is not null and action='blocked'
group by catdesc order by requests desc)###) t group by catdesc order by
requests desc
Dataset Reference 97
Fortinet Inc.
Dataset Reference List
select
catdesc,
sum(requests) as requests
from
(
###(select catdesc, count(*) as requests from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-
word', 'web-content', 'command-block', 'script-filter') and catdesc is not null
and utmaction!='blocked' group by catdesc order by requests desc)### union all
###(select catdesc, count(*) as requests from $log-webfilter where $filter and
(eventtype is null or logver = 52) and catdesc is not null and action!='blocked'
group by catdesc order by requests desc)###) t group by catdesc order by
requests desc
select
hostname,
string_agg(distinct catdesc, ', ') as agg_catdesc,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select hostname, catdesc, sum($browse_time) as delta, sum(coalesce(sent-
byte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as
traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter
and logid_to_int(logid) not in (4, 7, 14) and hostname is not null group by host-
name, catdesc having sum($browse_time)>0 order by delta desc)### t group by host-
name order by browsetime desc
98 Dataset Reference
Fortinet Inc.
Dataset Reference List
select
hostname,
string_agg(distinct catdesc, ', ') as agg_catdesc,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select hostname, catdesc, sum($browse_time2) as delta, sum(coalesce(sent-
byte, 0)+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as
traffic_in, sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter
and logid_to_int(logid) not in (4, 7, 14) and hostname is not null group by host-
name, catdesc having sum($browse_time2)>0 order by delta desc)### t group by
hostname order by browsetime desc
select
catdesc,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth
from
###(select catdesc, sum($browse_time) as delta, sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0)) as bandwidth from $log where $filter and logid_to_int
(logid) not in (4, 7, 14) and catdesc is not null group by catdesc having sum
($browse_time)>0 order by delta desc)### t group by catdesc order by browsetime
desc
select
catdesc,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth
from
###(select catdesc, sum($browse_time2) as delta, sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0)) as bandwidth from $log where $filter and logid_to_int
(logid) not in (4, 7, 14) and catdesc is not null group by catdesc having sum
($browse_time2)>0 order by delta desc)### t group by catdesc order by browsetime
desc
Dataset Reference 99
Fortinet Inc.
Dataset Reference List
select
dstcountry,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select dstcountry, sum($browse_time) as delta, sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in,
sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter and logid_to_
int(logid) not in (4, 7, 14) group by dstcountry having sum($browse_time)>0
order by delta desc)### t group by dstcountry order by browsetime desc
select
dstcountry,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select dstcountry, sum($browse_time2) as delta, sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in,
sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter and logid_to_
int(logid) not in (4, 7, 14) group by dstcountry having sum($browse_time2)>0
order by delta desc)### t group by dstcountry order by browsetime desc
select
keyword,
count(*) as requests
from
$log
where
$filter
and keyword is not null
group by
keyword
order by
requests desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum($browse_time) as browsetime
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum($browse_time)> 0
order by
browsetime desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum($browse_time2) as browsetime
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum($browse_time2)> 0
order by
browsetime desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum($browse_time) as browsetime
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum($browse_time)> 0
order by
browsetime desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum($browse_time2) as browsetime
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
user_src
having
sum($browse_time2)> 0
order by
browsetime desc
select
srcintf,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
group by
srcintf
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
srcintf,
count(distinct srcmac) as totalnum
from
###(select srcintf, srcssid, osname, osversion, devtype, srcmac, count(*) as
subtotal from $log where $filter and logid_to_int(logid) not in (4, 7, 14) and
(srcssid is not null or dstssid is not null) and srcmac is not null group by
srcintf, srcssid, osname, osversion, devtype, srcmac order by subtotal desc)###
t group by srcintf order by totalnum desc
select
srcssid,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and srcssid is not null
group by
srcssid
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
srcssid,
count(distinct srcmac) as totalnum
from
###(select srcintf, srcssid, osname, osversion, devtype, srcmac, count(*) as
subtotal from $log where $filter and logid_to_int(logid) not in (4, 7, 14) and
(srcssid is not null or dstssid is not null) and srcmac is not null group by
srcintf, srcssid, osname, osversion, devtype, srcmac order by subtotal desc)###
t where srcssid is not null group by srcssid order by totalnum desc
select
appid,
app,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
and nullifna(app) is not null
group by
appid,
app
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
(
coalesce(srcname, srcmac, 'unknown') || ' (' || coalesce(devtype, 'unknown')
|| ', ' || coalesce(osname, '') || (
case when osversion is null then '' else ' ' || osversion end
) || ')'
) as client,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
group by
client
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
(
coalesce(osname, 'unknown') || ' ' || coalesce(osversion, '')
) as os,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
group by
os
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
(
coalesce(osname, 'unknown') || ' ' || coalesce(osversion, '')
) as os,
count(distinct srcmac) as totalnum
from
###(select srcintf, srcssid, osname, osversion, devtype, srcmac, count(*) as
subtotal from $log where $filter and logid_to_int(logid) not in (4, 7, 14) and
(srcssid is not null or dstssid is not null) and srcmac is not null group by
srcintf, srcssid, osname, osversion, devtype, srcmac order by subtotal desc)###
t group by os order by totalnum desc
select
devtype,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
and devtype is not null
group by
devtype
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
devtype,
count(distinct srcmac) as totalnum
from
###(select srcintf, srcssid, osname, osversion, devtype, srcmac, count(*) as
subtotal from $log where $filter and logid_to_int(logid) not in (4, 7, 14) and
(srcssid is not null or dstssid is not null) and srcmac is not null group by
srcintf, srcssid, osname, osversion, devtype, srcmac order by subtotal desc)###
t where devtype is not null group by devtype order by totalnum desc
select
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and (
srcssid is not null
or dstssid is not null
)
select
count(distinct srcmac) as totalnum
from
###(select srcintf, srcssid, osname, osversion, devtype, srcmac, count(*) as
subtotal from $log where $filter and logid_to_int(logid) not in (4, 7, 14) and
(srcssid is not null or dstssid is not null) and srcmac is not null group by
srcintf, srcssid, osname, osversion, devtype, srcmac order by subtotal desc)###
t
select
ip_subnet(`srcip`) as subnet,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
subnet
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
ip_subnet(`srcip`) as subnet,
app_group_name(app) as app_group,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
subnet,
app_group
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
ip_subnet(`srcip`) as subnet,
app_group_name(app) as app_group,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
subnet,
app_group
order by
sessions desc
select
subnet,
website,
sum(bandwidth) as bandwidth
from
(
###(select ip_subnet(`srcip`) as subnet, hostname as website, sum(coalesce
(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $fil-
ter and hostname is not null and logid_to_int(logid) not in (4, 7, 14) and
utmevent in ('webfilter', 'banned-word', 'web-content', 'command-block',
'script-filter') group by subnet, website order by bandwidth desc)### union all
###(select ip_subnet(`srcip`) as subnet, hostname as website, sum(coalesce(sent-
byte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-webfilter where $filter
and hostname is not null and (eventtype is null or logver=52) group by subnet,
website order by bandwidth desc)###) t group by subnet, website order by band-
width desc
select
subnet,
website,
sum(hits) as hits
from
(
###(select ip_subnet(`srcip`) as subnet, hostname as website, count(*) as
hits from $log-traffic where $filter and hostname is not null and logid_to_int
(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-con-
tent', 'command-block', 'script-filter') group by subnet, website order by hits
desc)### union all ###(select ip_subnet(`srcip`) as subnet, hostname as website,
count(*) as hits from $log-webfilter where $filter and hostname is not null and
(eventtype is null or logver=52) group by subnet, website order by hits desc)
###) t group by subnet, website order by hits desc
select
ip_subnet(`srcip`) as subnet,
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and srcip is not null
group by
subnet,
user_src
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
ip_subnet(`srcip`) as subnet,
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
subnet,
user_src
order by
sessions desc
select
appcat,
app,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
appcat,
app
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
appcat,
app,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
appcat,
app
order by
sessions desc
select
from_itime(itime) as timestamp,
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
appcat,
app,
coalesce(
root_domain(hostname),
ipstr(dstip)
) as destination,
sum(
coalesce(`sentbyte`, 0)+ coalesce(`rcvdbyte`, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and action in ('accept', 'close', 'timeout')
group by
timestamp,
user_src,
appcat,
app,
destination
order by
bandwidth desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
appcat,
app,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and action in (
'deny', 'blocked', 'reset', 'dropped'
)
group by
user_src,
appcat,
app
order by
sessions desc
select
from_dtime(dtime) as timestamp,
catdesc,
hostname as website,
action as status,
sum(bandwidth) as bandwidth
from
(
###(select dtime, catdesc, hostname, utmaction as action, sum(coalesce(sent-
byte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and
hostname is not null and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
group by dtime, catdesc, hostname, utmaction order by dtime desc)### union all
###(select dtime, catdesc, hostname, action, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-webfilter where $filter and hostname is
not null and (eventtype is null or logver=52) group by dtime, catdesc, hostname,
action order by dtime desc)###) t group by dtime, catdesc, website, status order
by dtime desc
select
hod,
website,
sum(hits) as hits
from
(
###(select $hour_of_day as hod, (hostname || ' (' || coalesce(`catdesc`,
'Unknown') || ')') as website, count(*) as hits from $log-traffic where $filter
and hostname is not null and logid_to_int(logid) not in (4, 7, 14) and utmevent
in ('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
group by hod, website order by hod, hits desc)### union all ###(select $hour_of_
day as hod, (hostname || ' (' || coalesce(`catdesc`, 'Unknown') || ')') as web-
site , count(*) as hits from $log-webfilter where $filter and hostname is not
null and (eventtype is null or logver=52) group by hod, website order by hod,
hits desc)###) t group by hod, website order by hod, hits desc
select
website,
catdesc,
sum(bandwidth) as bandwidth
from
(
###(select hostname as website, catdesc, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and hostname is not
null and logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter',
'banned-word', 'web-content', 'command-block', 'script-filter') group by web-
site, catdesc order by bandwidth desc)### union all ###(select hostname as web-
site, catdesc, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth
from $log-webfilter where $filter and hostname is not null and (eventtype is
null or logver=52) group by website, catdesc order by bandwidth desc)###) t
group by website, catdesc order by bandwidth desc
select
website,
catdesc,
sum(hits) as hits
from
(
###(select hostname as website, catdesc, count(*) as hits from $log-traffic
where $filter and hostname is not null and logid_to_int(logid) not in (4, 7, 14)
and utmevent in ('webfilter', 'banned-word', 'web-content', 'command-block',
'script-filter') group by website, catdesc order by hits desc)### union all ###
(select hostname as website, catdesc, count(*) as hits from $log-webfilter where
$filter and hostname is not null and (eventtype is null or logver=52) group by
website, catdesc order by hits desc)###) t group by website, catdesc order by
hits desc
select
from_dtime(dtime) as timestamp,
user_src,
website,
catdesc,
cast(
sum(dura)/ 60 as decimal(18, 2)
) as dura,
sum(bandwidth) as bandwidth
from
###(select dtime, coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, hostname as website, catdesc, sum(coalesce(duration, 0)) as
dura, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter and hostname is not null and logid_to_int(logid) not in (4, 7, 14)
and action in ('accept','close','timeout') group by dtime, user_src, website,
catdesc having sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0))>0 order by band-
width desc)### t group by dtime, user_src, website, catdesc order by bandwidth
desc
select
website,
catdesc,
sum(bandwidth) as bandwidth
from
(
###(select hostname as website, catdesc, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and hostname is not
null and logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter',
'banned-word', 'web-content', 'command-block', 'script-filter') group by host-
name, catdesc having sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0))>0 order by
bandwidth desc)### union all ###(select hostname as website, catdesc, sum
(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-webfilter
where $filter and hostname is not null and (eventtype is null or logver=52)
group by hostname, catdesc order by bandwidth desc)###) t group by website, cat-
desc order by bandwidth desc
select
website,
catdesc,
sum(sessions) as sessions
from
(
###(select hostname as website, catdesc, count(*) as sessions from $log-
traffic where $filter and hostname is not null and logid_to_int(logid) not in
(4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-content', 'command-
block', 'script-filter') group by hostname, catdesc order by sessions desc)###
union all ###(select hostname as website, catdesc, count(*) as sessions from
$log-webfilter where $filter and hostname is not null and (eventtype is null or
logver=52) group by hostname, catdesc order by sessions desc)###) t group by web-
site, catdesc order by sessions desc
select
clientfeature,
count(*) as totalnum
from
$log
where
$filter
and clientfeature is not null
group by
clientfeature
order by
totalnum desc
select
os,
count(*) as totalnum
from
$log
where
$filter
and os is not null
group by
os
order by
totalnum desc
select
fctver_trim(fctver) as fctver_short,
count(*) as totalnum
from
$log
where
$filter
and fctver is not null
group by
fctver_short
order by
totalnum desc
select
coalesce(
nullifna(usingpolicy),
'Unknown'
) as profile,
count(*) as totalnum
from
$log
where
$filter
group by
profile
order by
totalnum desc
select
devicehostname,
deviceip,
os,
profile,
hostuser,
fctver_short
from
###(select devicehostname, deviceip, os, coalesce(nullifna(usingpolicy),
'Unknown') as profile, coalesce(nullifna(`user`), 'Unknown') as hostuser,
fctver_trim(fctver) as fctver_short from $log where $filter and os is not null
group by devicehostname, deviceip, os, profile, hostuser, fctver_short)### t
group by devicehostname, deviceip, os, profile, hostuser, fctver_short
select
coalesce(
nullifna(utmevent),
'Unknown'
) as utmevent,
count(*) as totalnum
from
$log
where
$filter
group by
utmevent
order by
totalnum desc
select
srcname,
count(*) as totalnum
from
$log
where
$filter
and srcname is not null
and lower(utmevent)= 'antivirus'
group by
srcname
order by
totalnum desc
select
hostname,
count(*) as totalnum
from
$log
where
$filter
and hostname is not null
and lower(utmevent) in ('webfilter', 'appfirewall')
and lower(threat) like '%botnet%'
group by
hostname
order by
totalnum desc
select
hostname,
count(*) as totalnum
from
$log
where
$filter
and hostname is not null
and lower(utmevent) in ('antivirus', 'antimalware')
group by
hostname
order by
totalnum desc
select
srcname,
hostname,
coalesce(
nullifna(`user`),
'Unknown'
) as hostuser,
utmaction
from
$log
where
$filter
and lower(utmevent) in ('antivirus', 'antimalware')
group by
srcname,
hostname,
hostuser,
utmaction
select
remotename,
hostname,
coalesce(
nullifna(`user`),
'Unknown'
) as hostuser,
utmaction,
count(*) as totalnum
from
$log
where
$filter
and lower(utmevent)= 'webfilter'
group by
remotename,
hostname,
hostuser,
utmaction
select
srcname,
hostname,
coalesce(
nullifna(`user`),
'Unknown'
) as hostuser,
utmaction
from
$log
where
$filter
and lower(utmevent)= 'appfirewall'
group by
srcname,
hostname,
hostuser,
utmaction
select
msg,
devicehostname,
coalesce(
nullifna(`user`),
'Unknown'
) as hostuser
from
$log
where
$filter
and level in ('error', 'alert')
group by
msg,
devicehostname,
hostuser
select
hostname,
count(*) as totalnum
from
$log
where
$filter
and hostname is not null
and utmevent is not null
group by
hostname
order by
totalnum desc
select
(
coalesce(osname, 'Unknown')
) as os,
count(*) as totalnum
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
os
order by
totalnum desc
select
appid,
app,
sum(sessions) as sessions
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and nullifna(app) is not null group by appid, app
order by sessions desc
select
appid,
app,
sum(sessions) as sessions
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and nullifna(app) is not null group by appid, app
order by sessions desc
select
appid,
app,
sum(bandwidth) as bandwidth
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and nullifna(app) is not null group by appid, app
having sum(bandwidth)>0 order by bandwidth desc
select
appid,
app,
sum(bandwidth) as bandwidth
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and nullifna(app) is not null group by appid, app
having sum(bandwidth)>0 order by bandwidth desc
select
dstip,
sum(sessions) as sessions
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and dstip is not null group by dstip order by ses-
sions desc
select
dstip,
sum(bandwidth) as bandwidth
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and dstip is not null group by dstip having sum
(bandwidth)>0 order by bandwidth desc
select
user_src,
sum(sessions) as sessions
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and user_src is not null group by user_src order by
sessions desc
select
user_src,
sum(sessions) as sessions
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and user_src is not null group by user_src order by
sessions desc
select
user_src,
sum(bandwidth) as bandwidth
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and user_src is not null group by user_src having
sum(bandwidth)>0 order by bandwidth desc
select
user_src,
sum(bandwidth) as bandwidth
from
###(select appid, app, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, srcintf, dstintf, policyid, count(*) as ses-
sions, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log
where $filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) group by
appid, app, user_src, dstip, srcintf, dstintf, policyid order by sessions desc)
### t where $filter-var-only and user_src is not null group by user_src having
sum(bandwidth)>0 order by bandwidth desc
select
user_src,
sum(requests) as visits
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, hostname, count(*) as requests from $log-traffic where $fil-
ter-exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null group by user_src, hostname order by requests desc)###
union all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src,
hostname, count(*) as requests from $log-webfilter where $filter-exclude-var and
(eventtype is null or logver = 52) and hostname is not null group by user_src,
hostname order by requests desc)###) t where $filter-var-only and user_src is
not null group by user_src order by visits desc
select
user_src,
sum(requests) as visits
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, hostname, count(*) as requests from $log-traffic where $fil-
ter-exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null group by user_src, hostname order by requests desc)###
union all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src,
hostname, count(*) as requests from $log-webfilter where $filter-exclude-var and
(eventtype is null or logver = 52) and hostname is not null group by user_src,
hostname order by requests desc)###) t where $filter-var-only and user_src is
not null group by user_src order by visits desc
select
hostname,
sum(requests) as visits
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, hostname, count(*) as requests from $log-traffic where $fil-
ter-exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null group by user_src, hostname order by requests desc)###
union all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src,
hostname, count(*) as requests from $log-webfilter where $filter-exclude-var and
(eventtype is null or logver = 52) and hostname is not null group by user_src,
hostname order by requests desc)###) t where $filter-var-only and hostname is
not null group by hostname order by visits desc
select
hostname,
sum(requests) as visits
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, hostname, count(*) as requests from $log-traffic where $fil-
ter-exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent in
('webfilter', 'banned-word', 'web-content', 'command-block', 'script-filter')
and hostname is not null group by user_src, hostname order by requests desc)###
union all ###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src,
hostname, count(*) as requests from $log-webfilter where $filter-exclude-var and
(eventtype is null or logver = 52) and hostname is not null group by user_src,
hostname order by requests desc)###) t where $filter-var-only and hostname is
not null group by hostname order by visits desc
select
sender,
sum(bandwidth) as volume
from
(
###(select sender, recipient, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter-exclude-
var and logid_to_int(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP',
'25/tcp', '587/tcp', 'smtps', 'SMTPS', '465/tcp') and utmevent in ('general-
email-log', 'spamfilter') group by sender, recipient order by requests desc)###
union all ###(select `from` as sender, `to` as recipient, count(*) as requests,
sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-email-
filter where $filter-exclude-var and service in ('smtp', 'SMTP', '25/tcp',
'587/tcp', 'smtps', 'SMTPS', '465/tcp') and eventtype is null group by `from`,
`to` order by requests desc)###) t where $filter-var-only and sender is not null
group by sender having sum(bandwidth)>0 order by volume desc
select
recipient,
sum(bandwidth) as volume
from
(
###(select sender, recipient, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter-exclude-
var and logid_to_int(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP',
'25/tcp', '587/tcp', 'smtps', 'SMTPS', '465/tcp') and utmevent in ('general-
email-log', 'spamfilter') group by sender, recipient order by requests desc)###
union all ###(select `from` as sender, `to` as recipient, count(*) as requests,
sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-email-
filter where $filter-exclude-var and service in ('smtp', 'SMTP', '25/tcp',
'587/tcp', 'smtps', 'SMTPS', '465/tcp') and eventtype is null group by `from`,
`to` order by requests desc)###) t where $filter-var-only and recipient is not
null group by recipient having sum(bandwidth)>0 order by volume desc
select
sender,
sum(requests) as requests
from
(
###(select sender, recipient, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter-exclude-
var and logid_to_int(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP',
'25/tcp', '587/tcp', 'smtps', 'SMTPS', '465/tcp') and utmevent in ('general-
email-log', 'spamfilter') group by sender, recipient order by requests desc)###
union all ###(select `from` as sender, `to` as recipient, count(*) as requests,
sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-email-
filter where $filter-exclude-var and service in ('smtp', 'SMTP', '25/tcp',
'587/tcp', 'smtps', 'SMTPS', '465/tcp') and eventtype is null group by `from`,
`to` order by requests desc)###) t where $filter-var-only and sender is not null
group by sender order by requests desc
select
recipient,
sum(requests) as requests
from
(
###(select sender, recipient, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter-exclude-
var and logid_to_int(logid) not in (4, 7, 14) and service in ('smtp', 'SMTP',
'25/tcp', '587/tcp', 'smtps', 'SMTPS', '465/tcp') and utmevent in ('general-
email-log', 'spamfilter') group by sender, recipient order by requests desc)###
union all ###(select `from` as sender, `to` as recipient, count(*) as requests,
sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-email-
filter where $filter-exclude-var and service in ('smtp', 'SMTP', '25/tcp',
'587/tcp', 'smtps', 'SMTPS', '465/tcp') and eventtype is null group by `from`,
`to` order by requests desc)###) t where $filter-var-only and recipient is not
null group by recipient order by requests desc
select
recipient,
sum(bandwidth) as volume
from
(
###(select recipient, sender, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and
logid_to_int(logid) not in (4, 7, 14) and service in ('pop3', 'POP3', '110/tcp',
'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S',
'995/tcp') and utmevent in ('general-email-log', 'spamfilter') group by recip-
ient, sender order by requests desc)### union all ###(select `to` as recipient,
`from` as sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce(rcvd-
byte, 0)) as bandwidth from $log-emailfilter where $filter-exclude-var and ser-
vice in ('pop3', 'POP3', '110/tcp', 'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp') and eventtype is null group by `to`,
`from` order by requests desc)###) t where $filter-var-only and recipient is not
null group by recipient having sum(bandwidth)>0 order by volume desc
select
sender,
sum(bandwidth) as volume
from
(
###(select recipient, sender, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and
logid_to_int(logid) not in (4, 7, 14) and service in ('pop3', 'POP3', '110/tcp',
'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S',
'995/tcp') and utmevent in ('general-email-log', 'spamfilter') group by recip-
ient, sender order by requests desc)### union all ###(select `to` as recipient,
`from` as sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce(rcvd-
byte, 0)) as bandwidth from $log-emailfilter where $filter-exclude-var and ser-
vice in ('pop3', 'POP3', '110/tcp', 'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp') and eventtype is null group by `to`,
`from` order by requests desc)###) t where $filter-var-only and sender is not
null group by sender having sum(bandwidth)>0 order by volume desc
select
recipient,
sum(requests) as requests
from
(
###(select recipient, sender, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and
logid_to_int(logid) not in (4, 7, 14) and service in ('pop3', 'POP3', '110/tcp',
'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S',
'995/tcp') and utmevent in ('general-email-log', 'spamfilter') group by recip-
ient, sender order by requests desc)### union all ###(select `to` as recipient,
`from` as sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce(rcvd-
byte, 0)) as bandwidth from $log-emailfilter where $filter-exclude-var and ser-
vice in ('pop3', 'POP3', '110/tcp', 'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp') and eventtype is null group by `to`,
`from` order by requests desc)###) t where $filter-var-only and recipient is not
null group by recipient order by requests desc
select
sender,
sum(requests) as requests
from
(
###(select recipient, sender, count(*) as requests, sum(coalesce(sentbyte,
0)+coalesce(rcvdbyte, 0)) as bandwidth from $log where $filter-exclude-var and
logid_to_int(logid) not in (4, 7, 14) and service in ('pop3', 'POP3', '110/tcp',
'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S',
'995/tcp') and utmevent in ('general-email-log', 'spamfilter') group by recip-
ient, sender order by requests desc)### union all ###(select `to` as recipient,
`from` as sender, count(*) as requests, sum(coalesce(sentbyte, 0)+coalesce(rcvd-
byte, 0)) as bandwidth from $log-emailfilter where $filter-exclude-var and ser-
vice in ('pop3', 'POP3', '110/tcp', 'imap', 'IMAP', '143/tcp', 'imaps', 'IMAPS',
'993/tcp', 'pop3s', 'POP3S', '995/tcp') and eventtype is null group by `to`,
`from` order by requests desc)###) t where $filter-var-only and sender is not
null group by sender order by requests desc
select
dstip,
sum(totalnum) as totalnum
from
###(select srcip, dstip, count(*) as totalnum from $log where $filter-exclude-
var group by srcip, dstip order by totalnum desc)### t where $filter-var-only
and dstip is not null group by dstip order by totalnum desc
select
srcip,
sum(totalnum) as totalnum
from
###(select srcip, dstip, count(*) as totalnum from $log where $filter-exclude-
var group by srcip, dstip order by totalnum desc)### t where $filter-var-only
and srcip is not null group by srcip order by totalnum desc
select
from_itime(itime) as timestamp,
attack,
srcip,
dstip
from
###(select itime, attack, srcip, dstip from $log where $filter-exclude-var
order by itime desc)### t where $filter-var-only order by itime desc
select
virus,
(
case when virus like 'Riskware%' then 'Spyware' when virus like 'Adware%'
then 'Adware' else 'Virus' end
) as malware_type,
sum(totalnum) as totalnum
from
(
###(select virus, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by virus order by totalnum desc)### union all ###(select virus, count
(*) as totalnum from $log-virus where $filter and (eventtype is null or logver =
52) and nullifna(virus) is not null group by virus order by totalnum desc)###) t
group by virus, malware_type order by totalnum desc
select
from_itime(itime) as timestamp,
virus,
user_src,
dstip,
hostname,
recipient
from
(
###(select itime, virus, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as user_src, dstip, hostname, recipient from $log-traffic where
$filter-exclude-var and logid_to_int(logid) not in (4, 7, 14) and utmevent is
not null and virus is not null order by itime desc)### union all ###(select
itime, virus, coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, dstip,
cast(' ' as char) as hostname, cast(' ' as char) as recipient from $log-virus
where $filter-exclude-var and (eventtype is null or logver = 52) and nullifna
(virus) is not null order by itime desc)###) t where $filter-var-only order by
itime desc
select
hostname,
sum(requests) as requests
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, hostname,
action, count(*) as requests from $log where $filter-exclude-var and hostname is
not null group by user_src, hostname, action order by requests desc)### t where
$filter-var-only and action='blocked' group by hostname order by requests desc
select
hostname,
sum(requests) as requests
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, hostname,
action, count(*) as requests from $log where $filter-exclude-var and hostname is
not null group by user_src, hostname, action order by requests desc)### t where
$filter-var-only and action!='blocked' group by hostname order by requests desc
select
catdesc,
sum(requests) as requests
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, catdesc,
action, count(*) as requests from $log where $filter-exclude-var and catdesc is
not null group by user_src, catdesc, action order by requests desc)### t where
$filter-var-only and action='blocked' group by catdesc order by requests desc
select
catdesc,
sum(requests) as requests
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, catdesc,
action, count(*) as requests from $log where $filter-exclude-var and catdesc is
not null group by user_src, catdesc, action order by requests desc)### t where
$filter-var-only and action!='blocked' group by catdesc order by requests desc
select
attack,
sum(attack_count) as attack_count
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, attack,
(case when severity in ('critical', 'high') then 1 else 0 end) as high_severity,
count(*) as attack_count from $log where $filter-exclude-var and nullifna
(attack) is not null group by user_src, attack, high_severity order by attack_
count desc)### t where $filter-var-only group by attack order by attack_count
desc
select
attack,
sum(attack_count) as attack_count
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, attack,
(case when severity in ('critical', 'high') then 1 else 0 end) as high_severity,
count(*) as attack_count from $log where $filter-exclude-var and nullifna
(attack) is not null group by user_src, attack, high_severity order by attack_
count desc)### t where $filter-var-only and high_severity=1 group by attack
order by attack_count desc
select
virus,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, virus,
count(*) as totalnum from $log where $filter-exclude-var and nullifna(virus) is
not null group by user_src, virus order by totalnum desc)### t where $filter-
var-only group by virus order by totalnum desc
select
receiver,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, `to` as
receiver, count(*) as totalnum from $log where $filter-exclude-var and sub-
type='infected' and (service in ('smtp', 'SMTP', '25/tcp', '587/tcp', 'smtps',
'SMTPS', '465/tcp') or service in ('pop3', 'POP3', '110/tcp', 'imap', 'IMAP',
'143/tcp', 'imaps', 'IMAPS', '993/tcp', 'pop3s', 'POP3S', '995/tcp')) and nul-
lifna(virus) is not null group by user_src, receiver order by totalnum desc)###
t where $filter-var-only group by receiver order by totalnum desc
select
hourstamp,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, $hour_of_
day as hourstamp, count(*) as totalnum from $log where $filter-exclude-var and
`to` is not null and action in ('detected', 'blocked') group by user_src,
hourstamp order by hourstamp)### t where $filter-var-only group by hourstamp
order by hourstamp
select
mf_sender,
sum(totalnum) as totalnum
from
###(select coalesce(nullifna(`user`), ipstr(`srcip`)) as user_src, `from` as
mf_sender, count(*) as totalnum from $log where $filter-exclude-var and `from`
is not null and action in ('detected', 'blocked') group by user_src, mf_sender
order by totalnum desc)### t where $filter-var-only group by mf_sender order by
totalnum desc
select
hourstamp,
cast(
sum(cpu_usage)/ sum(num) as decimal(6, 2)
) as cpu_avg_usage
from
###(select $hour_of_day as hourstamp, sum(cpu) as cpu_usage, count(*) as num
from $log where $filter and subtype='system' and action='perf-stats' group by
hourstamp)### t group by hourstamp order by hourstamp
select
hourstamp,
cast(
sum(mem_usage)/ sum(num) as decimal(6, 2)
) as mem_avg_usage
from
###(select $hour_of_day as hourstamp, sum(mem) as mem_usage, count(*) as num
from $log where $filter and subtype='system' and action='perf-stats' group by
hourstamp)### t group by hourstamp order by hourstamp
select
hourstamp,
cast(
sum(sess_usage)/ sum(num) as decimal(10, 2)
) as sess_avg_usage
from
###(select $hour_of_day as hourstamp, sum(totalsession) as sess_usage, count
(*) as num from $log where $filter and subtype='system' and action='perf-stats'
group by hourstamp)### t group by hourstamp order by hourstamp
select
hourstamp,
cast(
sum(sess_usage)/ sum(num) as decimal(10, 2)
) as sess_avg_usage,
cast(
sum(cpu_usage)/ sum(num) as decimal(6, 2)
) as cpu_avg_usage
from
###(select $hour_of_day as hourstamp, sum(cpu) as cpu_usage, sum(totalsession)
as sess_usage, count(*) as num from $log where $filter and subtype='system' and
action='perf-stats' group by hourstamp)### t group by hourstamp order by
hourstamp
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
srcip,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and srcip is not null
group by
user_src,
srcip
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
srcip,
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as sessions
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and srcip is not null
group by
srcip,
user_src
order by
sessions desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
sum(crscore % 65536) as scores
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
user_src
having
sum(crscore % 65536)> 0
order by
scores desc
select
devtype,
coalesce(
nullifna(`srcname`),
nullifna(`srcmac`),
ipstr(`srcip`)
) as dev_src,
sum(crscore % 65536) as scores
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and crscore is not null
group by
devtype,
dev_src
having
sum(crscore % 65536)> 0
order by
scores desc
select
appcat,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(appcat) is not null
group by
appcat
order by
bandwidth desc
select
appcat,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(appcat) is not null
group by
appcat
order by
bandwidth desc
select
catdesc,
sum(bandwidth) as bandwidth
from
(
###(select catdesc, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as band-
width from $log-traffic where $filter and logid_to_int(logid) not in (4, 7, 14)
and utmevent in ('webfilter', 'banned-word', 'web-content', 'command-block',
'script-filter') and catdesc is not null group by catdesc order by bandwidth
desc)### union all ###(select catdesc, sum(coalesce(sentbyte, 0)+coalesce(rcvd-
byte, 0)) as bandwidth from $log-webfilter where $filter and (eventtype is null
or logver = 52) and catdesc is not null group by catdesc order by bandwidth
desc)###) t group by catdesc order by bandwidth desc
select
app_group_name(app) as app_group,
appcat,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
count(*) as num_session
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
group by
app_group,
appcat
order by
bandwidth desc
select
app_group_name(app) as app_group,
service,
count(*) as sessions,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
and service in (
'80/tcp', '443/tcp', 'HTTP', 'HTTPS',
'http', 'https'
)
group by
app_group,
service
having
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
)> 0
order by
bandwidth desc
select
catdesc,
sum(num_sess) as num_sess,
sum(bandwidth) as bandwidth
from
(
###(select catdesc, count(*) as num_sess, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and logid_to_int
(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-con-
tent', 'command-block', 'script-filter') and catdesc is not null group by cat-
desc order by num_sess desc)### union all ###(select catdesc, count(*) as num_
sess, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-
webfilter where $filter and (eventtype is null or logver = 52) and catdesc is
not null group by catdesc order by num_sess desc)###) t group by catdesc order
by num_sess desc
select
catdesc,
sum(num_sess) as num_sess,
sum(bandwidth) as bandwidth
from
(
###(select catdesc, count(*) as num_sess, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and logid_to_int
(logid) not in (4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-con-
tent', 'command-block', 'script-filter') and catdesc is not null group by cat-
desc order by num_sess desc)### union all ###(select catdesc, count(*) as num_
sess, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-
webfilter where $filter and (eventtype is null or logver = 52) and catdesc is
not null group by catdesc order by num_sess desc)###) t group by catdesc order
by num_sess desc
select
domain,
catdesc,
sum(visits) as visits
from
(
###(select coalesce(nullifna(hostname), ipstr(`dstip`)) as domain, catdesc,
count(*) as visits from $log-traffic where $filter and logid_to_int(logid) not
in (4, 7, 14) and utmevent in ('webfilter', 'banned-word', 'web-content', 'com-
mand-block', 'script-filter') and catdesc is not null group by domain, catdesc
order by visits desc)### union all ###(select coalesce(nullifna(hostname), ipstr
(`dstip`)) as domain, catdesc, count(*) as visits from $log-webfilter where $fil-
ter and (eventtype is null or logver = 52) and catdesc is not null group by
domain, catdesc order by visits desc)###) t group by domain, catdesc order by
visits desc
select
dstcountry,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select dstcountry, sum($browse_time) as delta, sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in,
sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter and logid_to_
int(logid) not in (4, 7, 14) group by dstcountry having sum($browse_time)>0
order by delta desc)### t group by dstcountry order by browsetime desc
select
dstcountry,
sum(delta) as browsetime,
sum(bandwidth) as bandwidth,
sum(traffic_in) as traffic_in,
sum(traffic_out) as traffic_out
from
###(select dstcountry, sum($browse_time2) as delta, sum(coalesce(sentbyte, 0)
+coalesce(rcvdbyte, 0)) as bandwidth, sum(coalesce(rcvdbyte, 0)) as traffic_in,
sum(coalesce(sentbyte, 0)) as traffic_out from $log where $filter and logid_to_
int(logid) not in (4, 7, 14) group by dstcountry having sum($browse_time2)>0
order by delta desc)### t group by dstcountry order by browsetime desc
select
hostname,
sum($browse_time) as browsetime,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and hostname is not null
group by
hostname
having
sum($browse_time)> 0
order by
browsetime desc
select
hostname,
sum($browse_time2) as browsetime,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
sum(
coalesce(rcvdbyte, 0)
) as traffic_in,
sum(
coalesce(sentbyte, 0)
) as traffic_out
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and hostname is not null
group by
hostname
having
sum($browse_time2)> 0
order by
browsetime desc
select
severity,
count(*) as totalnum
from
$log
where
$filter
group by
severity
order by
totalnum desc
select
attack,
severity,
ref,
count(*) as totalnum
from
$log
where
$filter
and severity = 'critical'
and nullifna(attack) is not null
group by
attack,
severity,
ref
order by
totalnum desc
select
attack,
severity,
ref,
count(*) as totalnum
from
$log
where
$filter
and severity = 'high'
and nullifna(attack) is not null
group by
attack,
severity,
ref
order by
totalnum desc
select
attack,
severity,
ref,
count(*) as totalnum
from
$log
where
$filter
and severity = 'medium'
and nullifna(attack) is not null
group by
attack,
severity,
ref
order by
totalnum desc
select
attack,
severity,
ref,
count(*) as totalnum
from
$log
where
$filter
and severity = 'low'
and nullifna(attack) is not null
group by
attack,
severity,
ref
order by
totalnum desc
select
attack,
severity,
ref,
count(*) as totalnum
from
$log
where
$filter
and severity = 'info'
and nullifna(attack) is not null
group by
attack,
severity,
ref
order by
totalnum desc
select
virus,
(
case when virus like 'Riskware%' then 'Spyware' when virus like 'Adware%'
then 'Adware' else 'Virus' end
) as malware_type,
sum(totalnum) as totalnum
from
(
###(select virus, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by virus order by totalnum desc)### union all ###(select virus, count
(*) as totalnum from $log-virus where $filter and (eventtype is null or logver =
52) and nullifna(virus) is not null group by virus order by totalnum desc)###) t
group by virus, malware_type order by totalnum desc
select
user_src,
sum(totalnum) as totalnum
from
(
###(select coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr(`sr-
cip`)) as user_src, count(*) as totalnum from $log-traffic where $filter and
logid_to_int(logid) not in (4, 7, 14) and utmevent is not null and virus is not
null group by user_src order by totalnum desc)### union all ###(select coalesce
(nullifna(`user`), ipstr(`srcip`)) as user_src, count(*) as totalnum from $log-
virus where $filter and (eventtype is null or logver = 52) and nullifna(virus)
is not null group by user_src order by totalnum desc)###) t group by user_src
order by totalnum desc
select
utmsubtype,
sum(number) as number
from
(
###(select utmsubtype, count(*) as number from $log-traffic where $filter
and logid_to_int(logid) not in (4, 7, 14) and utmevent='dlp' and utmsubtype is
not null group by utmsubtype order by number desc)### union all ###(select sub-
type as utmsubtype, count(*) as number from $log-dlp where $filter and subtype
is not null group by subtype order by number desc)###) t group by utmsubtype
order by number desc
select
vuln,
vulnref as ref,
vulncat,
severity,
count(*) as totalnum
from
$log
where
$filter
and vuln is not null
group by
vuln,
vulnref,
vulncat,
severity
order by
totalnum desc
select
dom,
sum(totalnum) as totalnum
from
(
###(select $DAY_OF_MONTH as dom, count(*) as totalnum from $log-traffic
where $filter and logid_to_int(logid) not in (4, 7, 14) and utmevent is not null
and virus is not null group by dom order by totalnum desc)### union all ###
(select $DAY_OF_MONTH as dom, count(*) as totalnum from $log-virus where $filter
and nullifna(virus) is not null and (eventtype is null or logver = 52) group by
dom order by totalnum desc)###) t group by dom order by totalnum desc
select
d_behavior,
count(*) as number
from
$log t1
inner join app_mdata t2 on t1.appid = t2.id
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and d_risk > 0
group by
d_behavior
order by
number desc
select
d_risk,
coalesce(
d_behavior, 'Other Applications'
) as f_behavior,
count(*) as number
from
$log t1
inner join app_mdata t2 on t1.appid = t2.id
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
d_risk,
d_behavior
order by
d_risk desc,
number desc
select
d_risk,
d_behavior,
t2.id,
t2.name,
t2.app_cat,
t2.technology,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
count(*) as sessions
from
$log t1
inner join app_mdata t2 on t1.appid = t2.id
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and d_behavior is not null
group by
t2.id
order by
d_risk desc,
sessions desc
select
appcat,
count(distinct app) as total_num
from
###(select appcat, app from $log where $filter and app is not null and appcat
is not null and logid_to_int(logid) not in (4, 7, 14) and apprisk in ('crit-
ical', 'high') group by appcat, app)### t group by appcat order by total_num
desc
select
threat_name,
sum(total_num) as total_num
from
(
###(select cast('Malware & Botnet C&C' as char(32)) as threat_name, count(*)
as total_num from $log-app-ctrl where $filter and lower(appcat)='botnet')###
union all ###(select cast('Malware & Botnet C&C' as char(32)) as threat_name,
count(*) as total_num from $log-virus where $filter and nullifna(virus) is not
null)### union all ###(select cast('Malicious & Phishing Sites' as char(32)) as
threat_name, count(*) as total_num from $log-webfilter where $filter and cat in
(26, 61))### union all ###(select cast('Critical & High Intrusion Attacks' as
char(32)) as threat_name, count(*) as total_num from $log-attack where $filter
and severity in ('critical', 'high'))###) t group by threat_name having sum
(total_num) > 0 order by total_num desc
select
attack,
ref,
vuln_type,
severity_number,
count(distinct dstip) as victims,
count(distinct srcip) as sources,
sum(totalnum) as totalnum
from
###(select attack, ref, vuln_type, (case when t1.severity='critical' then 5
when t1.severity='high' then 4 when t1.severity='medium' then 3 when t1.-
severity='low' then 2 when t1.severity='info' then 1 else 0 end) as severity_num-
ber, dstip, srcip, count(*) as totalnum from $log t1 left join ips_mdata t2 on
t1.attack=t2.name where $filter and nullifna(attack) is not null and t1.severity
is not null group by attack, ref, vuln_type, t1.severity, dstip, srcip )### t
group by attack, ref, vuln_type, severity_number order by severity_number desc,
totalnum desc
select
appcat,
count(distinct app) as total_num
from
###(select appcat, app from $log where $filter and app is not null and appcat
is not null and logid_to_int(logid) not in (4, 7, 14) and apprisk in ('crit-
ical', 'high') group by appcat, app)### t group by appcat order by total_num
desc
select
d_risk,
count(distinct f_user) as users,
id,
name,
app_cat,
technology,
sum(bandwidth) as bandwidth,
sum(sessions) as sessions
from
###(select (case apprisk when 'low' then 1 when 'elevated' then 2 when
'medium' then 3 when 'high' then 4 when 'critical' then 5 else 0 end) as d_risk,
coalesce(nullifna(t1.`user`), nullifna(t1.`unauthuser`), ipstr(t1.`srcip`)) as
f_user, t2.id , t2.name, t2.app_cat, t2.technology, sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0)) as bandwidth, count(*) as sessions from $log t1 inner join
app_mdata t2 on t1.appid=t2.id where $filter and apprisk in ('critical', 'high')
and logid_to_int(logid) not in (4, 7, 14) group by f_user, t2.id , t2.name,
t2.app_cat, t2.technology, apprisk)### t group by id, d_risk, name, app_cat,
technology order by d_risk desc, sessions desc
select
behavior,
round(
sum(total_num)* 100 / sum(
sum(total_num)
) over (),
2
) as percentage
from
###(select (case when lower(appcat)='botnet' then 'malicious' when lower
(appcat)='remote.access' then 'tunneling' when lower(appcat) in ('stor-
age.backup', 'video/audio') then 'bandwidth-consuming' when lower(appcat)='p2p'
then 'peer-to-peer' when lower(appcat)='proxy' then 'proxy' end) as behavior,
count(*) as total_num from $log where $filter and lower(appcat) in ('botnet',
'remote.access', 'storage.backup', 'video/audio', 'p2p', 'proxy') and logid_to_
int(logid) not in (4, 7, 14) and apprisk in ('critical', 'high') group by
appcat)### t group by behavior order by percentage desc
select
d_risk,
count(distinct f_user) as users,
id,
name,
app_cat,
technology,
sum(bandwidth) as bandwidth,
sum(sessions) as sessions
from
###(select (case apprisk when 'low' then 1 when 'elevated' then 2 when
'medium' then 3 when 'high' then 4 when 'critical' then 5 else 0 end) as d_risk,
coalesce(nullifna(t1.`user`), nullifna(t1.`unauthuser`), ipstr(t1.`srcip`)) as
f_user, t2.id, t2.name, t2.app_cat, t2.technology, sum(coalesce(sentbyte, 0)+co-
alesce(rcvdbyte, 0)) as bandwidth, count(*) as sessions from $log t1 inner join
app_mdata t2 on t1.appid=t2.id where $filter and logid_to_int(logid) not in (4,
7, 14) group by f_user, t2.id, t2.name, t2.app_cat, t2.technology, apprisk )###
t group by id, name, app_cat, technology, d_risk order by bandwidth desc
select
appcat,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(appcat) is not null
group by
appcat
order by
bandwidth desc
select
appcat,
count(distinct appid) as app_num,
count(distinct f_user) as user_num,
sum(bandwidth) as bandwidth,
sum(num_session) as num_session
from
###(select appcat, appid, coalesce(nullifna(`user`), nullifna(`unauthuser`),
ipstr(`srcip`)) as f_user, sum(coalesce(sentbyte, 0)+coalesce(rcvdbyte, 0)) as
bandwidth, count(*) as num_session from $log where $filter and logid_to_int
(logid) not in (4, 7, 14) and nullifna(appcat) is not null group by appcat,
appid, f_user)### t group by appcat order by bandwidth desc
select
d_risk,
id,
name,
technology,
count(distinct f_user) as user_num,
sum(bandwidth) as bandwidth,
sum(num_session) as num_session
from
###(select (case apprisk when 'low' then 1 when 'elevated' then 2 when
'medium' then 3 when 'high' then 4 when 'critical' then 5 else 0 end) as d_risk,
t2.id, t2.name, t2.technology, coalesce(nullifna(t1.`user`), nullifna(t1.`un-
authuser`), ipstr(t1.`srcip`)) as f_user, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth, count(*) as num_session from $log t1 inner join
app_mdata t2 on t1.appid=t2.id where $filter and logid_to_int(logid) not in (4,
7, 14) and nullifna(app) is not null and service in ('80/tcp', '443/tcp',
'HTTP', 'HTTPS', 'http', 'https') group by apprisk, t2.id, t2.name, t2.-
technology, f_user)### t group by d_risk, id, name, technology order by band-
width desc
select
catdesc,
count(distinct f_user) as user_num,
sum(sessions) as sessions,
sum(bandwidth) as bandwidth
from
(
###(select catdesc, coalesce(nullifna(`user`), nullifna(`unauthuser`), ipstr
(`srcip`)) as f_user, count(*) as sessions, sum(coalesce(sentbyte, 0)+coalesce
(rcvdbyte, 0)) as bandwidth from $log-traffic where $filter and catdesc is not
null and logid_to_int(logid) not in (4, 7, 14) and utmevent in ('webfilter',
'banned-word', 'web-content', 'command-block', 'script-filter') group by f_user,
catdesc order by sessions desc)### union all ###(select catdesc, coalesce(nul-
lifna(`user`), ipstr(`srcip`)) as f_user, count(*) as sessions, sum(coalesce
(sentbyte, 0)+coalesce(rcvdbyte, 0)) as bandwidth from $log-webfilter where $fil-
ter and catdesc is not null and (eventtype is null or logver = 52) group by f_
user, catdesc order by sessions desc)###) t group by catdesc order by sessions
desc
select
virus_s as virus,
(
case when lower(appcat)= 'botnet' then 'Botenet C&C' else (
case when virus_s like 'Riskware%' then 'Spyware' when virus_s like
'Adware%' then 'Adware' else 'Virus' end
) end
) as malware_type,
appid,
app,
count(distinct dstip) as victims,
count(distinct srcip) as source,
sum(total_num) as total_num
from
###(select unnest(string_to_array(virus, ',')) as virus_s, appcat, appid, app,
dstip, srcip, count(*) as total_num from $log-traffic where $filter and logid_
to_int(logid) not in (4, 7, 14) and virus is not null group by virus_s, appcat,
appid, dstip, srcip, app order by total_num desc)### t group by virus, appid,
app, malware_type order by total_num desc
select
virus_s,
appid,
app,
count(distinct dstip) as victims,
count(distinct srcip) as source,
sum(total_num) as total_num
from
###(select unnest(string_to_array(virus, ',')) as virus_s, appid, app, dstip,
srcip, count(*) as total_num from $log where $filter and logid_to_int(logid) not
in (4, 7, 14) and virus like '%PossibleThreat.SB%' group by virus_s, dstip,
srcip, appid, app )### t where virus_s like '%PossibleThreat.SB%' group by
virus_s, appid, app order by total_num desc
select
$DAY_OF_MONTH as dom,
count(*) as total_num
from
$log
where
$filter
and nullifna(virus) is not null
and logid_to_int(logid)= 9233
group by
dom
order by
dom
select
filename,
analyticscksum,
count(distinct dstip) as victims,
count(distinct srcip) as source
from
###(select filename, analyticscksum, dstip, srcip from $log where $filter and
filename is not null and logid_to_int(logid)=9233 and analyticscksum is not null
group by filename, analyticscksum, srcip, dstip)### t group by filename, ana-
lyticscksum order by victims
select
appid,
app,
filename,
cloudaction,
filesize
from
$log
where
$filter
and filesize is not null
and clouduser is not null
and filename is not null
group by
cloudaction,
appid,
app,
filename,
filesize
order by
filesize desc
select
srcname as caller,
count(*) as totalnum
from
$log
where
$filter
and lower(appcat)= 'voip'
and app = 'sccp'
and action = 'block'
and srcname is not null
group by
caller
order by
totalnum desc
select
srcname as caller,
count(*) as totalnum
from
$log
where
$filter
and srcname is not null
and lower(appcat)= 'voip'
and app = 'sip'
and action = 'block'
group by
caller
order by
totalnum desc
select
$hour_of_day as hourstamp,
count(*) as totalnum
from
$log
where
$filter
and proto = 'sccp'
and kind = 'register'
group by
hourstamp
order by
hourstamp
select
$hour_of_day as hourstamp,
sum(duration) as sccp_usage
from
$log
where
$filter
and proto = 'sccp'
and kind = 'call-info'
and status = 'end'
group by
hourstamp
order by
hourstamp
select
status,
count(*) as totalnum
from
$log
where
$filter
and proto = 'sccp'
and kind = 'call-info'
group by
status
order by
totalnum desc
select
$hour_of_day as hourstamp,
count(*) as totalnum
from
$log
where
$filter
and proto = 'sip'
and kind = 'register'
group by
hourstamp
order by
hourstamp
select
status,
count(*) as totalnum
from
$log
where
$filter
and proto = 'sip'
and kind = 'call'
group by
status
order by
totalnum desc
select
(
case when duration < 60 then 'LESS_ONE_MIN' when duration < 600 then 'LESS_
TEN_MIN' when duration < 3600 then 'LESS_ONE_HOUR' when duration >= 3600 then
'MORE_ONE_HOUR' else 'unknown' end
) as f_duration,
count(*) as totalnum
from
$log
where
$filter
and proto = 'sip'
and kind = 'call'
and status = 'end'
group by
f_duration
order by
totalnum desc
select
app,
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
and nullifna(app) is not null
group by
app,
user_src
order by
events desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
devtype,
coalesce(srcname, srcmac) as host_mac,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
group by
user_src,
devtype,
host_mac
order by
events desc
select
app,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
and nullifna(app) is not null
group by
app
order by
events desc
select
dstip,
root_domain(hostname) as domain,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
and dstip is not null
group by
dstip,
domain
order by
events desc
select
coalesce(
nullifna(`user`),
nullifna(`unauthuser`),
ipstr(`srcip`)
) as user_src,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
and srcip is not null
group by
user_src
order by
events desc
select
$flex_timescale as hodex,
count(*) as events
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and appcat = 'Botnet'
group by
hodex
order by
hodex desc
select
$flex_timescale as hodex,
count(*) as counter
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
group by
hodex
order by
hodex
select
appid,
app,
appcat,
(
case when (
utmaction in ('block', 'blocked')
or action = 'deny'
) then 'Blocked' else 'Allowed' end
) as custaction,
sum(
coalesce(sentbyte, 0)+ coalesce(rcvdbyte, 0)
) as bandwidth,
count(*) as num_session
from
$log
where
$filter
and logid_to_int(logid) not in (4, 7, 14)
and nullifna(app) is not null
and policyid != 0
group by
appid,
app,
appcat,
custaction
order by
bandwidth desc
Application with Highest Band- Application with the highest band- Top-App-By-Bandwidth Traffic
width width usage
Application with Highest Session Applications with the highest ses- Top-App-By-Sessions Traffic
Count sion count
Attack with Highest Session Attack with highest session count Utm-Top-Attack- Attack
Count Source
Botnet with Highest Session Botnet with the highest session Detected-Botnet Traffic
Count count
Destination with Highest Band- Destination with the highest band- Top-Destinations-By- Traffic
width width usage Bandwidth
Destination with Highest Session Destination with the highest ses- Top-Destinations-By- Traffic
Count sion count Sessions
Highest Risk Application with Highest risk application with the High-Risk-Application- Traffic
Highest Bandwidth highest bandwidth usage By-Bandwidth
Highest Risk Application with Highest risk application with the High-Risk-Application- Traffic
Highest Session Count highest session count By-Sessions
Highest Session Count by Applic- Highest session count by applic- App-Sessions-By-Cat- Traffic
ation Category ation category egory
Highest Session Count by Applic- Highest session count by applic- Top-App-By-Sessions Traffic
ation ation
Highest Session Count by Attack Highest session count by attack Utm-Top-Attack- Attack
Source
Highest Session Count by Botnet Highest session count by botnet Detected-Botnet Traffic
Highest Session Count by Destin- Highest session count by des- Top-Destinations-By- Traffic
ation tination Sessions
Highest Session Count by P2P Highest session count by P2P Top-P2P-App-By-Ses- Traffic
Application application sions
Highest Session Count by Source Highest session count by source Top-User-Source-By- Traffic
Sessions
Highest Session Count by Virus Highest session count by virus Utm-Top-Virus Traffic
Highest Session Count by Web Highest session count by website Top-Web-Category-by- Web Filter
Category category Sessions
Highest Session Count by Web- Highest session count by website Top-Web-Sites-by-Ses- Web Filter
site sions
Highest Severity Attack with Highest severity attack with the Threat-Attacks-By- Attack
Highest Session Count highest session count Severity
P2P Application with Highest P2P applications with the highest Top-P2P-App-By-Band- Traffic
Bandwidth bandwidth usage width
P2P Application with Highest Ses- P2P applications with the highest Top-P2P-App-By-Ses- Traffic
sion Count session count sions
Source with Highest Bandwidth Source with the highest bandwidth Top-Users-By-Band- Traffic
usage width
Source with Highest Session Source with the highest session Top-User-Source-By- Traffic
Count count Sessions
Total Number of Botnet Events Total number of botnet events Total-Number-of-Bot- Traffic
net-Events
Virus with Highest Session Count Virus with the highest session Utm-Top-Virus Traffic
count
Web Category with Highest Band- Web filtering category with the Top-Web-Category-by- Web Filter
width highest bandwidth usage Bandwidth
Web Category with Highest Ses- Web filtering category with the Top-Web-Category-by- Web Filter
sion Count highest session count Sessions
Website with Highest Bandwidth Website with the highest band- Top-Web-Sites-by- Web Filter
width usage Bandwidth
Website with Highest Session Website with the highest session Top-Web-Sites-by-Ses- Web Filter
Count count sions