zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.92k stars 6.65k forks source link

Integrate network statistics to Prometheus #81712

Open jukkar opened 1 day ago

jukkar commented 1 day ago

This allows network statistics to be exported via Prometheus.

Some of the Prometheus APIs are changed as they did not play very well with a real life example.

jukkar commented 21 hours ago
jukkar commented 2 hours ago

I was too early to mark it ready, this needs more work.

mustafaabdullahk commented 2 hours ago

I have to integrate network statistics to Prometheus. I glad to hear that pull request. I will put the comment after reviews. We can to be inspired 'node exporters'. Also it is good point to start. We can will integrate to each core libraries as windows/linux Prometheus 'node exporter' and after we can develop Zephyr node exporter Grafana template :)

jukkar commented 1 hour ago

I am wondering how the metrics should be named. The PR creates several metric for each network interface name, for example net_stats_eth_native_posix_0_0_bytes_recv_counter where the network interface instance information is embedded to the metric name. But it seems that Prometheus expects the metric to be named something like net_stats_bytes_recv_counter where the instance is not set in metric name. It seems that I should put the instance information to the label instead. @mustafaabdullahk is this a correct assumption?

mustafaabdullahk commented 1 hour ago

Yep, you may put 'net_stats_bytes_recv_counter' and pass the network interfaces as label.

Further reading = Metric and label naming

Like following:

image

jukkar commented 1 hour ago

Ok, I will change the generated output to look like this then

# HELP zephyr_net_bytes_sent Bytes sent
# TYPE zephyr_net_bytes_sent counter
zephyr_net_bytes_sent{nic="eth_native_posix_0_0"} 7391
# HELP zephyr_net_bytes_recv Bytes received
# TYPE zephyr_net_bytes_recv counter
zephyr_net_bytes_recv{nic="eth_native_posix_0_0"} 1647
jukkar commented 35 minutes ago