ntopng/scripts/historical/tables
Alfredo Cardigliano 65ecebd2fa Rename custom query
2025-05-21 18:10:18 +02:00
..
alerted_domains.json Extend AS report 2025-04-18 14:58:22 +02:00
asn_flows.json Added bps render_type and fixed asn flows thpt 2025-05-15 12:05:04 +02:00
clients.json Add label and country to clients/servers presets 2023-07-31 16:31:07 +02:00
conversations.json Fixes wrong names to columns 2025-05-15 11:48:47 +02:00
dns_queries.json Split protocol and alert info from ALERT_JSON: new PROTOCOL_INFO_JSON column 2024-12-05 15:13:16 +01:00
domains.json Add custom query for top domains by destination 2025-02-11 18:09:50 +01:00
domains_by_dest.json Add custom query Number of unique domains by destination 2025-02-11 18:45:51 +01:00
l7_contacts.json Fix json configurationg l7 contacts for chart 2023-12-15 11:06:16 +01:00
l7_traffic.json Use throughput chart in l7 traffic query 2024-10-21 16:26:16 +02:00
l7_traffic_inout.json Cleanup query l7_traffic_inout 2025-04-14 12:05:23 +02:00
latency_by_asn.json Extend AS report 2025-04-18 14:58:22 +02:00
number_of_hosts.json Update presets for aggregated historical flows. 2023-06-15 15:56:00 +00:00
README Migrate local networks type from 16 to 32 bit 2024-10-29 15:31:37 +01:00
server_contacts.json Add hostnames to server contacts custom queries (#8104) 2023-12-15 11:57:46 +01:00
server_ports.json Fixes filters request in reports dashboard (#9205) 2025-05-13 16:22:29 +02:00
servers.json Implement Top 10 Historical Aggregation Charts #7994; fix unit_measure on flow historical page chart 2023-11-29 14:28:49 +01:00
sites.json Fix top sites query with constraints on protocol 2025-05-15 09:35:01 +02:00
top_as.json Add custom queries for top as 2025-04-01 09:21:01 +02:00
top_as_exporter_if.json Add custom queries for top as 2025-04-01 09:21:01 +02:00
top_clients.json Add hostnames to top clients/servers custom queries (#8104) 2023-12-15 12:02:28 +01:00
top_local_fingerprints.json Disable hourly from unsupported queries 2025-03-12 17:26:16 +01:00
top_local_talkers.json Fixes issue with ntopng report page (#8688) 2024-09-30 15:31:39 +02:00
top_receiver_as.json Add custom queries for top receiver/sender AS 2023-08-03 10:46:29 +02:00
top_receiver_as_exporter_if.json Fix queries (CH bug with UNION on tables with different column order) 2025-04-18 17:30:18 +02:00
top_receiver_countries.json Add custom queries for top receiver/sender countries 2023-08-16 12:23:52 +02:00
top_receiver_networks.json Migrate local networks type from 16 to 32 bit 2024-10-29 15:31:37 +01:00
top_remote_destinations.json Fixes issue with ntopng report page (#8688) 2024-09-30 15:31:39 +02:00
top_remote_fingerprints.json Disable hourly from unsupported queries 2025-03-12 17:26:16 +01:00
top_sender_as.json Add custom queries for top receiver/sender AS 2023-08-03 10:46:29 +02:00
top_sender_as_exporter_if.json Fix queries (CH bug with UNION on tables with different column order) 2025-04-18 17:30:18 +02:00
top_sender_countries.json Add custom queries for top receiver/sender countries 2023-08-16 12:23:52 +02:00
top_sender_networks.json Migrate local networks type from 16 to 32 bit 2024-10-29 15:31:37 +01:00
top_servers.json Add hostnames to top clients/servers custom queries (#8104) 2023-12-15 12:02:28 +01:00
top_vlans.json Add top VLAN custom query 2024-07-18 10:55:29 +00:00
unique_domains_by_dest.json Rename custom query 2025-05-21 18:10:18 +02:00

Query Definitions
-----------------

Place in this directory query definitions in JSON format
used by the Historical Flow Explorer.

Built-in examples are provided and can be used as starting
point for building new queries. Please note that:

- The 'select' object can contain a list of items in the 'items'
  array. A raw SQL select can be defined in the 'sql' string. A
  list of items is still required to define the columns and value 
  type (if not a plain column).

- It is possible to use SQL functions as 'select' item as shown
  in the examples by specifying the 'func' (e.g. SUM) and the
  parameter (e.g. TOTAL_BYTES)

- The 'filters' object contains a list of items to filter in the
  'items' array. Defining the 'name' is enough, however additional
  settings can be configured to overwrite the default (e.g. the
  operators to be used, the input type, optional field, etc.).

- The interface index, and first/last seen are automatically included
  by the engine: no need to define them as filters in the query definition.

- Custom SQL code can be also provided:
  - For sections of the query (e.g. select.sql)
  - For the full query - in this case $FROM$, $WHERE$, $GROUPBY$, $ORDERBY$, $LIMIT$ 
    tokens can be used to inject conditions and values built from the engine.

Examples
--------

Select example - list of fields:

	"select" : {
		"items" : [
			{
				"name": "IPV4_SRC_ADDR",
			},
			{
				"name": "IPV4_DST_ADDR", 
			},
			{
				"name": "VLAN_ID",
			},
			{
				"name": "L7_PROTO",
			},
			{
				"name": "bytes",
				"func": "SUM",
				"param": "TOTAL_BYTES",
				"value_type": "bytes",
			}
		]
	}

Select example - custom SQL (note: list of items still need to be declared to build the datatable structure):

	"select" : {
		"sql": "IPv4NumToString(IPV4_SRC_ADDR) IPV4_SRC_ADDR_FORMATTED, IPv4NumToString(IPV4_DST_ADDR) IPV4_DST_ADDR_FORMATTED, L7_PROTO, SUM(TOTAL_BYTES) bytes",
		"items" : [
			{ 
				"name" : "IPV4_SRC_ADDR" 
			},
			{
				"name" : "IPV6_SRC_ADDR"
			},
			{
				"name" : "bytes",
				"func" : "",
				"value_type" : "bytes"
			}
		]
	}

Filters examples:

	"filters" : {
		"items" : [
			{
				"name": "IPV4_SRC_ADDR"
			},
			{
				"name": "TOTAL_BYTES",
				"op": "gte",
				"value_type": "number",
				"input": "user",
				"optional": true
			},
			{
				"name": "L7_PROTO",
				"op": "eq",
				"value_type": "l7_proto",
				"input": "fixed",
				"value": "TLS"
			}
		]
	}

Full query using Custom SQL example (see top_receiver_networks.json):

	"sql" : "SELECT VLAN_ID, NETWORK_ID, SUM(BYTES) AS total_bytes FROM (SELECT VLAN_ID,SRC_NETWORK_ID AS NETWORK_ID, DST2SRC_BYTES AS BYTES $FROM$ $WHERE$ AND SRC_NETWORK_ID!=4294967295 UNION ALL SELECT VLAN_ID,DST_NETWORK_ID AS NETWORK_ID, SRC2DST_BYTES AS BYTES $FROM$ $WHERE$ AND DST_NETWORK_ID!=4294967295) AS f $GROUPBY$ $ORDERBY$ $LIMIT$"