Skip to content

add flag to disable event metrics#4926

Open
dangome3 wants to merge 4 commits into
cilium:mainfrom
dangome3:daniel/splitHealthAndEventMetrics
Open

add flag to disable event metrics#4926
dangome3 wants to merge 4 commits into
cilium:mainfrom
dangome3:daniel/splitHealthAndEventMetrics

Conversation

@dangome3
Copy link
Copy Markdown
Contributor

@dangome3 dangome3 commented Apr 28, 2026

Description

Add --enable-event-metrics flag (default: true) to allow disabling event metrics while keeping health and resource metrics available.

Split InitAllMetrics into InitHealthMetrics and InitEventsMetrics. Health metrics and resource metrics are always initialized when --metrics-server is set.

Unit tests for metrics config added in 'pkg/metrics/metricwithpod_test.go' also manually tested in a no-k8s environment.

Changelog

metrics: add agent flag to disable event metrics while keeping health metrics

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 28, 2026

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit b7c3966
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/6a039b561478de00085f4c78
😎 Deploy Preview https://deploy-preview-4926--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dangome3 dangome3 marked this pull request as ready for review April 29, 2026 12:55
@dangome3 dangome3 requested review from a team and mtardy as code owners April 29, 2026 12:55
@mtardy mtardy added the release-note/minor This PR introduces a minor user-visible change label May 4, 2026
Copy link
Copy Markdown
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dangome3!

Can you please split the first patch in two patches? One for the new functionality, and one for the unit tests?

@dangome3 dangome3 force-pushed the daniel/splitHealthAndEventMetrics branch from 68ba7ab to faa361e Compare May 5, 2026 17:03
@dangome3 dangome3 requested a review from kkourt May 5, 2026 19:31
@dangome3
Copy link
Copy Markdown
Contributor Author

dangome3 commented May 5, 2026

Hey @kkourt ! sure! that's already done. Thanks for the suggestion

Copy link
Copy Markdown
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good thanks, just a few comments.

Also I know the patch is quite simple but the first one could have been also sliced into two, your commit description is a hint for this, your commit does two things:

Add --enable-event-metrics flag (default: true) to allow disabling
event metrics while keeping health and resource metrics available.

Split InitAllMetrics into InitHealthMetrics and InitEventsMetrics.
Health metrics and resource metrics are always initialized when
--metrics-server is set.

I would have split first, and then added the flag in two separate commits.

Comment on lines +249 to +250
metricsconfig.InitHealthMetrics(metricsconfig.GetRegistry())
metricsconfig.InitEventsMetrics(metricsconfig.GetRegistry())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: we don't want to respect the flag from testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentional as this file contains only tests helper functions, and maybe any test could use the event metrics too

Please let me know if my assumption is wrong and if we should respect the flag here too

Comment on lines +53 to +54
By default, Tetragon exposes both health and events metrics. You can disable events metrics while keeping
health metrics by adding `--enable-event-metrics=false`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrapping is a bit wrong here (like in the rest of that doc btw)

Suggested change
By default, Tetragon exposes both health and events metrics. You can disable events metrics while keeping
health metrics by adding `--enable-event-metrics=false`.
By default, Tetragon exposes both health and events metrics. You can disable
events metrics while keeping health metrics by adding `--enable-event-metrics=false`.

Comment on lines 10 to 11
1. Monitoring the health of Tetragon itself
2. Monitoring the activity of processes observed by Tetragon
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like you could add a note there just after 1. and 2. instead of later in the ## Enable/Disable Metrics and ### Non-Kubernetes section.

@dangome3 dangome3 force-pushed the daniel/splitHealthAndEventMetrics branch from faa361e to b7c3966 Compare May 12, 2026 21:27
@dangome3
Copy link
Copy Markdown
Contributor Author

Thanks @mtardy for the suggestions. I updated the PR

@kkourt
Copy link
Copy Markdown
Contributor

kkourt commented May 13, 2026

Also I know the patch is quite simple but the first one could have been also sliced into two, your commit description is a hint for this, your commit does two things:

Add --enable-event-metrics flag (default: true) to allow disabling
event metrics while keeping health and resource metrics available.

Split InitAllMetrics into InitHealthMetrics and InitEventsMetrics.
Health metrics and resource metrics are always initialized when
--metrics-server is set.

I would have split first, and then added the flag in two separate commits.

I believe what Mahè meant here is to:

  1. Split the implementation of InitAllMetrics into InitHealthMetrics and InitEventsMetrics into one commit
  2. Add the flag, and use it to determine whether InitEventMetrics or not in the second commit.

In the current split, the flag is introduced in the first patch, and then used in the second patch, which I find more confusing that having both changes in a single patch (as originally).

@dangome3 dangome3 force-pushed the daniel/splitHealthAndEventMetrics branch from b7c3966 to db0bfe1 Compare May 13, 2026 13:04
dangome3 added 4 commits May 13, 2026 08:08
Split InitAllMetrics in two functions, InitHealthMetrics and
InitEventsMetrics.

Signed-off-by: Daniel Gomez <dangome3@cisco.com>
Add --enable-event-metrics flag (default: true) to allow disabling
event metrics while keeping health and resource metrics available.

Signed-off-by: Daniel Gomez <dangome3@cisco.com>
Unit tests for metrics config added in 'pkg/metrics/metricwithpod_test.go'
Covered tests for health only metrics and halth+event metrics enabled.

Signed-off-by: Daniel Gomez <dangome3@cisco.com>
Signed-off-by: Daniel Gomez <dangome3@cisco.com>
@dangome3 dangome3 force-pushed the daniel/splitHealthAndEventMetrics branch from db0bfe1 to 4a8498b Compare May 13, 2026 13:12
@dangome3
Copy link
Copy Markdown
Contributor Author

In the current split, the flag is introduced in the first patch, and then used in the second patch, which I find more confusing that having both changes in a single patch (as originally).

That's 💯 right, sorry for the confusion. That should be fixed now

@dangome3 dangome3 requested a review from mtardy May 13, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/minor This PR introduces a minor user-visible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants