Added custom field mapping in historical flows

This commit is contained in:
Matteo Biscosi 2024-11-06 10:46:33 +01:00
parent 3652422106
commit 10f2fe880f
6 changed files with 154 additions and 21 deletions

View file

@ -526,6 +526,34 @@ local function format_historical_proto_info(flow_details, proto_info)
local info = format_proto_info(flow_details, proto_info)
return info
end
-- ###############################################
local function format_historical_custom_fields(flow_details, custom_fields)
if table.len(custom_fields) > 0 then
require "flow_utils"
local flow_field_value_maps = require "flow_field_value_maps"
flow_details[#flow_details + 1] = {
name = i18n("flow_details.additional_flow_elements"),
values = {""}
}
for key, value in pairs(custom_fields) do
key, value = flow_field_value_maps.map_field_value(interface.getId(), key, value)
local nprobe_description = interface.getZMQFlowFieldDescr(key)
if isEmptyString(nprobe_description) then
nprobe_description = key
end
flow_details[#flow_details + 1] = {
name = "",
values = { nprobe_description , value }
}
end
end
return flow_details
end
-- ###############################################
local function format_historical_flow_traffic_stats(rowspan, cli2srv_retr, srv2cli_retr, cli2srv_ooo, srv2cli_ooo,
@ -702,6 +730,10 @@ function historical_flow_details_formatter.formatHistoricalFlowDetails(flow)
table.remove(flow_details, #flow_details)
end
end
if table.len(alert_json["proto"]) > 0 then
flow_details = format_historical_custom_fields(flow_details, alert_json["custom_fields"])
end
end
return flow_details