Skip to main content

pypdu

This module provides basic read-only access to the data contained in Prometheus on-disk files from Python.

pypdu may be installed from pip (on linux and macOS):

pip install pypdu

Example usage:

#!/usr/bin/env python3

import pypdu

data = pypdu.load("/path/to/stats_data")

for series in data:
    print(series.name) # equivalent to series.labels["__name__"]
    print(series.labels)
    print(len(series.samples)) # number of samples can be computed
                               # without iterating all of them
    for sample in series.samples:
        print(f"{sample.timestamp} : {sample.value}")

Or the series and samples can be unpacked:

for name, labels, samples in data:
    print(name)
    print(labels)
    print(len(samples))
    for timestamp, value in samples:
        print(f"{timestamp} : {value}")

Filtering time series

If only a subset of the time series are desired, pypdu can filter them based on label values, and avoid parsing unneeded series at all:

for series in data.filter({"__name__":"sysproc_page_faults_raw"}):

This will usually perform better than filtering "manually" in python after the fact.

Multiple labels can be specified:

data.filter({"__name__":"sysproc_page_faults_raw", "proc":"memcached"})

ECMAScript regexes can also be used:

data.filter({"proc":pypdu.regex("^go.*")})

Or even arbitrary Python callbacks:

data.filter({"proc":lambda x: x.startswith("go")})

As shorthand, when filtering on __name__ alone, just a string may be provided.

data.filter("sysproc_page_faults_raw")

Single series lookup

If there is only one time series matching your filter, for convenience you can do:

foobar_series = data[{"__name__":"foobar"}]

This is roughly equivalent to:

foobar_series = next(iter(data.filter({"__name__":"foobar"})))

If there are multiple time series matching your filter, this will silently discard all but the lexicographically first (sorted by the key and value of all labels).

If none match, a KeyError is raised.

All types of filter demonstrated above with .filter(...) may be used in this manner also.

Alternative installation steps

setup.py

pypdu may be installed without pip. To use, clone the repository as in the installation instructions.

Then run:

python setup.py install

This should also work on Windows, but is untested.

manual .so

Alternatively, following the cmake steps in the installation instructions to build the project produces a module with a platform-dependent name - for example on MacOS this may be pypdu.cpython-39-darwin.so.

This can be found either in <build dir>/src/pypdu or in your chosen installation prefix. This can be used without installing with setup.py, simply ensure the containing directory is in your PYTHONPATH.

Metadata

Release files for pypdu 0.0.7

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

Built distributions (wheels)

Table of built distributions (wheels) for pypdu 0.0.7
File
pypdu-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
pypdu-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
pypdu-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
pypdu-0.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
pypdu-0.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details
pypdu-0.0.7-cp27-cp27mu-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.17+ x86-64 Details
pypdu-0.0.7-cp27-cp27m-macosx_10_15_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.15+ x86-64 Details

Total release size: 4.5 MB

Release files / pypdu-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 437.8 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
26aace696240555fa0d7493e850bbdfd7367f8f9da9944c323ce2567eb28ef56
BLAKE2b-256 checksum
How to use checksums
382fa0b2659f0c5b883bbf07f8c760547c11c14a76f89b592c85660bdfa3571b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl

Download URL pypdu-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl
Size 311.8 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
06f0b2f0de5fea4ed30b37d18c4c8ffd0f4205e9ccb80ee00fa0e5050145af27
BLAKE2b-256 checksum
How to use checksums
2e2f12082fe493a909d2d5853dff84fe202460a49d59647795a0cc99fd1396dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 437.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a02d47413203ac93fba038aaf928f133dcc9ce7e6b869d2193949296e0d1be47
BLAKE2b-256 checksum
How to use checksums
d3e017aa88c5feae4f2fb340c79e9591e336a0a52031855704538285312efeac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl

Download URL pypdu-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl
Size 311.9 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
64b1797fff7b857f8cc672dd3dec9b62f9646eb00f19d467937499a82585b142
BLAKE2b-256 checksum
How to use checksums
60cedf8f3b65315facf4f302c5600e4286bfa4bd6faf3e07b423acb6110dd8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 437.7 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
407b12c65587cd57bbd1afc511b60f82bd7cae092086f31e26f9e3fcc65626a1
BLAKE2b-256 checksum
How to use checksums
358646dc9b73879e2bc48a5f08a24a678e593c491e03bbbf0b5c01f0e01dcbc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp38-cp38-macosx_10_9_x86_64.whl

Download URL pypdu-0.0.7-cp38-cp38-macosx_10_9_x86_64.whl
Size 311.8 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
84cbf3864c815a5ac7d52c5be9b2828b67081cd058301cf4c4cde47bdc0a7ea6
BLAKE2b-256 checksum
How to use checksums
a4518be8a006435ae92685cafaad5d37fcd09f12f09eecd2a6328f34214823c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 441.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7b26bedb3086745d7dbd1433b3e36e769d499331ce8a865728a52db9d7dcb493
BLAKE2b-256 checksum
How to use checksums
cf8a1e40c654955d9570dfe9f153fe98049888bf9838d7f7269390ab41a4ce3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL pypdu-0.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
Size 310.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
ddeffbc3b584e4da7fa410351d528dc4bb6c75a8c2a2f4bd0bb005a98d9dc864
BLAKE2b-256 checksum
How to use checksums
5a79b30032a0f0337e04cb0b8e179ac29919f1d8cd982f36aacb6c8e8214e85d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 441.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
69150ede3641002ccbf07fe6f3278ba3330946d810a0e471bfd709ea47c695b7
BLAKE2b-256 checksum
How to use checksums
318f532b8d887fe90efa42f405a90073e9ee61081f8df0a3ce643e93c43dcbdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL pypdu-0.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
Size 310.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
b120cad98933a898bc1469cc17b49f342386f3b8adb10af5e00fd1c079691d7d
BLAKE2b-256 checksum
How to use checksums
ea47e00679af8c18321c795df94761cd8a07614c93540f67340bb81371156560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp27-cp27mu-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypdu-0.0.7-cp27-cp27mu-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 442.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7ec13f4a44458f9da50015ae4d2ff592691d5206550c8c0d68359ae115ead867
BLAKE2b-256 checksum
How to use checksums
232c1779359168e989d34f5edba56e01d47a18fc4a4b32b7a6e019ab436e1842
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / pypdu-0.0.7-cp27-cp27m-macosx_10_15_x86_64.whl

Download URL pypdu-0.0.7-cp27-cp27m-macosx_10_15_x86_64.whl
Size 311.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
f669ac2d0d098cfe7550c01d2a5e5b194680ce39e4590b598a7db767bc1fbbe2
BLAKE2b-256 checksum
How to use checksums
8db6d93f0bdad572ff687c18c494aaac5616605f9006ee8fec3dcc33dfb01e0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release history Release notifications | RSS feed

0.1.9

21 release files

0.1.8

21 release files

0.1.7

29 release files

0.1.6

29 release files

0.1.4

18 release files

0.1.3

18 release files

0.1.2

18 release files

0.1.1

19 release files

0.1.0

19 release files

0.0.8

12 release files

This release

0.0.7 This release

12 release files

0.0.2

12 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