Skip to content

Histograms with bucket labels starting with '-' are missing _sum metric in 0.8.0? #552

Closed

Description

@tobiasbp

I have encountered an issue with my metrics after having upgraded from version 0.7.1 to 0.8.0.

In the example below, the resulting histogram does not have the sum metric (suffix _sum) when using 0.8.0. If I use version 0.7.1, the _sum metric is back.

label_values = ['1', 'DKK']
bucket_values = [['-50000', 40], ['+Inf', 40]]
buckets_sum = 3000.0

h = HistogramMetricFamily(name, desc, labels=label_names)
h.add_metric(label_values, bucket_values, buckets_sum)

yield h

If I change the value of the 1st bucket, so it no longer has the minus/dash prefix (As seen below), the _sum metric is no longer missing in when using version 0.8.0.

bucket_values = [['50000', 40], ['+Inf', 40]]

Is this behaviour a feature (Which I do not understand) or a regression?

Thanks,
Tobias

Activity

  1. brian-brazil commented on May 28, 2020

    @brian-brazil
    Contributor

    This is correct, negative observations means that sum would no longer be a counter and it is thus excluded as per OpenMetrics.

  2. tobiasbp commented on May 28, 2020

    @tobiasbp
    Author

    Counter = never decreasing (AFAIK). Makes sense. Thanks for all your work on Prometheus.

  3. belm0 commented on Feb 26, 2021

    @belm0

    @brian-brazil then it's an OpenMetrics flaw that histogram "_sum" is of type counter. It should be a gauge, and therefore support histograms with negative observations.

    How do you propose we derive the average from a histogram metric? It should be simply _sum / _count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions