prometheus-distributed-client


Nameprometheus-distributed-client JSON
Version 1.2.2 PyPI version JSON
download
home_page
Summary
upload_time2023-01-19 13:52:27
maintainer
docs_urlNone
authorFrançois Schmidts
requires_python>=3.7,<4.0
licenseGPLv3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://travis-ci.org/dolead/prometheus-distributed-client.svg?branch=master)](https://travis-ci.org/dolead/prometheus-distributed-client)
[![Code Climate](https://codeclimate.com/github/dolead/prometheus-distributed-client/badges/gpa.svg)](https://codeclimate.com/github/dolead/prometheus-distributed-client)
[![Coverage Status](https://coveralls.io/repos/github/dolead/prometheus-distributed-client/badge.svg?branch=master)](https://coveralls.io/github/dolead/prometheus-distributed-client?branch=master)

# Prometheus Distributed Client

### Purpose and principle

```prometheus-distributed-client``` is aimed at shorted lived process that can expose [Prometheus](https://prometheus.io/) metrics through HTTP.

### Advantages over Pushgateway

The prometheus project provides several ways of publishing metrics. Either you publish them directly like the [official client](https://github.com/prometheus/client_python) allows you to do, or you push them to a [pushgateway](https://github.com/prometheus/pushgateway).

The first method implies you've got to keep your metrics in-memory and publishs them over http.
The second method implies that you'll either have a pushgateway per process or split your metrics over all your processes to avoid overwriting your existing pushed metrics.

```prometheus-distributed-client``` allows you to have your short lived process push metrics to a database and have another process serving them over HTTP. One of the perks of that approach is that you keep consistency over concurrent calls. (Making multiple counter increment from multiple process will be acknowledge correctly by the database).

### Code examples

```prometheus-distributed-client``` uses the base of the [official client](https://github.com/prometheus/client_python) but replaces all write and read operation by database call.

#### Declaring and using metrics

```python
from prometheus-distributed-client import set_redis_conn, Counter, Gauge
# we use the official clients internal architecture
from prometheus_client import CollectorRegistry

# set your own registry
REGISTRY = CollectorRegistry()
# declare metrics from prometheus-distributed-client
COUNTER = Counter('counter_metric_name', 'metric documentation',
                  [labels], registry=REGISTRY)
GAUGE = Gauge('gauge_metric_name', 'metric documentation',
                  [labels], registry=REGISTRY)

# increment a counter and set a value for a gauge
COUNTER.labels('label_value').inc()
GAUGE.labels('other_label_value').set(12)
```

### Serving the metrics

```prometheus-distributed-client``` use the registry system from the official client and is de facto compatible with it. If you want to register regular metrics alongside the one from ```prometheus-distributed-client``` it is totally feasible.
Here is a little example of how to serv metrics from ```prometheus-distributed-client```, but you can also refer to the [documentation of the official client](https://github.com/prometheus/client_python#exporting).

```python
# with flask

from flask import Flask
from prometheus_client import generate_latest
# get the registry you declared your metrics in
from metrics import REGISTRY

app = Flask()

@app.route('/metrics')
def metrics():
    return generate_latest(REGISTRY)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "prometheus-distributed-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Fran\u00e7ois Schmidts",
    "author_email": "francois@schmidts.fr",
    "download_url": "https://files.pythonhosted.org/packages/94/e3/9d75aea666a46820c7b6aad09d65ab45373fe5c9f2a275974a106c3abf63/prometheus_distributed_client-1.2.2.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://travis-ci.org/dolead/prometheus-distributed-client.svg?branch=master)](https://travis-ci.org/dolead/prometheus-distributed-client)\n[![Code Climate](https://codeclimate.com/github/dolead/prometheus-distributed-client/badges/gpa.svg)](https://codeclimate.com/github/dolead/prometheus-distributed-client)\n[![Coverage Status](https://coveralls.io/repos/github/dolead/prometheus-distributed-client/badge.svg?branch=master)](https://coveralls.io/github/dolead/prometheus-distributed-client?branch=master)\n\n# Prometheus Distributed Client\n\n### Purpose and principle\n\n```prometheus-distributed-client``` is aimed at shorted lived process that can expose [Prometheus](https://prometheus.io/) metrics through HTTP.\n\n### Advantages over Pushgateway\n\nThe prometheus project provides several ways of publishing metrics. Either you publish them directly like the [official client](https://github.com/prometheus/client_python) allows you to do, or you push them to a [pushgateway](https://github.com/prometheus/pushgateway).\n\nThe first method implies you've got to keep your metrics in-memory and publishs them over http.\nThe second method implies that you'll either have a pushgateway per process or split your metrics over all your processes to avoid overwriting your existing pushed metrics.\n\n```prometheus-distributed-client``` allows you to have your short lived process push metrics to a database and have another process serving them over HTTP. One of the perks of that approach is that you keep consistency over concurrent calls. (Making multiple counter increment from multiple process will be acknowledge correctly by the database).\n\n### Code examples\n\n```prometheus-distributed-client``` uses the base of the [official client](https://github.com/prometheus/client_python) but replaces all write and read operation by database call.\n\n#### Declaring and using metrics\n\n```python\nfrom prometheus-distributed-client import set_redis_conn, Counter, Gauge\n# we use the official clients internal architecture\nfrom prometheus_client import CollectorRegistry\n\n# set your own registry\nREGISTRY = CollectorRegistry()\n# declare metrics from prometheus-distributed-client\nCOUNTER = Counter('counter_metric_name', 'metric documentation',\n                  [labels], registry=REGISTRY)\nGAUGE = Gauge('gauge_metric_name', 'metric documentation',\n                  [labels], registry=REGISTRY)\n\n# increment a counter and set a value for a gauge\nCOUNTER.labels('label_value').inc()\nGAUGE.labels('other_label_value').set(12)\n```\n\n### Serving the metrics\n\n```prometheus-distributed-client``` use the registry system from the official client and is de facto compatible with it. If you want to register regular metrics alongside the one from ```prometheus-distributed-client``` it is totally feasible.\nHere is a little example of how to serv metrics from ```prometheus-distributed-client```, but you can also refer to the [documentation of the official client](https://github.com/prometheus/client_python#exporting).\n\n```python\n# with flask\n\nfrom flask import Flask\nfrom prometheus_client import generate_latest\n# get the registry you declared your metrics in\nfrom metrics import REGISTRY\n\napp = Flask()\n\n@app.route('/metrics')\ndef metrics():\n    return generate_latest(REGISTRY)\n```\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "",
    "version": "1.2.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "61af844ab330b77f0805f1d32b422f7c661ce3f96c2a3baf27f8a4419ff83ca6",
                "md5": "0088f37c658d9bad863410e7d2e4a838",
                "sha256": "194fb46cd990d72403936b0d0569b24a36cb69ba8bd951f656d2a7ea5124b4bd"
            },
            "downloads": -1,
            "filename": "prometheus_distributed_client-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0088f37c658d9bad863410e7d2e4a838",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 15825,
            "upload_time": "2023-01-19T13:52:26",
            "upload_time_iso_8601": "2023-01-19T13:52:26.658710Z",
            "url": "https://files.pythonhosted.org/packages/61/af/844ab330b77f0805f1d32b422f7c661ce3f96c2a3baf27f8a4419ff83ca6/prometheus_distributed_client-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94e39d75aea666a46820c7b6aad09d65ab45373fe5c9f2a275974a106c3abf63",
                "md5": "2ff495809984f5b702fceda40f0c8c62",
                "sha256": "ae26c4f539e6b3e69e6086ff0e1376e82e49c1ad65ccf5eff1fc17e95debc278"
            },
            "downloads": -1,
            "filename": "prometheus_distributed_client-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2ff495809984f5b702fceda40f0c8c62",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 15657,
            "upload_time": "2023-01-19T13:52:27",
            "upload_time_iso_8601": "2023-01-19T13:52:27.963471Z",
            "url": "https://files.pythonhosted.org/packages/94/e3/9d75aea666a46820c7b6aad09d65ab45373fe5c9f2a275974a106c3abf63/prometheus_distributed_client-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-19 13:52:27",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "prometheus-distributed-client"
}
        
Elapsed time: 0.02981s