ntopng/scripts/historical/tables
2023-12-15 12:02:28 +01:00
..
alerted_domains.json Add server contacts custom query 2023-06-27 15:43:50 +02:00
clients.json Add label and country to clients/servers presets 2023-07-31 16:31:07 +02:00
conversations.json Add hostnames to conversations custom queries (#8104) 2023-12-15 10:32:41 +01:00
l7_contacts.json Fix json configurationg l7 contacts for chart 2023-12-15 11:06:16 +01:00
latency_by_asn.json Fix analysis page with hourly toggle on (fix #7989) 2023-11-07 11:49:24 +01:00
number_of_hosts.json Update presets for aggregated historical flows. 2023-06-15 15:56:00 +00:00
README Add support for $ token in custom queries. Add support for hourly in top_receiver_networks/top_sender_networks 2023-08-02 09:55:49 +02:00
server_contacts.json Add hostnames to server contacts custom queries (#8104) 2023-12-15 11:57:46 +01:00
server_ports.json Change count type 2023-11-24 18:34:34 +01: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 custom query columns formatters and alignment 2023-06-27 16:47:16 +02:00
top_clients.json Add hostnames to top clients/servers custom queries (#8104) 2023-12-15 12:02:28 +01:00
top_local_talkers.json Compute dashboard historical top from aggregated 2023-09-04 18:44:05 +02:00
top_receiver_as.json Add custom queries for top receiver/sender AS 2023-08-03 10:46:29 +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 Add support for $ token in custom queries. Add support for hourly in top_receiver_networks/top_sender_networks 2023-08-02 09:55:49 +02:00
top_remote_destinations.json Compute dashboard historical top from aggregated 2023-09-04 18:44:05 +02:00
top_sender_as.json Add custom queries for top receiver/sender AS 2023-08-03 10:46:29 +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 Add support for $ token in custom queries. Add support for hourly in top_receiver_networks/top_sender_networks 2023-08-02 09:55:49 +02:00
top_servers.json Add hostnames to top clients/servers custom queries (#8104) 2023-12-15 12:02:28 +01: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!=65535 UNION ALL SELECT VLAN_ID,DST_NETWORK_ID AS NETWORK_ID, SRC2DST_BYTES AS BYTES $FROM$ $WHERE$ AND DST_NETWORK_ID!=65535) AS f $GROUPBY$ $ORDERBY$ $LIMIT$"