Skip to main content

Asyncio library for creating Prometheus exporters.

Project description

# prometheus-aioexporter - Asyncio library for creating Prometheus exporters

[![Latest Version](https://img.shields.io/pypi/v/prometheus-aioexporter.svg)](https://pypi-hypernode.com/pypi/prometheus-aioexporter)
[![Build Status](https://travis-ci.org/albertodonato/prometheus-aioexporter.svg?branch=master)](https://travis-ci.org/albertodonato/prometheus-aioexporter)
[![Coverage Status](https://codecov.io/gh/albertodonato/prometheus-aioexporter/branch/master/graph/badge.svg)](https://codecov.io/gh/albertodonato/prometheus-aioexporter)

prometheus-aioexporter is an aysncio-powered library that provides a few
utilities to build [Prometheus](https://prometheus.io/) exporters.


## Install

The library can be installed from pip:

```bash
pip install prometheus-aioexporter
```

## Usage

The library provides a `PrometheusExporterScript` class that serves as an entry
point to create services that export Prometheus metrics via an HTTP endpoint.

An example usage is the following:

```python
from prometheus_aioexporter.script import PrometheusExporterScript


class MyExporter(PrometheusExporterScript):
"""My Prometheus exporter."""

def configure_argument_parser(self, parser):
# Additional arguments to the script
parser.add_argument('an-option', help='an option')
...

def configure(self, args):
# Save attributes that are needed for later
self.data = do_stuff()
...

def on_application_startup(self, application):
# Start other asyncio tasks at application startup
use(self.data)
...

def on_application_shutdown(self, application):
# Stop other asyncio tasks at application shutdown
use(self.data)
...


script = MyExporter()
```

The `script` variable can be referenced in `setup.py` to generate the script, like

```python
setup(
...,
entry_points={'console_scripts': ['script = path.to.script:script']},
...)
```

`PrometheusExporterScript` provides the following arguments by default, which can be
exended by implementing `configure_argument_parser()`:


```
optional arguments:
-h, --help show this help message and exit
-H HOST, --host HOST host address to bind (default: localhost)
-p PORT, --port PORT port to run the webserver on (default: 9090)
-L {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --log-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}
minimum level for log messages (default: WARNING)
--process-stats include process stats in metrics (default: False)
```


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-aioexporter-1.0.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

prometheus_aioexporter-1.0.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file prometheus-aioexporter-1.0.2.tar.gz.

File metadata

File hashes

Hashes for prometheus-aioexporter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 397f6fc3758a9a4196981f0983a50f98ce56490510bff24a28ef17720909aaa3
MD5 fd5b9c6d3932ae23ee4248a4e743e4b9
BLAKE2b-256 cfa62e687c96a263662fa08e6f7b84e51661c2c1d47e8722b2598ef09aebf20f

See more details on using hashes here.

File details

Details for the file prometheus_aioexporter-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for prometheus_aioexporter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c99b1b8e38b34980a5c93c560e6ebf2f263019aac9efa242435e9b19d1923a13
MD5 5965c5989e8940fda2ed60529bb361c1
BLAKE2b-256 8d636bd2febd7e609c2dc282a974eed0ee25489cb1681eb40d3b3db5c64237cb

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