Skip to content

native histograms: histogram_count and histogram_sum wrong result #16681

@krajorama

Description

@krajorama

What did you do?

Originally reported on Mimir 2.16 in grafana/mimir#11148

Under some circumstances histogram_count and histogram_sum produce a result different from what count and sum the underlying native histogram has.

I've managed to reproduce the issue eventually by using the same (or very similar) input histograms that we see at the user.

See PR

What did you expect to see?

The native histogram count should be the same between

sum(rate(series_1[10m]))

and

histogram_count(sum(rate(series_1[10m])))

What did you see instead? Under which circumstances?

Instead:

-- FAIL: TestInconsistentHistogramCount (0.01s)
    /home/krajo/go/github.com/prometheus/prometheus/promql/engine_test.go:4293: 
        	Error Trace:	/home/krajo/go/github.com/prometheus/prometheus/promql/engine_test.go:4293
        	Error:      	Not equal: 
        	            	expected: 0.0068000000000000005
        	            	actual  : 0
        	Test:       	TestInconsistentHistogramCount
        	Messages:   	histogram_count function should return the same count as the histogram itself

System information

unit test

Prometheus version

main 8fd46f74aa0155e4d5aa30654f9c02e564e03743

Prometheus configuration file

N/A

Alertmanager version

N/A

Alertmanager configuration file

N/A

Logs

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions