Python bindings for C++ library for reading Prometheus on-disk data
Project description
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
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pypdu-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
26aace696240555fa0d7493e850bbdfd7367f8f9da9944c323ce2567eb28ef56
|
|
MD5 |
a5570e6eacb55c8acf63fe3060f1e7bd
|
|
BLAKE2b-256 |
382fa0b2659f0c5b883bbf07f8c760547c11c14a76f89b592c85660bdfa3571b
|
File details
Details for the file pypdu-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 311.8 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
06f0b2f0de5fea4ed30b37d18c4c8ffd0f4205e9ccb80ee00fa0e5050145af27
|
|
MD5 |
eec103d3fac11396ae000f5cc60148ac
|
|
BLAKE2b-256 |
2e2f12082fe493a909d2d5853dff84fe202460a49d59647795a0cc99fd1396dd
|
File details
Details for the file pypdu-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a02d47413203ac93fba038aaf928f133dcc9ce7e6b869d2193949296e0d1be47
|
|
MD5 |
d782df77af2fec1e0178c889da55e2a8
|
|
BLAKE2b-256 |
d3e017aa88c5feae4f2fb340c79e9591e336a0a52031855704538285312efeac
|
File details
Details for the file pypdu-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 311.9 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
64b1797fff7b857f8cc672dd3dec9b62f9646eb00f19d467937499a82585b142
|
|
MD5 |
2bc06dd1dcb59ada63b0a9e4515b5b05
|
|
BLAKE2b-256 |
60cedf8f3b65315facf4f302c5600e4286bfa4bd6faf3e07b423acb6110dd8db
|
File details
Details for the file pypdu-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.7 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
407b12c65587cd57bbd1afc511b60f82bd7cae092086f31e26f9e3fcc65626a1
|
|
MD5 |
40000f8627ac7637f41873e5da08145c
|
|
BLAKE2b-256 |
358646dc9b73879e2bc48a5f08a24a678e593c491e03bbbf0b5c01f0e01dcbc9
|
File details
Details for the file pypdu-0.0.7-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 311.8 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
84cbf3864c815a5ac7d52c5be9b2828b67081cd058301cf4c4cde47bdc0a7ea6
|
|
MD5 |
2fec4e17aa3f4e0857158a61f960af1e
|
|
BLAKE2b-256 |
a4518be8a006435ae92685cafaad5d37fcd09f12f09eecd2a6328f34214823c0
|
File details
Details for the file pypdu-0.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 441.7 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7b26bedb3086745d7dbd1433b3e36e769d499331ce8a865728a52db9d7dcb493
|
|
MD5 |
a254ca3370a30987478140d29df95fa5
|
|
BLAKE2b-256 |
cf8a1e40c654955d9570dfe9f153fe98049888bf9838d7f7269390ab41a4ce3a
|
File details
Details for the file pypdu-0.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 310.5 kB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ddeffbc3b584e4da7fa410351d528dc4bb6c75a8c2a2f4bd0bb005a98d9dc864
|
|
MD5 |
1e436648d69d0b3ddcdf78357450e0ee
|
|
BLAKE2b-256 |
5a79b30032a0f0337e04cb0b8e179ac29919f1d8cd982f36aacb6c8e8214e85d
|
File details
Details for the file pypdu-0.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 441.6 kB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
69150ede3641002ccbf07fe6f3278ba3330946d810a0e471bfd709ea47c695b7
|
|
MD5 |
4311e0b3c8d50b7cb1bdb09153f72360
|
|
BLAKE2b-256 |
318f532b8d887fe90efa42f405a90073e9ee61081f8df0a3ce643e93c43dcbdd
|
File details
Details for the file pypdu-0.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 310.5 kB
- Tags: CPython 3.6m, macOS 10.9+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b120cad98933a898bc1469cc17b49f342386f3b8adb10af5e00fd1c079691d7d
|
|
MD5 |
5e5849b36517aceef0bffecac1d5d028
|
|
BLAKE2b-256 |
ea47e00679af8c18321c795df94761cd8a07614c93540f67340bb81371156560
|
File details
Details for the file pypdu-0.0.7-cp27-cp27mu-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp27-cp27mu-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 442.5 kB
- Tags: CPython 2.7mu, manylinux: glibc 2.17+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7ec13f4a44458f9da50015ae4d2ff592691d5206550c8c0d68359ae115ead867
|
|
MD5 |
396bff72274cd696a961f75fa2b0ff45
|
|
BLAKE2b-256 |
232c1779359168e989d34f5edba56e01d47a18fc4a4b32b7a6e019ab436e1842
|
File details
Details for the file pypdu-0.0.7-cp27-cp27m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: pypdu-0.0.7-cp27-cp27m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 311.0 kB
- Tags: CPython 2.7m, macOS 10.15+ x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
f669ac2d0d098cfe7550c01d2a5e5b194680ce39e4590b598a7db767bc1fbbe2
|
|
MD5 |
9fefd93f039f39e9030910688f17f38b
|
|
BLAKE2b-256 |
8db6d93f0bdad572ff687c18c494aaac5616605f9006ee8fec3dcc33dfb01e0c
|