Implemented egress traffic Sankey with ASN source data (#9311)

This commit is contained in:
Manuel Ceroni 2025-06-25 14:08:15 +02:00 committed by GitHub
parent bd4aa03495
commit 73ec8592e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 30 deletions

View file

@ -23,15 +23,12 @@ local flows_stats = interface.getFlowsInfo(flows_filter["hostFilter"], flows_fil
flows_filter["client"], flows_filter["server"], flows_filter["flow_info"])
local unit
if criteria_as == "traffic_criteria" then
unit = " Ingress"
if criteria_as == "egress_traffic_criteria" then
unit = "Egress"
else
unit = " Egress"
unit = "Ingress"
end
-- For now only ingress
unit = " Ingress"
-- ################################################
if isEmptyString(ifid) then
@ -88,11 +85,11 @@ end
asn = tonumber(asn)
for flow_id, flow in pairs(flows_stats.flows) do
if type(flow) == "table" then
if flow.dst_as == asn then
local exporter_ip = getProbeName(flow.device_ip) or "unknown"
local exporter_ip = getProbeName(flow.device_ip) or "unknown"
local bytes = tonumber(flow.bytes) or 0
local exporter_node_id = find_node_id(exporter_ip)
if unit == "Ingress" and flow.dst_as == asn then
local port_index = format_portidx_name(flow.device_ip, flow.in_index) or "?"
local bytes = tonumber(flow.bytes) or 0
local exporter_node_id = find_node_id(exporter_ip)
local n_id = exporter_ip .. "@" .. port_index
local port_node_id = find_node_id(n_id)
@ -111,6 +108,25 @@ for flow_id, flow in pairs(flows_stats.flows) do
value = bytes
})
end
if unit == "Egress" and flow.src_as == asn then
local port_index = format_portidx_name(flow.device_ip, flow.out_index) or "?"
local n_id = exporter_ip .. "@" .. port_index
local port_node_id = find_node_id(n_id)
add_unique_node(exporter_node_id, exporter_ip, "#")
add_unique_node(port_node_id, port_index, "#")
table.insert(links, {
source_node_id = as_root_key,
target_node_id = exporter_node_id,
value = bytes
})
table.insert(links, {
source_node_id = exporter_node_id,port_node_id,
target_node_id = port_node_id,
value = bytes
})
end
end
end