Skip to content

feature: add alternate method to parse namespace traffic - #53

Open
manueleiria wants to merge 11 commits into
davidgiga1993:masterfrom
manueleiria:feature/k8snamespacetrafficsourcefallback
Open

feature: add alternate method to parse namespace traffic#53
manueleiria wants to merge 11 commits into
davidgiga1993:masterfrom
manueleiria:feature/k8snamespacetrafficsourcefallback

Conversation

@manueleiria

Copy link
Copy Markdown

Pollect currently depends on BCC in order to use K8SNamespaceTrafficSource, but there seems to be an issue with it and the current version of AL2023 for Kubernetes 1.33. I was able to try a different solution that doesn't use kprobes that provides basic network traffic monitoring without the detailed per-process tracking that BPF provides.

@davidgiga1993 davidgiga1993 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your contribution!
Has this been written using AI? Because the code has a lot of unusual patterns in it.
Also there are a lot of issues with separations of concerns. Getting the actual metrics and interface data should be in separate classes, and not in the Source itself.

if self._debug_namespace_detection:
self.log.info(f"✅ Address {addr_str} matched namespace {namespace}")
return namespace
except:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is this for? Either remove or comment when this happens

# If no namespace match found, check if we have any namespace data at all
if not self._namespace_ips:
if self._debug_namespace_detection:
self.log.warning(f"❌ No namespace IPs available for address {addr_str} - runtime detection may have failed")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please no emojis to follow the other log patterns

connections.append(conn)

except Exception as e:
self.log.debug(f"Error reading TCP from PID {pid}: {e}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Isn't this an actual error?

# Common service port patterns and their typical traffic volumes
# These are rough estimates based on typical service behavior

# Web traffic (HTTP/HTTPS)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This code makes a LOT of assumptions about the type of traffic flowing.
For example a web download would or large db traffic would completely break the estimation. I'm not sure if this makes sense in a general library

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.

2 participants