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

Integrate network statistics to Prometheus #81712

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jukkar
Copy link
Member

@jukkar jukkar commented Nov 21, 2024

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.

The PR is still WIP and is missing these things:

  • Add gauge/histogram/summary support for relevant statistics variables
  • Add traffic class statistics to be exported
  • Fix HTTP server so that we do not need to allocate massive buffer for the Prometheus data that is sent. The scraped data, that is to be sent out via HTTP GET request, needs to be sent in small chunks so that we do not need to allocate a large buffer for that.
  • Fix prometheus_format_exposition() as it no longer works as expected

@jukkar jukkar added In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on area: Networking labels Nov 21, 2024
Add function to increase the counter value with arbitrary value.

Signed-off-by: Jukka Rissanen <[email protected]>
Add a test that will test the counter value add functionality.

Signed-off-by: Jukka Rissanen <[email protected]>
This is similar function as add, but will add the difference of
previous value and the new one. This can be used if we want to
periodically update the value with a new one but don't want to
keep track of the old one.

Signed-off-by: Jukka Rissanen <[email protected]>
Add a test that will test the counter value set functionality.

Signed-off-by: Jukka Rissanen <[email protected]>
Save same memory and store metrics into a linked list inside
a collector entry.

Signed-off-by: Jukka Rissanen <[email protected]>
Instead of allocating space for description and label name + value,
have a const pointer for it. The data is set typically statically
when the metric is defined, so there should be no need to allocate
separate buffer for those strings.

Signed-off-by: Jukka Rissanen <[email protected]>
Embed "struct prometheus_metric" to individual metric like
counter, gauge, histogram and summary. This way we avoid having
a separate base pointer in specific metrict struct. We also do
not need to search the specific metric from base metric as
we can simply use CONTAINER_OF() macro to get the base metric.

This embedding means that the counter, gauge, histogram and summary
metric define macros are changed as user does not need to create a
separate "struct prometheus_metric".

Convert the tests and sample to use the new macros.

Remove also the static from metric creation macros so that user
can decide whether it needs collector to be static or not.

Signed-off-by: Jukka Rissanen <[email protected]>
Prometheus macros have changed in order to lower memory
consumption.

Signed-off-by: Jukka Rissanen <[email protected]>
Allow user to configure the label count from Kconfig.

Signed-off-by: Jukka Rissanen <[email protected]>
When creating prometheus network statistics variables, we need
to map the variables back to the collector, so add a backpointer
to it.

Signed-off-by: Jukka Rissanen <[email protected]>
Add collector parameter to metric creation macros so that it
is possible to bind the metric to collector already at built
time.

Also add optional user_data to metric macro calls so that user
can add optional data there. This will be used by network statistics
Prometheus support in subsequent commits.

Signed-off-by: Jukka Rissanen <[email protected]>
Remove the "static" from HTTP service definition macro so that
user is able to add it or leave it out if needed.

Signed-off-by: Jukka Rissanen <[email protected]>
Allow user to update prometheus metrics from network statistics.

Signed-off-by: Jukka Rissanen <[email protected]>
Instead of requiring one big buffer for formatting the output,
have a walk function that can be used to generate output by
one metric at a time.

Signed-off-by: Jukka Rissanen <[email protected]>
Add separate URL handling for network statistics.

Signed-off-by: Jukka Rissanen <[email protected]>
@jukkar jukkar force-pushed the devel/net-stats-to-prometheus branch from d23a476 to 20309cd Compare November 21, 2024 16:33
@jukkar
Copy link
Member Author

jukkar commented Nov 21, 2024

  • Added a walker to go through the metrics one by one so that HTTP output can be generated without one big massive buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant