Commit 0ac4a2a
committed
expose num_evts metric in Prometheus output (#3584)
The `num_evts` counter is already emitted by the JSON / text stats
sinks (via stats_writer::collector::get_metrics_output_fields_wrapper)
but the Prometheus output sink at /metrics never got it. Anyone
running Falco with prometheus_metrics_enabled couldn't see how many
events the agent had processed.
Three small wires to bridge the gap:
app/state.h
add `std::atomic<uint64_t> num_evts = 0;` to the shared state
so a counter is reachable from both the per-source event loop
and the prometheus sink without plumbing stats_writer through.
app/actions/process_events.cpp
after each `num_evts++` for the local source counter, also
bump `s.num_evts` with relaxed memory ordering. Cheap, lock-free
counter increment per event.
falco_metrics.cpp
emit a `falcosecurity_falco_num_evts_total` counter alongside the
existing `falcosecurity_falco_outputs_queue_num_drops_total` block
in `falco_to_text_prometheus`. Same metric type / unit pattern as
the queue-drops counter just above it.
Output:
# HELP falcosecurity_falco_num_evts_total https://falco.org/docs/metrics/
# TYPE falcosecurity_falco_num_evts_total counter
falcosecurity_falco_num_evts_total 123451 parent af5bd6c commit 0ac4a2a
3 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
389 | 393 | | |
390 | 394 | | |
391 | 395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
77 | 84 | | |
78 | 85 | | |
79 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
| |||
0 commit comments