'Prometheus histogram get number of requests per bucket

We have a histogram bucket (myapp_duration_seconds_bucket) with different le values that captures the response time of an api. From this I would like to find the count of requests per bucket using Prometheus query.

For example below is Prometheus output for bucket myapp_duration_seconds_bucket by le. The histogram buckets are cumulative, but I would like to get the count per bucket to find the exact number of transactions that fall into each bucket.

  • le="+Inf" 8229
  • le="0.005" 0
  • le="0.01" 0
  • le="0.025" 0
  • le="0.05" 5149
  • le="0.075" 7101
  • le="0.1" 7466
  • le="0.25" 7942
  • le="0.5" 8070
  • le="0.75" 8120
  • le="1.0" 8156
  • le="10.0" 8229
  • le="2.5" 8223
  • le="5.0" 8229
  • le="7.5" 8229
  • le="0.1" 7466
  • le="0.25" 7942
  • le="0.5" 8070
  • le="0.75" 8120
  • le="1.0" 8156
  • le="10.0" 8229
  • le="2.5" 8223
  • le="5.0" 8229
  • le="7.5" 8229

Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source