mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-17 16:21:31 +00:00
update(metrics): introduce immediate initial metrics msg (output_rule or output_file) upon start/restart/hot_reload
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
This commit is contained in:
parent
c5c51eb14d
commit
0123af47e7
@ -246,7 +246,7 @@ void stats_writer::worker() noexcept {
|
||||
|
||||
// this helps waiting for the first tick
|
||||
tick = stats_writer::get_ticker();
|
||||
if(first_tick != tick) {
|
||||
if(m_first_run || first_tick != tick) {
|
||||
if(last_tick != tick) {
|
||||
m_total_samples++;
|
||||
}
|
||||
@ -274,6 +274,7 @@ void stats_writer::worker() noexcept {
|
||||
"stats_writer (worker): " + std::string(e.what()) + "\n");
|
||||
}
|
||||
}
|
||||
m_first_run = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -638,7 +639,7 @@ void stats_writer::collector::collect(const std::shared_ptr<sinsp>& inspector,
|
||||
#endif
|
||||
/* Collect stats / metrics once per ticker period. */
|
||||
auto tick = stats_writer::get_ticker();
|
||||
if(tick != m_last_tick) {
|
||||
if(m_first_run || tick != m_last_tick) {
|
||||
m_last_tick = tick;
|
||||
auto now = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
@ -659,7 +660,10 @@ void stats_writer::collector::collect(const std::shared_ptr<sinsp>& inspector,
|
||||
num_evts,
|
||||
now,
|
||||
stats_snapshot_time_delta_sec);
|
||||
get_metrics_output_fields_additional(output_fields, stats_snapshot_time_delta_sec);
|
||||
if(!m_first_run) {
|
||||
get_metrics_output_fields_additional(output_fields, stats_snapshot_time_delta_sec);
|
||||
}
|
||||
m_first_run = false;
|
||||
|
||||
/* Send message in the queue */
|
||||
stats_writer::msg msg;
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
double stats_snapshot_time_delta_sec);
|
||||
|
||||
std::shared_ptr<stats_writer> m_writer;
|
||||
bool m_first_run = true;
|
||||
stats_writer::ticker_t m_last_tick = 0;
|
||||
uint64_t m_last_now = 0;
|
||||
uint64_t m_last_n_evts = 0;
|
||||
@ -144,6 +145,7 @@ private:
|
||||
inline void push(const stats_writer::msg& m);
|
||||
|
||||
bool m_initialized = false;
|
||||
bool m_first_run = true;
|
||||
uint64_t m_total_samples = 0;
|
||||
std::thread m_worker;
|
||||
std::ofstream m_file_output;
|
||||
|
Loading…
Reference in New Issue
Block a user