Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ip_port top metrics #621

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/handlers/flow/FlowStreamHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ void FlowMetricsBucket::specialized_merge(const AbstractMetricsBucket &o, [[mayb
top_dir.second.topDstPort.merge(interface.second->directionTopN.at(top_dir.first).topDstPort);
}
if (group_enabled(group::FlowMetrics::TopIPPorts)) {
top_dir.second.topSrcIPandPort.merge(interface.second->directionTopN.at(top_dir.first).topSrcIPandPort);
top_dir.second.topDstIPandPort.merge(interface.second->directionTopN.at(top_dir.first).topDstIPandPort);
top_dir.second.topSrcIPPort.merge(interface.second->directionTopN.at(top_dir.first).topSrcIPPort);
top_dir.second.topDstIPPort.merge(interface.second->directionTopN.at(top_dir.first).topDstIPPort);
}
}

Expand Down Expand Up @@ -821,8 +821,8 @@ void FlowMetricsBucket::to_prometheus(std::stringstream &out, Metric::LabelMap a
top_dir.second.topDstPort.to_prometheus(out, interface_labels);
}
if (group_enabled(group::FlowMetrics::TopIPPorts)) {
top_dir.second.topSrcIPandPort.to_prometheus(out, interface_labels);
top_dir.second.topDstIPandPort.to_prometheus(out, interface_labels);
top_dir.second.topSrcIPPort.to_prometheus(out, interface_labels);
top_dir.second.topDstIPPort.to_prometheus(out, interface_labels);
}
}

Expand Down Expand Up @@ -976,8 +976,8 @@ void FlowMetricsBucket::to_opentelemetry(metrics::v1::ScopeMetrics &scope, Metri
top_dir.second.topDstPort.to_opentelemetry(scope, start_ts, end_ts, interface_labels);
}
if (group_enabled(group::FlowMetrics::TopIPPorts)) {
top_dir.second.topSrcIPandPort.to_opentelemetry(scope, start_ts, end_ts, interface_labels);
top_dir.second.topDstIPandPort.to_opentelemetry(scope, start_ts, end_ts, interface_labels);
top_dir.second.topSrcIPPort.to_opentelemetry(scope, start_ts, end_ts, interface_labels);
top_dir.second.topDstIPPort.to_opentelemetry(scope, start_ts, end_ts, interface_labels);
}
}

Expand Down Expand Up @@ -1125,8 +1125,8 @@ void FlowMetricsBucket::to_json(json &j) const
top_dir.second.topDstPort.to_json(j["devices"][deviceId]["interfaces"][interfaceId]);
}
if (group_enabled(group::FlowMetrics::TopIPPorts)) {
top_dir.second.topSrcIPandPort.to_json(j["devices"][deviceId]["interfaces"][interfaceId]);
top_dir.second.topDstIPandPort.to_json(j["devices"][deviceId]["interfaces"][interfaceId]);
top_dir.second.topSrcIPPort.to_json(j["devices"][deviceId]["interfaces"][interfaceId]);
top_dir.second.topDstIPPort.to_json(j["devices"][deviceId]["interfaces"][interfaceId]);
}
}

Expand Down Expand Up @@ -1319,7 +1319,7 @@ void FlowMetricsBucket::process_interface(bool deep, FlowInterface *iface, const
iface->directionTopN.at(type).topSrcIP.update(ip, aggregator);
}
if ((flow.src_port > 0) && group_enabled(group::FlowMetrics::TopIPPorts)) {
iface->directionTopN.at(type).topSrcIPandPort.update(application_src, aggregator);
iface->directionTopN.at(type).topSrcIPPort.update(application_src, aggregator);
}
_process_geo_metrics(iface, type, flow.ipv4_in, aggregator);
} else if (flow.is_ipv6 && flow.ipv6_in.isValid()) {
Expand All @@ -1336,7 +1336,7 @@ void FlowMetricsBucket::process_interface(bool deep, FlowInterface *iface, const
iface->directionTopN.at(type).topSrcIP.update(ip, aggregator);
}
if ((flow.src_port > 0) && group_enabled(group::FlowMetrics::TopIPPorts)) {
iface->directionTopN.at(type).topSrcIPandPort.update(application_src, aggregator);
iface->directionTopN.at(type).topSrcIPPort.update(application_src, aggregator);
}
_process_geo_metrics(iface, type, flow.ipv6_in, aggregator);
}
Expand All @@ -1353,7 +1353,7 @@ void FlowMetricsBucket::process_interface(bool deep, FlowInterface *iface, const
iface->directionTopN.at(type).topDstIP.update(ip, aggregator);
}
if ((flow.dst_port > 0) && group_enabled(group::FlowMetrics::TopIPPorts)) {
iface->directionTopN.at(type).topDstIPandPort.update(application_dst, aggregator);
iface->directionTopN.at(type).topDstIPPort.update(application_dst, aggregator);
}
_process_geo_metrics(iface, type, flow.ipv4_out, aggregator);
} else if (flow.is_ipv6 && flow.ipv6_out.isValid()) {
Expand All @@ -1370,7 +1370,7 @@ void FlowMetricsBucket::process_interface(bool deep, FlowInterface *iface, const
iface->directionTopN.at(type).topDstIP.update(ip, aggregator);
}
if ((flow.dst_port > 0) && group_enabled(group::FlowMetrics::TopIPPorts)) {
iface->directionTopN.at(type).topDstIPandPort.update(application_dst, aggregator);
iface->directionTopN.at(type).topDstIPPort.update(application_dst, aggregator);
}
_process_geo_metrics(iface, type, flow.ipv6_out, aggregator);
}
Expand Down
14 changes: 7 additions & 7 deletions src/handlers/flow/FlowStreamHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct FlowTopN {
TopN<std::string> topASN;

FlowTopN(std::string metric)
: topConversations(FLOW_SCHEMA, "conversations", {"top_conversations_" + metric}, "Top source IP addresses and port by " + metric)
: topConversations(FLOW_SCHEMA, "conversation", {"top_conversations_" + metric}, "Top source IP addresses and port by " + metric)
, topGeoLoc(FLOW_SCHEMA, "geo_loc", {"top_geo_loc_" + metric}, "Top GeoIP locations by " + metric)
, topASN(FLOW_SCHEMA, "asn", {"top_asn_" + metric}, "Top ASNs by IP by " + metric)
{
Expand All @@ -135,16 +135,16 @@ struct FlowDirectionTopN {
TopN<std::string> topDstIP;
TopN<std::string> topSrcPort;
TopN<std::string> topDstPort;
TopN<std::string> topSrcIPandPort;
TopN<std::string> topDstIPandPort;
TopN<std::string> topSrcIPPort;
TopN<std::string> topDstIPPort;

FlowDirectionTopN(std::string direction, std::string metric)
: topSrcIP(FLOW_SCHEMA, "ip", {"top_" + direction + "_src_ips_" + metric}, "Top " + direction + " source IP addresses by " + metric)
, topDstIP(FLOW_SCHEMA, "ip", {"top_" + direction + "_dst_ips_" + metric}, "Top " + direction + " destination IP addresses by " + metric)
, topSrcPort(FLOW_SCHEMA, "port", {"top_" + direction + "_src_ports_" + metric}, "Top " + direction + " source ports by " + metric)
, topDstPort(FLOW_SCHEMA, "port", {"top_" + direction + "_dst_ports_" + metric}, "Top " + direction + " destination ports by " + metric)
, topSrcIPandPort(FLOW_SCHEMA, "ip_port", {"top_" + direction + "_src_ips_and_port_" + metric}, "Top " + direction + " source IP addresses and port by " + metric)
, topDstIPandPort(FLOW_SCHEMA, "ip_port", {"top_" + direction + "_dst_ips_and_port_" + metric}, "Top " + direction + " destination IP addresses and port by " + metric)
, topSrcIPPort(FLOW_SCHEMA, "ip_port", {"top_" + direction + "_src_ip_ports_" + metric}, "Top " + direction + " source IP addresses and port by " + metric)
, topDstIPPort(FLOW_SCHEMA, "ip_port", {"top_" + direction + "_dst_ip_ports_" + metric}, "Top " + direction + " destination IP addresses and port by " + metric)
{
}

Expand All @@ -154,8 +154,8 @@ struct FlowDirectionTopN {
topDstIP.set_settings(topn_count, percentile_threshold);
topSrcPort.set_settings(topn_count, percentile_threshold);
topDstPort.set_settings(topn_count, percentile_threshold);
topSrcIPandPort.set_settings(topn_count, percentile_threshold);
topDstIPandPort.set_settings(topn_count, percentile_threshold);
topSrcIPPort.set_settings(topn_count, percentile_threshold);
topDstIPPort.set_settings(topn_count, percentile_threshold);
}
};

Expand Down
20 changes: 10 additions & 10 deletions src/handlers/flow/tests/test_flows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TEST_CASE("Parse sflow stream", "[sflow][flow]")
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_dst_ports_bytes"][0]["estimate"] == 170879120000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_dst_ports_bytes"][0]["name"] == "commplex-link");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ports_bytes"][0]["name"] == "dynamic-client");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ips_and_port_bytes"][0]["estimate"] == 108027400000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ips_and_port_bytes"][0]["name"] == "10.4.1.2:dynamic-client");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ip_ports_bytes"][0]["estimate"] == 108027400000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ip_ports_bytes"][0]["name"] == "10.4.1.2:dynamic-client");
}

TEST_CASE("Parse sflow with enrichment", "[sflow][flow]")
Expand Down Expand Up @@ -143,8 +143,8 @@ TEST_CASE("Parse sflow stream without sampling", "[sflow][flow]")
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_packets"][0]["estimate"] == 258);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_packets"][0]["name"] == "10.4.4.2");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_dst_ports_bytes"][0]["estimate"] == 18060);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_and_port_bytes"][0]["estimate"] == 18060);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_and_port_bytes"][0]["name"] == "10.4.4.2:commplex-link");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ip_ports_bytes"][0]["estimate"] == 18060);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ip_ports_bytes"][0]["name"] == "10.4.4.2:commplex-link");
}

TEST_CASE("Parse sflow stream with ip filter", "[sflow][flow]")
Expand Down Expand Up @@ -183,8 +183,8 @@ TEST_CASE("Parse sflow stream with ip filter", "[sflow][flow]")
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_packets"][0]["estimate"] == 5160000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_out_src_ips_packets"][0]["name"] == "10.4.4.2");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_dst_ports_bytes"][0]["estimate"] == 62851720000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ips_and_port_bytes"][0]["estimate"] == 62851720000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ips_and_port_bytes"][0]["name"] == "10.4.3.2:registered-40k");
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ip_ports_bytes"][0]["estimate"] == 62851720000);
CHECK(j["devices"]["192.168.0.13"]["interfaces"]["52"]["top_in_src_ip_ports_bytes"][0]["name"] == "10.4.3.2:registered-40k");
}

TEST_CASE("Parse sflow stream with device filter", "[sflow][flow]")
Expand Down Expand Up @@ -225,8 +225,8 @@ TEST_CASE("Parse sflow stream with device filter", "[sflow][flow]")
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ips_packets"][0]["estimate"] == 8040000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ips_packets"][0]["name"] == "10.4.2.2");
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_in_dst_ports_bytes"][0]["estimate"] == 264021720000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ips_and_port_bytes"][0]["estimate"] == 563840000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ips_and_port_bytes"][0]["name"] == "10.4.2.2:commplex-link");
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ip_ports_bytes"][0]["estimate"] == 563840000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["37"]["top_out_src_ip_ports_bytes"][0]["name"] == "10.4.2.2:commplex-link");

CHECK(j["devices"]["192.168.0.13"]["records_filtered"] == 7189);
}
Expand Down Expand Up @@ -269,8 +269,8 @@ TEST_CASE("Parse sflow stream with port filter", "[sflow][flow]")
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_in_src_ips_packets"][0]["estimate"] == 16820000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_in_src_ips_packets"][0]["name"] == "10.4.3.2");
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_in_dst_ports_bytes"][0]["estimate"] == 25532760000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_out_src_ips_and_port_bytes"][0]["estimate"] == 71400000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_out_src_ips_and_port_bytes"][0]["name"] == "10.4.4.2:commplex-link");
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_out_src_ip_ports_bytes"][0]["estimate"] == 71400000);
CHECK(j["devices"]["192.168.0.11"]["interfaces"]["38"]["top_out_src_ip_ports_bytes"][0]["name"] == "10.4.4.2:commplex-link");
}

TEST_CASE("Parse sflow stream with subnet summary", "[sflow][flow]")
Expand Down