Skip to main content

A Python library for exporting data as metrics for Prometheus

Project description

Prometheus Exporter

A simple prometheus exporter library using:

Features

  • async via aiohttp
  • detailed logging
  • toml config
  • optional caching

Components

Labels

The Labels dict represents a collection of labels and ensures added labels are strings.

The __str__ method is overridden so that when printed, the object returns a formatted label string for exporting.

copy() ensures the copy is also a Labels type, and has a logger from the same parent.

Metric

The Metric class represents a prometheus metric.

It must be defined with a name, and defaults to the value 0.

Optionally the following parameters can be passed:

  • metric_type (untyped) Prometheus metric type
  • help (None) The metric help string
  • labels (Labels()) Label dictionary for the metric.

check_filter(label_filter) can be used to pass a label filter to the metric, returning True if the labels match.

__str__ is overridden to print out a proper metric string based on the contents of the object.

Exporter

The Exporter is responsible for collecting and exporting metrics.

The following arguments can be used:

  • config_file (config.toml) The config file for the exporter.
  • labels (Labels()) Label dictionary for the exporter, passed to created metrics.
  • listen_ip (127.0.0.1) The IP address to run the exporter on.
  • listen_port (9999) The port to listen on.

Once created the exporter can be started with: start()

Requests to /metrics are handled by handle_metrics(request).

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_exporter-1.0.0.tar.gz (13.9 kB view details)

Uploaded Source

File details

Details for the file prometheus_exporter-1.0.0.tar.gz.

File metadata

  • Download URL: prometheus_exporter-1.0.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for prometheus_exporter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d333ae113c9eefca9550053def70c97571930b8b88ab1904dcc6cfe51b75c2e9
MD5 941e65f0290c3b88405399164ec4336f
BLAKE2b-256 2d7c359edd4f99faebeebac2ff5d85d3bc3077ed0d86548f9c3a4fbcb93be299

See more details on using hashes here.

Supported by

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