I recommend you to forgo Prometheus server for now and just look at the data that is returned when you query localhost:8000 after every call to the observe() method. This way you will better understand how and why a histogram metric consists out of multiple time series.

Answer from trallnag on Stack Overflow
🌐
client_python
prometheus.github.io › client_python › instrumenting › histogram
Histogram | client_python
April 24, 2026 - Use it when you want to track distributions — request latency, response sizes — and need to calculate quantiles (p50, p95, p99) in your queries. from prometheus_client import Histogram h = Histogram('request_latency_seconds', 'Description of histogram') h.observe(4.7) # Observe 4.7 (seconds ...
🌐
ProgramCreek
programcreek.com › python › example › 105485 › prometheus_client.Histogram
Python Examples of prometheus_client.Histogram
hist = getattr(registry, '_openstacksdk_histogram', None) if not hist: hist = prometheus_client.Histogram( 'openstack_http_response_time', 'Time taken for an http response to an OpenStack service', labelnames=[ 'method', 'endpoint', 'service_type', 'status_code' ], registry=registry, ) registry._openstacksdk_histogram = hist return hist
🌐
GitHub
github.com › prometheus › client_python › blob › master › docs › content › instrumenting › histogram.md
client_python/docs/content/instrumenting/histogram.md at master · prometheus/client_python
Use it when you want to track ... (p50, p95, p99) in your queries. from prometheus_client import Histogram h = Histogram('request_latency_seconds', 'Description of histogram') h.observe(4.7) # Observe 4.7 (seconds in ...
Author: prometheus
🌐
GitHub
github.com › prometheus › client_python › blob › master › prometheus_client › metrics.py
client_python/prometheus_client/metrics.py at master · prometheus/client_python
Example for a Histogram: · from prometheus_client import Histogram · · h = Histogram('request_size_bytes', 'Request size (bytes)') h.observe(512) # Observe 512 (bytes) · Example for a Histogram using time: ...
Author: prometheus
🌐
Prometheus
prometheus.io › docs › concepts › metric_types
Metric types | Prometheus
In contrast to the usual counter-like histograms, gauge histograms are rarely directly exposed by instrumented programs and are thus not (yet) usable in instrumentation libraries, but they are represented in newer versions of the protobuf exposition format and in OpenMetrics . They are also created regularly by PromQL expressions. For example, the outcome of applying the rate function to a counter histogram is a gauge histogram, in the same way as the outcome of applying the rate function to a counter is a gauge.
🌐
Medium
leapcell.medium.com › understanding-prometheus-and-monitoring-python-applications-37abf0712e2f
Understanding Prometheus and Monitoring Python Applications | by Leapcell | Medium
May 28, 2025 - ... from prometheus_client import ... specified buckets request_duration_histogram = Histogram( 'http_request_duration_seconds', 'HTTP request duration in seconds', buckets=(0.1, 0.2, 0.3, 0.4, 0.5) ) # Simulate 20 request durations ...
🌐
client_python
prometheus.github.io › client_python › instrumenting › exemplars
Exemplars | client_python
November 15, 2023 - from prometheus_client import Histogram h = Histogram('request_latency_seconds', 'Description of histogram') h.observe(4.7, {'trace_id': 'abc123'}) Exemplars are only rendered in the OpenMetrics exposition format. If using the HTTP server or apps in this library, content negotiation can be ...
🌐
Prometheus
prometheus.io › docs › practices › histograms
Histograms and summaries | Prometheus
For a native histogram (including an NHCB), you extract the sum and count of observations with the functions histogram_sum and histogram_count, respectively. For example, to calculate the average request duration over the last 5m from a native histogram called http_request_duration_seconds, use the following PromQL expression:
Find elsewhere
🌐
OneUptime
oneuptime.com › blog › post › 2026-01-26-prometheus-histograms-summaries › view
How to Use Histograms and Summaries in Prometheus
January 26, 2026 - Python example: from prometheus_client import Histogram, start_http_server import time import random # Define histogram with custom buckets request_latency = Histogram( 'http_request_duration_seconds', 'HTTP request latency in seconds', ['method', ...
🌐
PyPI
pypi.org › project › pyprometheus
Client Challenge
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Form3
form3.tech › blog › engineering › prometheus-histograms
Prometheus Histograms. Run that past me again?
Each time the histogram is scraped by Prometheus, the values are not reset. This means that the counts in each bucket are cumulative over the lifetime of the metric (at least in the memory of each process) and that it’s really the change in each bucket’s values the tells us the distribution of observations since the last scrape. Let’s put all of these ideas into practice. The examples below can all be found here along with a Docker Compose file for running a sample application and Prometheus.
🌐
DEV Community
dev.to › leapcell › understanding-prometheus-and-monitoring-python-applications-3d0p
Understanding Prometheus and Monitoring Python Applications - DEV Community
May 28, 2025 - ... from prometheus_client import ... specified buckets request_duration_histogram = Histogram( 'http_request_duration_seconds', 'HTTP request duration in seconds', buckets=(0.1, 0.2, 0.3, 0.4, 0.5) ) # Simulate 20 request durations ...
🌐
PyPI
pypi.org › project › prometheus-client › 0.14.0
Prometheus Python Client
from prometheus_client import Summary s = Summary('request_latency_seconds', 'Description of summary') s.observe(4.7) # Observe 4.7 (seconds in this case) ... The Python client doesn't store or expose quantile information at this time.
      » pip install prometheus-client
    
Published: Apr 05, 2022
Version: 0.14.0
🌐
Tom Gregory
tomgregory.com › the-four-types-of-prometheus-metrics
The 4 Types Of Prometheus Metrics | Tom Gregory
December 2, 2019 - For example, you could measure request duration for a specific HTTP request call using histograms. Rather than storing every duration for every request, Prometheus will make an approximation by storing the frequency of requests that fall into ...
🌐
Reddit
reddit.com › r/prometheusmonitoring › prometheus histogram with python
r/PrometheusMonitoring on Reddit: Prometheus histogram with python
May 17, 2022 - I am looking for a python code for histogram. To calculate response time and http request.
🌐
PyPI
pypi.org › project › prometheus-client › 0.14.1
prometheus-client · PyPI
from prometheus_client import Summary s = Summary('request_latency_seconds', 'Description of summary') s.observe(4.7) # Observe 4.7 (seconds in this case) ... The Python client doesn't store or expose quantile information at this time.
🌐
Prometheus
prometheus.io › docs › instrumenting › writing_clientlibs
Writing client libraries | Prometheus
A histogram SHOULD have the same default buckets as other client libraries. Buckets MUST NOT be changeable once the metric is created. ... Some way to time code for users in seconds. In Python this is the time() decorator/context manager. In Java this is startTimer/observeDuration.
🌐
Linux Hint
linuxhint.com › monitor-python-applications-prometheus
Monitoring Python Applications using Prometheus – Linux Hint
To experiment with Histogram, create ... from prometheus_client import Histogram LATENCY = Histogram('server_latency_seconds', 'Time to serve a web page', buckets=[ 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20]) class ServerHandler(http.server.BaseHTTPRequestHandler): ...