Skip to main content

Prometheus Pandas

Python library for querying Prometheus and accessing the results as Pandas data structures.

This is mostly intended for use in Jupyter notebooks. See Prometheus.ipynb for an example.

Example

Evaluate an instant query at a single point in time:

>>> from prometheus_pandas import query
>>>
>>> p = query.Prometheus('http://localhost:9090')
>>> p.query('node_cpu_seconds_total{mode="system"}', '2020-05-10T00:00:00Z')
node_cpu_seconds_total{cpu="0",instance="localhost:9100",job="node",mode="system"}    15706.47
node_cpu_seconds_total{cpu="1",instance="localhost:9100",job="node",mode="system"}    15133.25
node_cpu_seconds_total{cpu="2",instance="localhost:9100",job="node",mode="system"}    15095.59
node_cpu_seconds_total{cpu="3",instance="localhost:9100",job="node",mode="system"}    14649.20
dtype: float64

Evaluates an expression query over a time range:

>>> from prometheus_pandas import query
>>>
>>> p = query.Prometheus('http://localhost:9090')
>>> print(p.query_range(
        'sum(rate(node_cpu_seconds_total{mode=~"system|user"}[1m])) by (mode)',
        '2020-10-05T00:00:00Z', '2020-10-05T06:00:00Z', '1h'))
dtype: float64
---
                     {mode="system"}  {mode="user"}
2020-10-05 00:00:00         0.022667       0.038222
2020-10-05 01:00:00         0.015333       0.036667
2020-10-05 02:00:00         0.028000       0.040667
2020-10-05 03:00:00         0.015111       0.034889
2020-10-05 04:00:00         0.015556       0.038000
2020-10-05 05:00:00         0.018444       0.040222
2020-10-05 06:00:00         0.018222       0.035111

Customizing the HTTP request:

>>> import requests
>>> from prometheus_pandas import query
>>>
>>> http = requests.Session()
>>> http.cert = '/path/client.cert'
>>> http.verify = '/path/to/certfile'
>>>
>>> p = query.Prometheus('http://localhost:9090', http)
>>> print(p.query('node_cpu_seconds_total{mode="system"}', '2020-10-05T00:00:00Z'))
node_cpu_seconds_total{cpu="0",instance="localhost:9100",job="node",mode="system"}    3954.92
dtype: float64

Installation

Latest release via pip:

pip install prometheus-pandas [--user]

via Git:

git clone https://github.com/dcoles/prometheus-pandas.git; cd prometheus-pandas
python3 setup.py install [--user]

Licence

Licenced under the MIT License. See LICENSE for details.

Metadata

Release files for prometheus-pandas 0.3.3

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

Source distribution (sdist)

Source distribution for prometheus-pandas 0.3.3
File Size Uploaded
prometheus-pandas-0.3.3.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prometheus-pandas 0.3.3
File Interpreter ABI Platform
prometheus_pandas-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / prometheus-pandas-0.3.3.tar.gz

Download URL prometheus-pandas-0.3.3.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d5e69398dba2ddc022b0a12104c1293aff949dd259c1be0618ad8cefac62cbb9
BLAKE2b-256 checksum
How to use checksums
0e32cc52d78fcda4fad3149bce4f3f215834b31aa394db35bf0cb40404b7237f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / prometheus_pandas-0.3.3-py3-none-any.whl

Download URL prometheus_pandas-0.3.3-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58ec3d33f8896f0fbbb6b75a8646610aca5e3d6dfca63db062c1c5890b74e8e7
BLAKE2b-256 checksum
How to use checksums
2acd7b6d6c44e5942d6bcdfce3dc02628f50de12c5194504a2af612913b47149
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

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