{ "info": { "author": "Alexandr Lispython", "author_email": "lispython@users.noreply.github.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: System Administrators", "Operating System :: OS Independent", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: System :: Monitoring", "Topic :: System :: Networking :: Monitoring" ], "description": "Prometheus instrumentation library for Python applications\n============================================================\n\nThe unofficial Python 2 and 3 client for `Prometheus`_.\n\n.. image:: https://travis-ci.org/Lispython/pyprometheus.svg?branch=master\n :target: https://travis-ci.org/Lispython/pyprometheus\n\n\n\nFeatures\n--------\n\n- Four types of metric are supported: Counter, Gauge, Summary(without quantiles) and Histogram.\n- InMemoryStorage (do not use it for multiprocessing apps)\n- UWSGI storage - share metrics between processes\n- UWAGI flush storage - sync metrics with uwsgi sharedarea by flush call\n- time decorator\n- time context manager\n\n\n\nINSTALLATION\n------------\n\nTo use pyprometheus use pip or easy_install:\n\n:code:`pip install pyprometheus`\n\nor\n\n:code:`easy_install pyprometheus`\n\n\nHOW TO INSTRUMENTING CODE\n-------------------------\n\nGauge\n~~~~~\n\nA gauge is a metric that represents a single numerical value that can arbitrarily go up and down.::\n\n from pyprometheus import Gauge\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n gauge = Gauge(\"job_in_progress\", \"Description\", registry=registry)\n\n gauge.inc(10)\n gauge.dec(5)\n gauge.set(21.1)\n\n\nutilities::\n\n gauge.set_to_current_time() # Set to current unixtime\n\n # Increment when entered, decrement when exited.\n @gauge.track_in_progress()\n def f():\n pass\n\n with gauge.track_in_progress():\n pass\n\n\n with gauge.time():\n time.sleep(10)\n\n\n\nCounter\n~~~~~~~\n\nA counter is a cumulative metric that represents a single numerical value that only ever goes up.::\n\n from pyprometheus import Counter\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n counter = Counter(\"requests_total\", \"Description\", registry=registry)\n\n counter.inc(10)\n\n\n\n\n\nSummary\n~~~~~~~\n\nSimilar to a histogram, a summary samples observations (usually things like request durations and response sizes).::\n\n from pyprometheus import Summary\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n s = Summary(\"requests_duration_seconds\", \"Description\", registry=registry)\n\n s.observe(0.100)\n\n\nutilities for timing code::\n\n @gauge.time()\n def func():\n time.sleep(10)\n\n with gauge.time():\n time.sleep(10)\n\n\n\nHistogram\n~~~~~~~~~\n\nA histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.::\n\n from pyprometheus import Summary\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n histogram = Histogram(\"requests_duration_seconds\", \"Description\", registry=registry)\n\n histogram.observe(1.1)\n\nutilities for timing code::\n\n @histogram.time()\n def func():\n time.sleep(10)\n\n with histogram.time():\n time.sleep(10)\n\n\n\nLabels\n~~~~~~\n\nAll metrics can have labels, allowing grouping of related time series.\n\n\nExample::\n\n from pyprometheus import Counter\n c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])\n c.labels('get', '/').inc()\n c.labels('post', '/submit').inc()\n\nor labels as keyword arguments::\n\n from pyprometheus import Counter\n c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])\n c.labels(method='get', endpoint='/').inc()\n c.labels(method='post', endpoint='/submit').inc()\n\n\n\nSTORAGES\n--------\n\nCurrently library support 2 storages: LocalMemoryStorage and UWSGIStorage\n\nEvery registry MUST have link to storage::\n\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n\n\nUse LocalMemoryStorage\n~~~~~~~~~~~~~~~~~~~~~~\n\nSimple storage that store samples to application memory. It can be used with threads.::\n\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n\n storage = LocalMemoryStorag()\n\n\nUse UWSGIStorage\n~~~~~~~~~~~~~~~~\n\nUWSGIStorage allow to use `uwsgi sharedarea`_ to sync metrics between processes.::\n\n from pyprometheus.contrib.uwsgi_features import UWSGICollector, UWSGIStorage\n\n SHAREDAREA_ID = 0\n storage = UWSGIStorage(SHAREDAREA_ID)\n\n\n\nalso need to configure UWSGI sharedaread pages.\n\n\n\n\nEXPORTING\n---------\n\nLibrary have some helpers to export metrics\n\nTo text format\n~~~~~~~~~~~~~~\n\nYou can convert registry to text format::\n\n\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n from pyprometheus.utils.exposition import registry_to_text\n from pyprometheus import Gauge\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n g = Gauge('raid_status', '1 if raid array is okay', registry=registry)\n g.set(1)\n print(registry_to_text(registry))\n\n\n\nText file export\n~~~~~~~~~~~~~~~~\n\nThis is useful for monitoring cronjobs, or for writing cronjobs to expose metrics about a machine system.::\n\n from pyprometheus import BaseRegistry, LocalMemoryStorage\n from pyprometheus.utils.exposition import registry_to_text, write_to_textfile\n from pyprometheus import Gauge\n\n storage = LocalMemoryStorage()\n registry = CollectorRegistry(storage=storage)\n g = Gauge('raid_status', '1 if raid array is okay', registry=registry)\n g.set(1)\n write_to_textfile(registry, \"/path/to/file/metrics.prom\")\n\n\nYou can configure `text file collector`_ to use generated file.\n\n\nTODO\n----\n\nSome features that we plan to do:\n\n- [ ] Add mmap storage\n- [ ] Add features for async frameworks\n- [ ] Optimize UWSGI storage byte pad\n- [ ] Add quantiles\n\n\n\nEXAMPLE PROJECT\n---------------\n\nWe create `example project`_ to show hot to use pyprometheus in real project.\n\n\nCONTRIBUTE\n----------\n\nFork https://github.com/Lispython/pyprometheus/ , create commit and pull request to ``develop``.\n\n\n\n.. _`example project`: http://github.com/Lispython/pyprometheus_demo\n.. _`text file collector`: https://github.com/prometheus/node_exporter#textfile-collector\n.. _`uwsgi sharedarea`: http://uwsgi-docs.readthedocs.io/en/latest/SharedArea.html\n.. _`Prometheus`: http://prometheus.io\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Lispython/pyprometheus", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pyprometheus", "package_url": "https://pypi.org/project/pyprometheus/", "platform": "", "project_url": "https://pypi.org/project/pyprometheus/", "project_urls": { "Homepage": "https://github.com/Lispython/pyprometheus" }, "release_url": "https://pypi.org/project/pyprometheus/0.0.9/", "requires_dist": [ "flake8 (==3.2.1); extra == 'tests'", "flake8-comprehensions (==1.2.1); extra == 'tests'", "flake8-quotes (==0.9.0); extra == 'tests'", "ipdb; extra == 'tests'", "pytest (==3.0.6); extra == 'tests'", "pytest-cov (==2.4.0); extra == 'tests'", "pytest-flake8 (==0.8.1); extra == 'tests'", "tox (==2.3.2); extra == 'tests'", "uwsgi (==2.0.14); extra == 'tests'" ], "requires_python": "", "summary": "Prometheus python client and instrumentation library", "version": "0.0.9" }, "last_serial": 3729784, "releases": { "0.0.3": [], "0.0.4": [ { "comment_text": "", "digests": { "md5": "cc00e8e545cbb0c0fab2acfb17e6121e", "sha256": "c9d3efce2069ece2e7240590b681331460dc8047881a761fcd4250f1daa62de8" }, "downloads": -1, "filename": "pyprometheus-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cc00e8e545cbb0c0fab2acfb17e6121e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21796, "upload_time": "2017-02-27T19:39:22", "url": "https://files.pythonhosted.org/packages/e9/7f/8a1dfae7cf9bd07feed07bb146f83a2e0328a00462755dab74767a5a73ef/pyprometheus-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0fa59dab12470bcb07e7bf048368cd86", "sha256": "7dacfc43789d95cde16d499e266c0ba5fd767769e28b3d9f5721c8aa81024b93" }, "downloads": -1, "filename": "pyprometheus-0.0.4.tar.gz", "has_sig": false, "md5_digest": "0fa59dab12470bcb07e7bf048368cd86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20256, "upload_time": "2017-02-27T19:39:25", "url": "https://files.pythonhosted.org/packages/f0/d3/96dc6aee45967a8c8af2f6e4b7223f39d33f7731929b936afc7902aa27f3/pyprometheus-0.0.4.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "3e7cb8c6ab7ab028b0339f56fedae242", "sha256": "12b20f98cf4f344ac894b3c2e3fd69f5311231cfe59ba0c43fe97a495fdb073b" }, "downloads": -1, "filename": "pyprometheus-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3e7cb8c6ab7ab028b0339f56fedae242", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22383, "upload_time": "2017-03-09T08:35:11", "url": "https://files.pythonhosted.org/packages/de/1d/5ec55de8d679482f529d64c71d9bb9253dd8da1cbe2d7756a1fbaefef0c5/pyprometheus-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f68f874a333f39c2848e77a0c0010ff9", "sha256": "9ecd1e428c14ea187e20d213a6d553332a8c042eacb8e1a5b50c80814b5af2f7" }, "downloads": -1, "filename": "pyprometheus-0.0.6.tar.gz", "has_sig": false, "md5_digest": "f68f874a333f39c2848e77a0c0010ff9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20629, "upload_time": "2017-03-09T08:35:13", "url": "https://files.pythonhosted.org/packages/48/48/a4f05849f40c8a88b14a32bf1f341b5423fed1de44948b4212f8f9aef567/pyprometheus-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "379cc86cdeffeab9857b1187641ecfae", "sha256": "378b657b24a55d580ef94133fecd0a28ccf3aa13b80830decf7d49fb1971ee7b" }, "downloads": -1, "filename": "pyprometheus-0.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "379cc86cdeffeab9857b1187641ecfae", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 24987, "upload_time": "2017-04-03T07:17:08", "url": "https://files.pythonhosted.org/packages/af/3b/c757efe1d6707183b2a0ac741a6a7454fab9dabd85362a10949c909dbdef/pyprometheus-0.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "446cc54f09e231af6bfc434472c6bbff", "sha256": "a0efff332dd35173a6d180829de30e9068542cac9f2dffb33d2fd3400286d643" }, "downloads": -1, "filename": "pyprometheus-0.0.7.tar.gz", "has_sig": false, "md5_digest": "446cc54f09e231af6bfc434472c6bbff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21023, "upload_time": "2017-04-03T07:17:10", "url": "https://files.pythonhosted.org/packages/14/52/b4ee2ff7f16603940340033b98cd27cc3bb7df623ce421d7c2cab41d0291/pyprometheus-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "1733752c403d73e8335a361cc6f38704", "sha256": "2cfa13db4d6dbbb71473752179cf4c2febaab0d8e8c9bd7ffb0beb0bb1b25703" }, "downloads": -1, "filename": "pyprometheus-0.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1733752c403d73e8335a361cc6f38704", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22615, "upload_time": "2017-04-04T11:33:00", "url": "https://files.pythonhosted.org/packages/45/62/b1c0c8cb2d05d3f36173c5ebb3d893c13bcaa4cc38eeb7f86013164ad11a/pyprometheus-0.0.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "67fd54a7f2be83ca30427944be6d9bc2", "sha256": "7094c146a3567cf39e98f51ae1b3f494675c563a7ed740ec5d74a6c573917511" }, "downloads": -1, "filename": "pyprometheus-0.0.8.tar.gz", "has_sig": false, "md5_digest": "67fd54a7f2be83ca30427944be6d9bc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20985, "upload_time": "2017-04-04T11:33:02", "url": "https://files.pythonhosted.org/packages/64/70/b7c9930adac86459ea57685f6fafde596b3a5af2f53174b76ba377bec1be/pyprometheus-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "3cf33ba01f9a5828985e092c20e35c30", "sha256": "4dbdc654e7389bbd60c6d975c6b8bca148bb6dcb2691832221c9cf2a1431d0e1" }, "downloads": -1, "filename": "pyprometheus-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3cf33ba01f9a5828985e092c20e35c30", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22882, "upload_time": "2018-04-03T14:29:05", "url": "https://files.pythonhosted.org/packages/39/bf/e26eb1d8fbd99240813675120c40e09a79cf3b14020cee3a5854d460940f/pyprometheus-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "55196b3dd17a59f50d17601389c14173", "sha256": "ec94ebf5bc079a94a1e8fe45e859c340da2da967573344b52387b0bbd48e5edc" }, "downloads": -1, "filename": "pyprometheus-0.0.9.tar.gz", "has_sig": false, "md5_digest": "55196b3dd17a59f50d17601389c14173", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21101, "upload_time": "2018-04-03T14:29:06", "url": "https://files.pythonhosted.org/packages/27/2d/c8755ef50cebd5290e2d3cb89e9869a0718382956f95a60bff66924780ff/pyprometheus-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3cf33ba01f9a5828985e092c20e35c30", "sha256": "4dbdc654e7389bbd60c6d975c6b8bca148bb6dcb2691832221c9cf2a1431d0e1" }, "downloads": -1, "filename": "pyprometheus-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3cf33ba01f9a5828985e092c20e35c30", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22882, "upload_time": "2018-04-03T14:29:05", "url": "https://files.pythonhosted.org/packages/39/bf/e26eb1d8fbd99240813675120c40e09a79cf3b14020cee3a5854d460940f/pyprometheus-0.0.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "55196b3dd17a59f50d17601389c14173", "sha256": "ec94ebf5bc079a94a1e8fe45e859c340da2da967573344b52387b0bbd48e5edc" }, "downloads": -1, "filename": "pyprometheus-0.0.9.tar.gz", "has_sig": false, "md5_digest": "55196b3dd17a59f50d17601389c14173", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21101, "upload_time": "2018-04-03T14:29:06", "url": "https://files.pythonhosted.org/packages/27/2d/c8755ef50cebd5290e2d3cb89e9869a0718382956f95a60bff66924780ff/pyprometheus-0.0.9.tar.gz" } ] }