Skip to main content

Pandas integration for Prometheus

Project description

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for prometheus-pandas, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size prometheus_pandas-0.3.0-py3-none-any.whl (6.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size prometheus-pandas-0.3.0.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page