Skip to main content

Customisable prometheus exporter for your python application

Project description

pyp8s

Customisable prometheus exporter for your python application.

Currently not that much customisable, though.

Installation

python3 -m pip install pyp8s

Usage

Examples: https://github.com/pyp8s/examples

MetricsHandler implements a singleton.

from pyp8s import MetricsHandler as meh

if __name__ == '__main__':

    meh.serve(listen_address="0.0.0.0", listen_port=8081)

    meh.init("calls", "counter", "Number of calls I've received")
    meh.init("doorbells", "counter", "Number of doorbells I've answered")
    meh.init("yawns", "counter", "Quite self-explanatory")
    meh.init("mood", "gauge", "How do I feel myself from 1 to good enough")

    meh.inc("calls", 1)

    meh.inc("doorbells", 100, can="have", extra="labels", since="2.1.0")
    meh.inc("doorbells", 9000, this="will", be="useful")

    meh.inc("yawns", 8, satisfying="yes")
    meh.inc("yawns", 1, satisfying="no", loud="yes")

    meh.set("mood", 3)
    meh.set("mood", 6)
curl 127.0.0.1:8081/metrics
# HELP http_get_requests Number GET requests accepted
# TYPE http_get_requests counter
http_get_requests{} 1
# HELP http_get_metrics Number times the metrics endpoint was called
# TYPE http_get_metrics counter
http_get_metrics{} 1
# HELP calls Number of calls I've received
# TYPE calls counter
calls{} 1
# HELP doorbells Number of doorbells I've answered
# TYPE doorbells counter
doorbells{can="have",extra="labels",since="2.1.0"} 100
doorbells{this="will",be="useful"} 9000
# HELP yawns Quite self-explanatory
# TYPE yawns counter
yawns{satisfying="yes"} 8
yawns{satisfying="no",loud="yes"} 1
# HELP mood How do I feel myself from 1 to good enough
# TYPE mood gauge
mood{} 6

Test environment

python3.10 -m virtualenv --prompt="py3.10 pyp8s" .virtualenv
source .virtualenv/bin/activate

Reporting bugs

Please, use GitHub issues.

Requesting new functionality

Please, use GitHub issues.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pyp8s-3.0.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file pyp8s-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyp8s-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for pyp8s-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52a8cc6e6eb4cf3598f547cef68a3e466729fdffea33552ef7111fd9bdd84e2a
MD5 4cdb850a5eefbd08ad025f9a45e62654
BLAKE2b-256 4dab7268f2dce926a55b84ae443c47b5bb20380e6f9caaea5dd05cf65cfd9d2d

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