diff --git a/userspace/falco/stats_writer.cpp b/userspace/falco/stats_writer.cpp index e93b26e5abb..fe6415fedfe 100644 --- a/userspace/falco/stats_writer.cpp +++ b/userspace/falco/stats_writer.cpp @@ -358,40 +358,37 @@ void stats_writer::collector::get_metrics_output_fields_wrapper( output_fields[metric_name_file_sha256] = item.second; } - if (stats_snapshot_time_delta_sec == 0) + auto ipv4list = inspector->get_ifaddr_list().get_ipv4_list(); + auto ipv6list = inspector->get_ifaddr_list().get_ipv6_list(); + nlohmann::json ipv4_json; + nlohmann::json ipv6_json; + if(ipv4list) { - auto ipv4list = inspector->get_ifaddr_list().get_ipv4_list(); - auto ipv6list = inspector->get_ifaddr_list().get_ipv6_list(); - nlohmann::json ipv4_json; - nlohmann::json ipv6_json; - if(ipv4list) + for (const auto& item : *ipv4list) { - for (const auto& item : *ipv4list) + if(item.m_name == "lo") { - if(item.m_name == "lo") - { - continue; - } - ipv4_json[item.m_name] = item.addr_to_string(); + continue; } + ipv4_json[item.m_name] = item.addr_to_string(); } + } - if(ipv6list) + if(ipv6list) + { + for (const auto& item : *ipv6list) { - for (const auto& item : *ipv6list) + if(item.m_name == "lo") { - if(item.m_name == "lo") - { - continue; - } - ipv6_json[item.m_name] = item.addr_to_string(); + continue; } + ipv6_json[item.m_name] = item.addr_to_string(); } - nlohmann::json ifinfo_json; - ifinfo_json["ipv4"] = ipv4_json; - ifinfo_json["ipv6"] = ipv6_json; - m_ifinfo_json_escaped = ifinfo_json.dump(); } + nlohmann::json ifinfo_json; + ifinfo_json["ipv4"] = ipv4_json; + ifinfo_json["ipv6"] = ipv6_json; + m_ifinfo_json_escaped = ifinfo_json.dump(); output_fields["falco.host_ifinfo_json"] = m_ifinfo_json_escaped; #endif