Skip to content
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

adding drop bytes and drop packets count metric #316

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

yash97
Copy link
Contributor

@yash97 yash97 commented Oct 2, 2024

Issue #, if available:

solves #229
Description of changes:
This PR enhances the network policy agent by adding packet length and direction information to policy events. These additions enable the export of more detailed metrics, specifically:

  1. Packet drop counts with direction
  2. Packet drop bytes with direction

Sample Output of metrics:

We have prometheus port setup here Code Customer can use Prometheus or other tool to scrape metrics.

 curl localhost:61680/metrics

# HELP network_policy_drop_bytes_total Total number of bytes dropped by network policy agent
# TYPE network_policy_drop_bytes_total counter
network_policy_drop_bytes_total{direction="ingress"} 1.0665324e+07
# HELP network_policy_drop_count_total Total number of packets dropped by network policy agent
# TYPE network_policy_drop_count_total counter
network_policy_drop_count_total{direction="ingress"} 144126

Important Notes

These metrics will only be measured if the --enable-policy-event-logs flag is set to true.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@yash97 yash97 requested a review from a team as a code owner October 2, 2024 05:45
@yash97 yash97 changed the title [Draft] adding drop bytes and drop packets count metric adding drop bytes and drop packets count metric Oct 3, 2024
@yash97 yash97 changed the title adding drop bytes and drop packets count metric [Draft]adding drop bytes and drop packets count metric Oct 23, 2024
@yash97 yash97 changed the title [Draft]adding drop bytes and drop packets count metric adding drop bytes and drop packets count metric Dec 18, 2024
@@ -61,6 +61,8 @@ struct data_t {
__u32 dest_port;
__u32 protocol;
__u32 verdict;
__u32 packet_sz;
__u8 is_egress;
Copy link
Member

Choose a reason for hiding this comment

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

Why do we use unsigned 8 here? Is it this a reference from kernel data structure or since the value be 0 or 1 we chose the __u8 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its just to store boolean value

@Pavani-Panakanti
Copy link
Contributor

@yash97 How are these metrics being exposed to cx and how can cx use these metrics for monitoring ?

@yash97
Copy link
Contributor Author

yash97 commented Jan 17, 2025

@Pavani-Panakanti cx can scrape metrics through open prometheus port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants