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

Prometheus_client custom collector class #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Qwiko
Copy link
Contributor

@Qwiko Qwiko commented Jan 10, 2025

This is my first draft to issue: #55

Rebuilt the entire metric creation and focuses on fetching the appropriate statistic that is associated with the metric instead of the other way round. The current code (v0.7.0) loops over all statistics and tries to find a metric it can change value for.

Changes

  • Rebuilt code to work with a custom collector
    • Only returning labels with data so that help texts with not data are not visible.
      Not sure if this is something that is needed or not. Cannot find anything online regarding a best practise. Would like to have input on it.
  • Added logging with support for debug mode using -d or --debug
    Solves: Add debug-logging #48
  • Removed interval setting
  • Changed how subnets are stored in uds and http classes
  • Added more base labels to all metrics, target and server_tag info
    Solves: Include target name as label #56
    Also solves a bug where statistics from multiple targets could overwrite each other. Having unique labels solves this.
    See comment: Kea HTTP ctrl-agent support #33 (comment)

Example of new labels

Old
# HELP kea_dhcp4_packets_sent_total Packets sent
# TYPE kea_dhcp4_packets_sent_total gauge
kea_dhcp4_packets_sent_total{operation="ack"} 2.0
kea_dhcp4_packets_sent_total{operation="nak"} 0.0
kea_dhcp4_packets_sent_total{operation="offer"} 0.0

New
# HELP kea_dhcp4_packets_sent_total Packets sent
# TYPE kea_dhcp4_packets_sent_total gauge
kea_dhcp4_packets_sent_total{operation="ack",server_tag="kea-server",target="http://localhost:8001"} 2.0
kea_dhcp4_packets_sent_total{operation="nak",server_tag="kea-server",target="http://localhost:8001"} 0.0
kea_dhcp4_packets_sent_total{operation="offer",server_tag="kea-server",target="http://localhost:8001"} 0.0

Things yet to do

  • Add more logging
  • Add initial tests using pytest and mocking (In progress)
  • Investigate into logging which statistics are not processed.
    Removed in the initial draft
  • End to end tests with using both http and socket mode
  • Refactor and make the code nicer
  • Investigate if code works with other metric types like Counter

This is a quite large change and I expect to be working on this for a while before we are happy with all changes.

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.

1 participant