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

Fix the appending of unit suffix for histogram metrics in Prometheus exporter. #553

Open
tobz opened this issue Jan 31, 2025 · 0 comments
Open
Labels
C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug.

Comments

@tobz
Copy link
Member

tobz commented Jan 31, 2025

In #535, support was added to metrics-exporter-prometheus for suffixing metrics based on their configured unit. This was applied uniformly to counters, gauges, and histograms, and relied on a change to one of the core functions used to write out a metric line in the exposition format.

#552 was raised to highlight a bug with how that change was gated, which made me realize that we're likely suffixing histograms wrong when the feature is enabled. For counters and gauges, the suffixing we do is fine: my_counter turns into something like my_counter_seconds, and so on. For histograms, however, lines like my_histogram_sum turn into my_histogram_sum_seconds.

As I understand it, at least, this is wrong, since the intent is that Prometheus would expect the base metric name to be turned into <base>_bucket, <base>_sum, and <base>_count... whereas we would be doing something like <base>_bucket_seconds, <base>_sum_seconds, and <base>_count_seconds. While the suffixing is uniform, Prometheus wants (again, as I understand it) a histogram metric to have the _bucket/_sum/_count suffixes so that it knows how to transforms queries against <base> into the right parts when doing histogram-y things.

Looking at the code, this should be as simple as reordering how the unit suffix and the generic suffix (the parameter we use to add _bucket/_sum/_count in the first place) are applied.

@tobz tobz added C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug. labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug.
Projects
None yet
Development

No branches or pull requests

1 participant