Skip to content

Commit 4c4dd8f

Browse files
committed
update(falco_metrics): add kernel_event_counters_per_cpu_enabled config
Signed-off-by: Melissa Kilby <[email protected]>
1 parent fe86c1f commit 4c4dd8f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

falco.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,9 @@ syscall_event_drops:
10661066
# counters reflect monotonic values since Falco's start and are exported at a
10671067
# constant stats interval.
10681068
#
1069+
# `kernel_event_counters_per_cpu_enabled`: Detailed kernel event and drop counters
1070+
# per CPU. typically used when debugging and not in production.
1071+
#
10691072
# `libbpf_stats_enabled`: Exposes statistics similar to `bpftool prog show`,
10701073
# providing information such as the number of invocations of each BPF program
10711074
# attached by Falco and the time spent in each program measured in nanoseconds.
@@ -1104,6 +1107,8 @@ metrics:
11041107
resource_utilization_enabled: true
11051108
state_counters_enabled: true
11061109
kernel_event_counters_enabled: true
1110+
# Enabling `kernel_event_counters_per_cpu_enabled` automatically enables `kernel_event_counters_enabled`
1111+
kernel_event_counters_per_cpu_enabled: false
11071112
libbpf_stats_enabled: true
11081113
plugins_metrics_enabled: true
11091114
convert_memory_to_mb: true

userspace/falco/configuration.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ void falco_configuration::load_yaml(const std::string& config_name)
581581
{
582582
m_metrics_flags |= METRICS_V2_KERNEL_COUNTERS;
583583
}
584+
if (m_config.get_scalar<bool>("metrics.kernel_event_counters_per_cpu_enabled", true))
585+
{
586+
m_metrics_flags |= METRICS_V2_KERNEL_COUNTERS_PER_CPU;
587+
}
584588
if (m_config.get_scalar<bool>("metrics.libbpf_stats_enabled", true))
585589
{
586590
m_metrics_flags |= METRICS_V2_LIBBPF_STATS;

userspace/falco/stats_writer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void stats_writer::collector::get_metrics_output_fields_additional(
470470
m_writer->m_output_rule_metrics_converter->convert_metric_to_unit_convention(metric);
471471
}
472472
char metric_name[METRIC_NAME_MAX] = "falco.";
473-
if((metric.flags & METRICS_V2_LIBBPF_STATS) || (metric.flags & METRICS_V2_KERNEL_COUNTERS) )
473+
if((metric.flags & METRICS_V2_LIBBPF_STATS) || (metric.flags & METRICS_V2_KERNEL_COUNTERS) || (metric.flags & METRICS_V2_KERNEL_COUNTERS_PER_CPU) )
474474
{
475475
strlcpy(metric_name, "scap.", sizeof(metric_name));
476476
}
@@ -600,7 +600,7 @@ void stats_writer::collector::collect(const std::shared_ptr<sinsp>& inspector, c
600600
// Note: src is static for live captures
601601
if (src != falco_common::syscall_source)
602602
{
603-
flags &= ~(METRICS_V2_KERNEL_COUNTERS | METRICS_V2_STATE_COUNTERS | METRICS_V2_LIBBPF_STATS);
603+
flags &= ~(METRICS_V2_KERNEL_COUNTERS | METRICS_V2_KERNEL_COUNTERS_PER_CPU | METRICS_V2_STATE_COUNTERS | METRICS_V2_LIBBPF_STATS);
604604

605605
}
606606
m_writer->m_libs_metrics_collector = std::make_unique<libs::metrics::libs_metrics_collector>(inspector.get(), flags);

0 commit comments

Comments
 (0)