doc/developers/AddClickhouseColumns.md
This guide explains how to add a new column to ntopng so that it can be queried from the frontend Historical Flows page.
To expose a new column in the historical flow search:
Edit the schema file:
httpdocs/misc/db_schema_clickhouse.sql
flows, aggregated_flows_hourly, etc.).Edit the tag definition in:
scripts/lua/modules/tag_utils.lua
Add an entry for your new column (example: dst_peer_as):
dst_peer_as = {
value_type = 'asn',
i18n_label = i18n('db_search.tags.dst_peer_as'),
operators = { 'eq', 'neq' },
hourly_available = false,
},
hourly_available field should be set to true if you want the field usable in hourly aggregations.Edit:
scripts/lua/modules/historical_flow_utils.lua
Add the new column to the flow_columns table:
['DST_PEER_ASN'] = { tag = "dst_peer_asn" },
DST_PEER_ASN) should match the column name in ClickHouse (uppercase).tag must correspond to the tag defined in tag_utils.lua.If aggregations (e.g., hourly) are enabled, ensure the new column is also available in:
db_schema_clickhouse.sqlscripts/lua/modules/historical_flow_utils.lua aggregated_flow_columns.Edit:
pro/scripts/lua/rest/v2/get/flow/historical/flow_details.lua
Find and update the historical_flow_details_formatter.formatHistoricalFlowDetails(flow) function to include your new column:
formatted_flow.dst_peer_asn = flow.dst_peer_asn
This ensures the new field is visible in the frontend when rendering historical flow details.
To add a new column for querying and displaying in the historical flow UI, update the following files:
httpdocs/misc/db_schema_clickhouse.sqlscripts/lua/modules/tag_utils.luascripts/lua/modules/historical_flow_utils.luapro/scripts/lua/rest/v2/get/flow/historical/flow_details.luaEnsure that all parts are in sync to allow querying, filtering, and rendering of the new column.