Skip to main content

aioprometheus-summary

Aioprometheus summary with quantiles over configurable sliding time window

Installation

pip install aioprometheus-summary==0.1.0

This package can be found on PyPI.

Collecting

Basic usage

from aioprometheus_summary import Summary

s = Summary("request_latency_seconds", "Description of summary")
s.observe({}, 4.7)

With labels

from aioprometheus_summary import Summary

s = Summary("request_latency_seconds", "Description of summary")
s.observe({"method": "GET", "endpoint": "/profile"}, 1.2)
s.observe({"method": "POST", "endpoint": "/login"}, 3.4)

With custom quantiles and precisions

By default, metrics are observed for next quantile-precision pairs ((0.50, 0.05), (0.90, 0.01), (0.99, 0.001)) but you can provide your own value when creating the metric.

from aioprometheus_summary import Summary

s = Summary(
    "request_latency_seconds", "Description of summary",
    invariants=((0.50, 0.05), (0.75, 0.02), (0.90, 0.01), (0.95, 0.005), (0.99, 0.001)),
)
s.observe({}, 4.7)

With custom time window settings

Typically, you don't want to have a Summary representing the entire runtime of the application, but you want to look at a reasonable time interval. Summary metrics implement a configurable sliding time window.

The default is a time window of 10 minutes and 5 age buckets, i.e. the time window is 10 minutes wide, and we slide it forward every 2 minutes, but you can configure this values for your own purposes.

from aioprometheus_summary import Summary

s = Summary(
    "request_latency_seconds", "Description of summary",
    # time window 5 minutes wide with 10 age buckets (sliding every 30 seconds)
    max_age_seconds=5 * 60,
    age_buckets=10,
)
s.observe({}, 4.7)

Querying

Suppose we have a metric:

from aioprometheus_summary import Summary

s = Summary("request_latency_seconds", "Description of summary")

To show request latency by method, endpoint and quntile use next query:

max by (method, endpoint, quantile) (request_latency_seconds)

To only 99-th quantile:

max by (method, endpoint) (request_latency_seconds{quantile="0.99")

Release files for aioprometheus-summary 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aioprometheus-summary 0.1.0
File Size Uploaded
aioprometheus-summary-0.1.0.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aioprometheus-summary 0.1.0
File Interpreter ABI Platform
aioprometheus_summary-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / aioprometheus-summary-0.1.0.tar.gz

Download URL aioprometheus-summary-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
575cf926ba01dd3e20608edb0ed38cbf5ea0f471639ae6fa43002e8b527e762a
BLAKE2b-256 checksum
How to use checksums
57da1f1ca9808ee65efe65a4d8d2f20f5b58fcdfaf1910a6e4d2e4fc517fe533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / aioprometheus_summary-0.1.0-py3-none-any.whl

Download URL aioprometheus_summary-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d85478817f27c020d238436713b5607bedaf8fe843611184dd33b158ceb25c68
BLAKE2b-256 checksum
How to use checksums
396bd1e032aeddeb5b395fa4ae102712cae3066a0542656839f9ba00f4b9083e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page