{"id":22048885,"url":"https://github.com/chaostoolkit-incubator/chaostoolkit-prometheus","last_synced_at":"2025-05-08T23:07:53.338Z","repository":{"id":26986924,"uuid":"107178552","full_name":"chaostoolkit-incubator/chaostoolkit-prometheus","owner":"chaostoolkit-incubator","description":"Prometheus Extension for the Chaos Toolkit","archived":false,"fork":false,"pushed_at":"2023-09-26T08:51:11.000Z","size":51,"stargazers_count":13,"open_issues_count":4,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T23:07:45.344Z","etag":null,"topics":["chaos-engineering","chaostoolkit-extension","prometheus"],"latest_commit_sha":null,"homepage":"https://chaostoolkit.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaostoolkit-incubator.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-16T20:19:44.000Z","updated_at":"2024-11-28T16:33:36.000Z","dependencies_parsed_at":"2024-06-18T21:35:41.433Z","dependency_job_id":"e9f215b5-abc1-4ed0-ab7f-51b515183a07","html_url":"https://github.com/chaostoolkit-incubator/chaostoolkit-prometheus","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaostoolkit-incubator","download_url":"https://codeload.github.com/chaostoolkit-incubator/chaostoolkit-prometheus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253160777,"owners_count":21863629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chaos-engineering","chaostoolkit-extension","prometheus"],"created_at":"2024-11-30T14:13:37.829Z","updated_at":"2025-05-08T23:07:53.308Z","avatar_url":"https://github.com/chaostoolkit-incubator.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prometheus extension for the Chaos Toolkit\n\n[![Version](https://img.shields.io/pypi/v/chaostoolkit-prometheus.svg)](https://img.shields.io/pypi/v/chaostoolkit-prometheus.svg)\n[![License](https://img.shields.io/pypi/l/chaostoolkit-prometheus.svg)](https://img.shields.io/pypi/l/chaostoolkit-prometheus.svg)\n[![Build](https://github.com/chaostoolkit-incubator/chaostoolkit-prometheus/actions/workflows/build.yaml/badge.svg)](https://github.com/chaostoolkit-incubator/chaostoolkit-prometheus/actions/workflows/build.yaml)\n[![Python versions](https://img.shields.io/pypi/pyversions/chaostoolkit-prometheus.svg)](https://www.python.org/)\n\n[Prometheus][prometheus] support for the [Chaos Toolkit][chaostoolkit].\n\n[prometheus]: https://prometheus.io/\n[chaostoolkit]: http://chaostoolkit.org/\n\n## Install\n\nTo be used from your experiment, this package must be installed in the Python\nenvironment where [chaostoolkit][] already lives.\n\n[chaostoolkit]: https://github.com/chaostoolkit/chaostoolkit\n\n```\n$ pip install chaostoolkit-prometheus\n```\n\n## Usage\n\nTo use this package, you must create have access to a Prometheus instance via\nHTTP and be allowed to connect to it.\n\nBy default, the Prometheus instance at `http://localhost:9090` will be queried.\nTo override, you need to set up the instance details using the `prometheus_base_url`\nconfiguration property:\n\n```json\n\"configuration\": {\n  \"prometheus_base_url\": \"http://my.prometheus.server/\"\n}\n```\n\nThis package only exports probes to query for some aspects of your system as\nmonitored by Prometheus.\n\nHere is an example of querying Prometheus at a given moment\n\n```json\n{\n    \"type\": \"probe\",\n    \"name\": \"fetch-cpu-just-2mn-ago\",\n    \"provider\": {\n        \"type\": \"python\",\n        \"module\": \"chaosprometheus.probes\",\n        \"func\": \"query\",\n        \"arguments\": {\n            \"query\": \"process_cpu_seconds_total{job='websvc'}\",\n            \"when\": \"2 minutes ago\"\n        }\n    }\n}\n```\n\nYou can also ask for an interval as follows:\n\n```json\n{\n    \"type\": \"probe\",\n    \"name\": \"fetch-cpu-over-interval\",\n    \"provider\": {\n        \"type\": \"python\",\n        \"module\": \"chaosprometheus.probes\",\n        \"func\": \"query_interval\",\n        \"arguments\": {\n            \"query\": \"process_cpu_seconds_total{job='websvc'}\",\n            \"start\": \"2 minutes ago\",\n            \"end\": \"now\",\n            \"step\": 5\n        }\n    }\n}\n```\n\nIn both cases, the probe returns the [JSON payload as-is][api] from Prometheus\nor raises an exception when an error is met.\n\n[api]: https://prometheus.io/docs/querying/api/\n\nThe result is not further process and should be found in the generated report\nof the experiment run.\n\nYou can also send metrics to a pushgateway service via a control:\n\n```json\n{\n    \"controls\": [\n        {\n            \"name\": \"prometheus\",\n            \"provider\": {\n                \"type\": \"python\",\n                \"module\": \"chaosprometheus.metrics\",\n                \"arguments\": {\n                    \"pushgateway_url\": \"http://someip:9091\",\n                    \"job\": \"chaostoolkit\"\n                }\n            }\n        }\n    ]\n}\n```\n\nYou can also set three more arguments:\n\n* `grouping_key`: A mapping of strings to uniquely aggregate multiple runs\n  in the Prometheus backend\n* `trace_id`: This must be a string which will identify this run uniquely in\n  your metrics. If none is a provided, a random string is generated.\n* `experiment_ref`: Sometimes it's useful to identify a particular experiment,\n  not just its run, throughout many runs. This is the string to do that. If\n  none is provided, a hash of the experiment is performed and used. The hash\n  is not stable across changes of the experiment of course.\n  \nThese are particularly useful when you couple this extension with others like\nLoki where you want to cross-reference between logs and metrics.\n\n## Contribute\n\nIf you wish to contribute more functions to this package, you are more than\nwelcome to do so. Please, fork this project, make your changes following the\nusual [PEP 8][pep8] code style, sprinkling with tests and submit a PR for\nreview.\n\n[pep8]: https://pycodestyle.readthedocs.io/en/latest/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-prometheus/lists"}