PyPromql - Python PromQL Query Builder
Abstract
What is PyPromql?
PyPromql is a Python library that simplifies the creation and execution of PromQL queries. With PyPromql, developers can effortlessly construct and run PromQL queries with ease and simplicity. It provides a convenient and intuitive interface for working with Prometheus Query Language (PromQL).
Read the docs: http://pypromql.readthedocs.io/en/latest/
Installation
To install PyPromql run the following command:
pip install pypromql
Tutorial
The main classes in pypromql are pypromql.query.Query and pypromql.result.PrometheusResult.
from pypromql.query import Query
from pypromql.result import PrometheusResult
Create simple query
The entry point for building queries is pypromql.query.Query.
promql_query = Query.metric('up').label('job', 'prometheus')
up{job="prometheus"}
To convert the query into raw PromQL, it can be cast to a string.
str(promql_query)
Alternatively, you can use the to_promql() function:
promql_query.to_promql()
Execute query
First, we need to create a pypromql.PrometheusConnection.
connection = PrometheusConnection(prometheus_base_url='http://my-host-name:my-port/')
Then, we execute our query and get the result using PrometheusResult.from_query_builder.
result = PrometheusResult.from_query_builder(promql_query, connection)
Metadata
Release files for PyPromql 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyPromql-0.0.3.tar.gz | 7.0 kB | Without provenance | Details for PyPromql-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyPromql-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for PyPromql-0.0.3-py3-none-any.whl |
Total release size: 16.4 kB
Release files / PyPromql-0.0.3.tar.gz
| Download URL | PyPromql-0.0.3.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da814b6f704c994f15cd331fc7588195497b2adbc32ee072239c7dc73af8d108
|
|
BLAKE2b-256 checksum How to use checksums |
f8208d26868ec88ee50de37e8a71196a047a391172e59b736a52ede60aca9ac6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Release files / PyPromql-0.0.3-py3-none-any.whl
| Download URL | PyPromql-0.0.3-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dad162b6e67c0b95cf54b34d8af8061fac1b244a1ebc6adc0f02927250ed11e
|
|
BLAKE2b-256 checksum How to use checksums |
76775d8716c4641af116b32567c5d2d57869ac4a1e3435c3369263a5ee6a4549
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.5
|
Security for PyPromql 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.