Skip to content

Conversation

@angelbarrera92
Copy link

Trying to address: #540

I am exposing the same metrics as it was in egressd.
This is just a starting point, it would be amazing to understand how far I can go to integrate these changes in kvisor.


Visit the [docs](https://docs.cast.ai/docs/getting-started) to connect your cluster.

## Build Instructions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add this to DEVELOPMENT.md file.

var err error

ciliumCt4, err = bpf.OpenMap(proc.HostPath(filepath.Join(defaults.BPFFSRoot, defaults.TCGlobalsPath, ctmap.MapNameTCP4Global)), &ctmap.CtKey4Global{}, &ctmap.CtEntry{})
ciliumCt4, err = bpf.OpenMap(filepath.Join(defaults.BPFFSRoot, defaults.TCGlobalsPath, ctmap.MapNameTCP4Global), &ctmap.CtKey4Global{}, &ctmap.CtEntry{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there some issues accessing cilium ebpf maps via /proc/1/root ?

Copy link
Author

Choose a reason for hiding this comment

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

It didn't work for me in a kubeadm cluster baked by flatcar in AWS.
Did it for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't tested such setup. But on GKE, EKS with cilium haven't saw any issues.

Do you have some more context regarding the issue, what exactly didn't work just to understand it better?

Copy link
Author

Choose a reason for hiding this comment

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

In cilium 1.16 the conntrackaccounting was disabled by default, thats why it wasnt reporting the bytes...
In 1.17 is solved (but you need to explicit enable this feature)

var (
// egressd-compatible metrics
egressdTransmitBytesTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "egressd_transmit_bytes_total",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sadly this approach will not work efficiently. In egressd we have explicit metrics push via remote write api.
https://github.com/castai/egressd/blob/main/exporter/sinks/prom.go#L116

By using remote write api it will support not only original prometheus but mimir/cortex too. Also it allows to have different prometheus instance just for netflows metrics.

Copy link
Author

Choose a reason for hiding this comment

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

On egressd was the controller gathering metrics from the agent and then pushing remotely.

Probably kvisor has to implement the same approach... Do you have it on the roadmap?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, kvisor agent could push metrics directly from each agent to prometheus similar to clickhouse exporter.
For now we are no plans for it, but if you could update current prometheus_netflow_exporter that would great :)

@anjmao
Copy link
Collaborator

anjmao commented May 28, 2025

Thanks for the change. Added few comments.

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