-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose kernel ringbuffer errors in metrics #2839
Merged
+62
−22
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Loading status checks…
Expose kernel ringbuffer errors in metrics
There are two metrics counting events lost in the ringbuffer: * tetragon_missed_events_total, collected in BPF based on perf_event_output error * tetragon_ringbuf_perf_event_lost_total, collected in observer based on Record.LostSamples from cilium/ebpf When testing, I saw the former being higher than the latter. This might mean there are failed writes to the ringbuffer that are not lost events seen by Record.LostSamples. To investigate such issues, I'm adding error label to tetragon_missed_events_total, representing kernel error returned by perf_event_output. According to @olsajiri EBUSY and ENOSPC would be the only we could really hit, the rest is most likely due config error. So let's start with counting these two, and aggregating other errors as "unknown". We can always split out more errors in the future if needed. Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
commit c270528916f99bd13d63db31fbd7da741ff683f5
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -564,8 +564,13 @@ FUNC_INLINE struct execve_info *execve_joined_info_map_get(__u64 tid) | |
_Static_assert(sizeof(struct execve_map_value) % 8 == 0, | ||
"struct execve_map_value should have size multiple of 8 bytes"); | ||
|
||
#define SENT_FAILED_UNKNOWN 0 // unknown error | ||
#define SENT_FAILED_EBUSY 1 // EBUSY | ||
#define SENT_FAILED_ENOSPC 2 // ENOSPC | ||
#define SENT_FAILED_MAX 3 | ||
|
||
struct kernel_stats { | ||
__u64 sent_failed[256]; | ||
__u64 sent_failed[256][SENT_FAILED_MAX]; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a note.. I think it's ok because it's still small map, but it is per cpu and this change multiplies the memory usage by 3 |
||
|
||
struct { | ||
|
@@ -576,7 +581,7 @@ struct { | |
} tg_stats_map SEC(".maps"); | ||
|
||
FUNC_INLINE void | ||
perf_event_output_metric(void *ctx, u8 metric, void *map, u64 flags, void *data, u64 size) | ||
perf_event_output_metric(void *ctx, u8 msg_op, void *map, u64 flags, void *data, u64 size) | ||
{ | ||
struct kernel_stats *valp; | ||
__u32 zero = 0; | ||
|
@@ -585,8 +590,14 @@ perf_event_output_metric(void *ctx, u8 metric, void *map, u64 flags, void *data, | |
err = perf_event_output(ctx, map, flags, data, size); | ||
if (err < 0) { | ||
valp = map_lookup_elem(&tg_stats_map, &zero); | ||
if (valp) | ||
__sync_fetch_and_add(&valp->sent_failed[metric], 1); | ||
if (valp) { | ||
if (err == -16) // EBUSY | ||
__sync_fetch_and_add(&valp->sent_failed[msg_op][SENT_FAILED_EBUSY], 1); | ||
else if (err == -28) // ENOSPC | ||
__sync_fetch_and_add(&valp->sent_failed[msg_op][SENT_FAILED_ENOSPC], 1); | ||
else | ||
__sync_fetch_and_add(&valp->sent_failed[msg_op][SENT_FAILED_UNKNOWN], 1); | ||
} | ||
} | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, extra tab screwing the diff in terminal