feat: introduce policy event logs scope #491
Open
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.
Issues:
#482
#463
#464 (comment)
#427
Description of changes:
This feature allows to narrow the ebpf programs events scope (both
ACCEPT and DENYoronly DENY). To filter out the ACCEPT logs and metrics please specify--enable-policy-event-logs=trueand--policy-event-logs-scope=deny.The policy event logs volume can be overwhelming. The high CPU usage comes usually from userspace process processing the ebpf events published to
RINGBUF, which are mostly theACCEPTevents.Secondly the policy events logs are critical due to observability reasons. There is no command to confirm the NP is dropping traffic. The only way is to enable
enable-policy-event-logs=true, which is quite resources heavy and might decrease environment performance.Finally, by reducing the
ACCEPTevents we can get a guarantee that allDENYevents are written to log files. The policy_eventsRINGBUFhas a fixed size (https://github.com/aws/aws-network-policy-agent/blob/main/pkg/ebpf/c/v4events.bpf.c#L53), when exceeding the buffer capacity some old events are dropped and eventually missing in the log files.Alternatively the feature could be implemented as:
ACCEPTevents,DENYandACCEPTevents separately (probably cleaner approach, less ebpf maps lookups)The goal is to discuss the overall architecture. Please consider this PR as prototype, not yet a final implementation.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.