Skip to main content

Prometheus extension for the Chaos Toolkit

Version License Build Python versions

Prometheus support for the Chaos Toolkit.

Install

To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.

$ pip install chaostoolkit-prometheus

Usage

To use this package, you must create have access to a Prometheus instance via HTTP and be allowed to connect to it.

By default, the Prometheus instance at http://localhost:9090 will be queried. To override, you need to set up the instance details using the prometheus_base_url configuration property:

"configuration": {
  "prometheus_base_url": "http://my.prometheus.server/"
}

This package only exports probes to query for some aspects of your system as monitored by Prometheus.

Here is an example of querying Prometheus at a given moment

{
    "type": "probe",
    "name": "fetch-cpu-just-2mn-ago",
    "provider": {
        "type": "python",
        "module": "chaosprometheus.probes",
        "func": "query",
        "arguments": {
            "query": "process_cpu_seconds_total{job='websvc'}",
            "when": "2 minutes ago"
        }
    }
}

You can also ask for an interval as follows:

{
    "type": "probe",
    "name": "fetch-cpu-over-interval",
    "provider": {
        "type": "python",
        "module": "chaosprometheus.probes",
        "func": "query_interval",
        "arguments": {
            "query": "process_cpu_seconds_total{job='websvc'}",
            "start": "2 minutes ago",
            "end": "now",
            "step": 5
        }
    }
}

In both cases, the probe returns the JSON payload as-is from Prometheus or raises an exception when an error is met.

The result is not further process and should be found in the generated report of the experiment run.

You can also send metrics to a pushgateway service via a control:

{
    "controls": [
        {
            "name": "prometheus",
            "provider": {
                "type": "python",
                "module": "chaosprometheus.metrics",
                "arguments": {
                    "pushgateway_url": "http://someip:9091",
                    "job": "chaostoolkit"
                }
            }
        }
    ]
}

You can also set three more arguments:

  • grouping_key: A mapping of strings to uniquely aggregate multiple runs in the Prometheus backend
  • trace_id: This must be a string which will identify this run uniquely in your metrics. If none is a provided, a random string is generated.
  • experiment_ref: Sometimes it's useful to identify a particular experiment, not just its run, throughout many runs. This is the string to do that. If none is provided, a hash of the experiment is performed and used. The hash is not stable across changes of the experiment of course.

These are particularly useful when you couple this extension with others like Loki where you want to cross-reference between logs and metrics.

Contribute

If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.

Metadata

Release files for chaostoolkit-prometheus 0.6.0

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

Source distribution (sdist)

Source distribution for chaostoolkit-prometheus 0.6.0
File Size Uploaded
chaostoolkit-prometheus-0.6.0.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chaostoolkit-prometheus 0.6.0
File Interpreter ABI Platform
chaostoolkit_prometheus-0.6.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 24.4 kB

Release files / chaostoolkit-prometheus-0.6.0.tar.gz

Download URL chaostoolkit-prometheus-0.6.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4fa346453c325f3d0d8981f93473f8b2348db994a099f85b6f983794971506b2
BLAKE2b-256 checksum
How to use checksums
0728c899fd2913b288562e0c7a5f4636c15778f77cb0b5b2c4c6b78592121eb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release files / chaostoolkit_prometheus-0.6.0-py2.py3-none-any.whl

Download URL chaostoolkit_prometheus-0.6.0-py2.py3-none-any.whl
Size 11.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
897d2eb72af359ae93fbff559a44b2f79ffac2ba3eb0ebe72dbc235146019d1c
BLAKE2b-256 checksum
How to use checksums
76fc998fa521bf25d412fab79e5d913c60945daa00a2068584ec3662b260c9e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

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