{ "info": { "author": "Xabier Larrakoetxea", "author_email": "slok69@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "Prometheus python client\n==================\n\nPython 3 client library for [Prometheus](http://prometheus.io) that can\nserve data to prometheus (in text and protobuf formats) and also push data\nto a pushgateway.\n\n[![CircleCI](https://circleci.com/gh/slok/prometheus-python.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/slok/prometheus-python)\n[![Coverage Status](https://coveralls.io/repos/slok/prometheus-python/badge.svg?branch=master)](https://coveralls.io/r/slok/prometheus-python?branch=master)\n[![PyPI version](https://badge.fury.io/py/prometheus.svg)](http://badge.fury.io/py/prometheus)\n\n**Table of Contents**\n\n- [Prometheus python client](#)\n - [Status](#)\n - [Install](#)\n - [Why Python 3 and not python 2?](#)\n - [Usage](#)\n - [Serve data](#)\n - [Push data (to pushgateway)](#)\n - [Metrics/Collectors](#)\n - [Counter](#)\n - [Gauge](#)\n - [Summary](#)\n - [Labels](#)\n - [Const labels](#)\n - [Examples](#)\n - [Serve examples](#)\n - [Gauges](#)\n - [Summaries](#)\n - [How to use the examples](#)\n - [PushGateway examples](#)\n - [Gauges](#)\n - [How to use the examples](#)\n - [Tests](#)\n - [TODO](#)\n - [Author](#)\n - [License](#)\n\n\nStatus\n------\nUnder *heavy* development\n\n\nInstall\n-------\n\n $ pip install prometheus\n\n\nWhy Python 3 and not python 2?\n-------------------------------\n\nI think that everyone should start adopting the \"new\" Python version and let\npython2 be the old man that every one likes talking to but don't want live be with him.\n\nAnd the only way doing this is by \"forcing people\" to use py3.\n\nAlso Maintaining code for one version is hard, imagine 2... error prone, slower updates...\n\nSo, don't use Python 2 and start using Python 3!\n\nUsage\n-----\n\n### Serve data\n\n```python\nfrom http.server import HTTPServer\nfrom prometheus.exporter import PrometheusMetricHandler\nfrom prometheus.registry import Registry\n\nregistry = Registry()\n\ndef handler(*args, **kwargs):\n PrometheusMetricHandler(registry, *args, **kwargs)\n\nserver = HTTPServer(('', 8888), handler)\nserver.serve_forever()\n```\n\n### Push data (to pushgateway)\n\n TODO\n\nMetrics/Collectors\n-------------------\n\n### Counter\n\n```python\nfrom prometheus.collectors import Counter\n\nuploads_metric = Counter(\"file_uploads_total\", \"File total uploads.\")\nuploads_metric.inc({'type': \"png\", })\n```\n\n### Gauge\n\n```python\nfrom prometheus.collectors import Gauge\n\nram_metric = Gauge(\"memory_usage_bytes\", \"Memory usage in bytes.\", {'host': host})\nram_metric.set({'type': \"virtual\", }, 100)\n```\n\n### Summary\n\n```python\nfrom prometheus.collectors import Summary\n\nhttp_access = Summary(\"http_access_time\", \"HTTP access time\", {'time': 'ms'})\n\nvalues = [3, 5.2, 13, 4]\n\nfor i in values:\n http_access.add({'time': '/static'}, i)\n```\n\nLabels\n------\n\nLabels define the multidimensional magic in prometheus. To add a metric to a collector\nyou identify with a label for example we have this collector that stores the cosumed\nmemory:\n\n```python\n ram_metric = Gauge(\"memory_usage_bytes\", \"Memory usage in bytes.\")\n```\n\nAnd then we add our RAM user MBs:\n\n```python\n ram_metric.set({'type': \"virtual\", }, 100)\n```\n\naplying mutidimensional capacity we can store in the same metric the memory consumed by the\nswap of our system too:\n\n```python\n ram_metric.set({'type': \"swap\", }, 100)\n```\n\nConst labels\n------------\n\nWhen you create a `collector` you can put to than collector constant labels,\nthese constant labels will apply to all the metrics gathered by that collector\nappart from the ones that we put. For example this example without const labels\n\n```python\n ram_metric = Gauge(\"memory_usage_bytes\", \"Memory usage in bytes.\")\n ram_metric.set({'type': \"virtual\", 'host': host}, 100)\n ram_metric.set({'type': \"swap\", 'host': host}, 100)\n```\n\nis the same as this one with const labels:\n\n```python\n ram_metric = Gauge(\"memory_usage_bytes\", \"Memory usage in bytes.\", {'host': host})\n ram_metric.set({'type': \"virtual\", }, 100)\n ram_metric.set({'type': \"swap\", }, 100)\n```\n\nExamples\n--------\n\n### Serve examples\n\n#### Gauges\n* [Memory and cpu usage](examples/memory_cpu_usage_example.py) (Requires psutil)\n* [Trigonometry samples](examples/trigonometry_example.py)\n\n#### Summaries\n* [Disk write IO timing](examples/timing_write_io_example.py)\n\n#### How to use the examples\n\nFirst some examples need requirements, install them:\n\n pip install requirements_test.txt\n\nNow run an example, for example [timing_write_io_example.py](examples/timing_write_io_example.py)\n\n python ./examples/timing_write_io_example.py\n\nAll examples run on port `4444`. You can point prometheus conf like this to\npoint to one of the examples:\n\n job: {\n name: \"python-client-test\"\n scrape_interval: \"1s\"\n target_group: {\n target: \"http://xxx.xxx.xxx.xxx:4444/metrics\"\n }\n }\n\nOr you can test the different formats available with curl:\n\nDefault (Text 0.0.4):\n\n curl 'http://127.0.0.1:4444/metrics'\n\n\nText (0.0.4):\n\n curl 'http://127.0.0.1:4444/metrics' -H 'Accept: text/plain; version=0.0.4'\n\n\nProtobuf debug (0.0.4):\n\n curl 'http://127.0.0.1:4444/metrics' -H 'Accept: application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=text'\n\nProtobuf (0.0.4):\n\n curl 'http://127.0.0.1:4444/metrics' -H 'Accept: application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited'\n\n\n### PushGateway examples\n\n#### Gauges\n\n* [input digits](examples/input_example.py)\n\n\n#### How to use the examples\n\nFirst you need to run a gateway, for example with docker:\n\n docker run --rm -p 9091:9091 prom/pushgateway\n\nNow configure prometheus to grab the metrics from the push gateway example\n\n job: {\n name: \"pushgateway\"\n scrape_interval: \"1s\"\n target_group: {\n target: \"http://172.17.42.1:9091/metrics\"\n }\n }\n\nReady to launch the example:\n\n python ./examples/input_example.py\n\nAs the serve explanation, you can debug de pushgateway serving data by\naccessing its URL (in the example: `http://localhost:9091/metrics`) with `Curl`\n\nTests\n-----\n\n $ pip install -r requirements_test.txt\n $ ./run_tests.sh\n\n\nTODO\n----\n\n* Moaaaar examples\n* implement handy utils\n\n\nAuthor\n------\n\n[Xabier (slok) Larrakoetxea](http://xlarrakoetxea.org)\n\nLicense\n-------\n\n[See License](/LICENSE)", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/slok/prometheus-python/tarball/0.3.0", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/slok/prometheus-python", "keywords": "prometheus,client,metrics", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "prometheus", "package_url": "https://pypi.org/project/prometheus/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/prometheus/", "project_urls": { "Download": "https://github.com/slok/prometheus-python/tarball/0.3.0", "Homepage": "https://github.com/slok/prometheus-python" }, "release_url": "https://pypi.org/project/prometheus/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "Python Prometheus client", "version": "0.3.0" }, "last_serial": 1431423, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "bb118c847e1fe4dc988b7797446cb5c4", "sha256": "f8ff1ef060a5ceb6915f937b7c475179912134645dc109b3a1b765c92621bf13" }, "downloads": -1, "filename": "prometheus-0.1.tar.gz", "has_sig": false, "md5_digest": "bb118c847e1fe4dc988b7797446cb5c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14741, "upload_time": "2015-02-11T19:56:55", "url": "https://files.pythonhosted.org/packages/66/f2/e14c2cfea645505fbef02e4740aa3abb8a7cc1a540d087357acd878b1c18/prometheus-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "38135506c9b64f5f4c09f002d6fdebe9", "sha256": "88e76d43d13b7686c46dd6a52db82d953458bf4bc3a0e3795d263498a739e8ca" }, "downloads": -1, "filename": "prometheus-0.1.1.tar.gz", "has_sig": false, "md5_digest": "38135506c9b64f5f4c09f002d6fdebe9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15465, "upload_time": "2015-02-11T21:02:00", "url": "https://files.pythonhosted.org/packages/f4/26/7e49773271056d18b56221e64dfdc900de1ccf5cb6529d1f32802333907d/prometheus-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "1ef73fd66d06c5c2c6782175f3338829", "sha256": "b8dced4c78301372e4c6d774f4ef19dde319daadf080870b0376bbd0faf6fedf" }, "downloads": -1, "filename": "prometheus-0.1.2.tar.gz", "has_sig": false, "md5_digest": "1ef73fd66d06c5c2c6782175f3338829", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15486, "upload_time": "2015-02-11T21:13:58", "url": "https://files.pythonhosted.org/packages/ad/d2/770110e6bac9da1976be0fd5906f2ea0972db531f3e8577135857fb89ac7/prometheus-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "9e3f742cf99e81995df0a38f8c727c77", "sha256": "935e01fae4dbd066a66dcd134a54cd7ec515389b6356787392a0fbb068e9d4d6" }, "downloads": -1, "filename": "prometheus-0.1.3.tar.gz", "has_sig": false, "md5_digest": "9e3f742cf99e81995df0a38f8c727c77", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16932, "upload_time": "2015-02-11T21:27:31", "url": "https://files.pythonhosted.org/packages/87/b7/ad56c8547dfe7fc79fafa39b04a99ac269c37b6fb1a0767b0173285191a3/prometheus-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e3aade56ce37ec67bec8641568492a4e", "sha256": "e6db77eb1ede7cc9e9896358ddb9aeab8ea53fa93041f55a20f03a1854e015a0" }, "downloads": -1, "filename": "prometheus-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e3aade56ce37ec67bec8641568492a4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21453, "upload_time": "2015-02-19T22:43:16", "url": "https://files.pythonhosted.org/packages/a2/cf/09ebfc4f4fd23e7b39343632547beff3d1671e06dd75d8302861e30f52f3/prometheus-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "98eb170133b015a3d23c2b947cf76bf3", "sha256": "a45e8e39f4f950717607add9eb326b32fb63431aa1a4e4999cc836938fc04de0" }, "downloads": -1, "filename": "prometheus-0.2.1.tar.gz", "has_sig": false, "md5_digest": "98eb170133b015a3d23c2b947cf76bf3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23804, "upload_time": "2015-02-19T22:50:02", "url": "https://files.pythonhosted.org/packages/05/2d/8aa5f9a999b9123631eed56ff52bbf2b179dbad73fecf692b23db5221a39/prometheus-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "ada8798b9c06f009ab06421070e6cc31", "sha256": "089b4284cd8c7edfaec6fb6b31cfb02d7a0bf1d7b1cbc08800ef1bf2b7b7d402" }, "downloads": -1, "filename": "prometheus-0.3.0.tar.gz", "has_sig": false, "md5_digest": "ada8798b9c06f009ab06421070e6cc31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26137, "upload_time": "2015-02-20T17:55:23", "url": "https://files.pythonhosted.org/packages/b4/93/417bb94467b7a49d77f21a701a27db71dc5fa857b9bde3e5f135985fdad5/prometheus-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ada8798b9c06f009ab06421070e6cc31", "sha256": "089b4284cd8c7edfaec6fb6b31cfb02d7a0bf1d7b1cbc08800ef1bf2b7b7d402" }, "downloads": -1, "filename": "prometheus-0.3.0.tar.gz", "has_sig": false, "md5_digest": "ada8798b9c06f009ab06421070e6cc31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26137, "upload_time": "2015-02-20T17:55:23", "url": "https://files.pythonhosted.org/packages/b4/93/417bb94467b7a49d77f21a701a27db71dc5fa857b9bde3e5f135985fdad5/prometheus-0.3.0.tar.gz" } ] }