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)
```
[![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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file prometheus-aioexporter-0.2.0.tar.gz
.
File metadata
- Download URL: prometheus-aioexporter-0.2.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a29008d910489415a5fc540b92de4f5b9512ed60f1c81e7492ef2d1bdaf1217 |
|
MD5 | 8c38e9fdd2a073d8b4827d48c3178f82 |
|
BLAKE2b-256 | 3c118fd678eb1897d0edb129aa4a4db09dda5a1435b05c5776eea583f1f7667a |