Pangolier

build PromQL by Python code.

install

pip install pangolier

simple usage

basic

For a metric with filters:

from pangolier.metrics import Metric

print(Metric('http_requests_total').filter(
    job='prometheus',
    group='canary'
).to_str())

output:

http_requests_total{job="prometheus", group="canary"}

pretty output

Add pretty=True in to_str for better readability:

from pangolier.metrics import Metric

print(Metric('http_requests_total').filter(
    job='prometheus',
    group='canary'
).to_str(pretty=True))

output:

http_requests_total{
    job="prometheus",
    group="canary"
}

I will always use pretty=True in rest of this document.

read more: