Skip to main content

No project description provided

Project description

Build Status Code Climate Coverage Status

Prometheus Distributed Client

Purpose and principle

prometheus-distributed-client is aimed at shorted lived process that can expose Prometheus metrics through HTTP.

Advantages over Pushgateway

The prometheus project provides several ways of publishing metrics. Either you publish them directly like the official client allows you to do, or you push them to a 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 but replaces all write and read operation by database call.

Declaring and using metrics

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.

# 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prometheus_distributed_client-2.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prometheus_distributed_client-2.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file prometheus_distributed_client-2.0.0.tar.gz.

File metadata

  • Download URL: prometheus_distributed_client-2.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.3 Linux/6.14.0-27-generic

File hashes

Hashes for prometheus_distributed_client-2.0.0.tar.gz
Algorithm Hash digest
SHA256 810f212831336bbf26351ea7bbe19a3e9192f5fd47fdedbd9be94e96ad787724
MD5 38e4aa5238482d653edd9c9bbf6dc0f0
BLAKE2b-256 4f31a484eca04460e8db51c49aa33894465a33856bdb46019a161bcd21e2e121

See more details on using hashes here.

File details

Details for the file prometheus_distributed_client-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prometheus_distributed_client-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a45e65f66feaed622f9aa35eefd5c56fde1e4fe7db55bb48adba27a79867b36
MD5 dabc56b4f90f530d04f270f9ffb575c0
BLAKE2b-256 8ae3d967c797c03ffa8b4a34551616c6628099df23d02caa6f9b686c55ec2f3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page