diff --git a/userspace/falco/stats_writer.cpp b/userspace/falco/stats_writer.cpp index 49c31e66..0d8cde11 100644 --- a/userspace/falco/stats_writer.cpp +++ b/userspace/falco/stats_writer.cpp @@ -343,6 +343,14 @@ void stats_writer::collector::get_metrics_output_fields_additional( { output_fields["scap.evts_drop_rate_sec"] = (double)(0); } + if((n_evts - m_last_n_evts) > 0) + { + output_fields["scap.n_drops_perc"] = (double)((100.0 * (n_drops - m_last_n_drops)) / (n_evts - m_last_n_evts)); + } + else + { + output_fields["scap.n_drops_perc"] = (double)(0); + } output_fields["scap.n_drops_prev"] = m_last_n_drops; } output_fields[metric_name] = stats_v2[stat].value.u64; @@ -351,14 +359,6 @@ void stats_writer::collector::get_metrics_output_fields_additional( break; } } - if((n_evts - m_last_n_evts) > 0) - { - output_fields["scap.n_drops_perc"] = (double)((100.0 * (n_drops - m_last_n_drops)) / (n_evts - m_last_n_evts)); - } - else - { - output_fields["scap.n_drops_perc"] = (double)(0); - } m_last_n_evts = n_evts; m_last_n_drops = n_drops; }