Skip to main content

Python programmable Prometheus exporter

Docker Repository on Quay Docker Image Version PyPI version Codacy Badge Documentation Status

p3exporter will help any DevOps to quickstart its Prometheus exporter development. It is completly written in python and provides a facility for pluggable metric collectors. The exporter comes with real life exporters to illustrate how it works but is also intended to use as a framework for completely custom collectors.

The included collectors were only tested on linux systems. Other *nix derivates are not supported by us but you are welcome to contribute to bring this exporter to a broader audience.

Installation and Running

There are different ways to run the exporter on your system. Our exporter listen on tcp/5876 by default. You can change this by adding --port or -p option with the port of your choice.

Running exporter as docker container

The simplest way will is to start it as docker container. The container image is hosted on quay.io and dockerhub and the latest tag represent the develop branch of the github repository. If you want to use a given version you can us the verson string (e.g. v1.0.0) as tag instead.

docker run -d --net="host" --pid="host" -v "/:/host:ro,rslave" codeaffen/p3exporter:latest

Installing from pypi.org

We also release all versions on pypi so you can use pip to install the exporter and run it locally.

pip install p3exporter

This will install the exporter and all of its dependencies. Now you can start it as every other program. You need to add --config or -c option with path to your p3.yml file.

$ curl --silent https://raw.githubusercontent.com/codeaffen/p3exporter/develop/p3.yml --output ~/tmp/p3.yml
$ p3exporter --config ~/tmp/p3.yml
INFO:root:Collector 'example' was loaded and registred successfully
INFO:root:Collector 'loadavg' was loaded and registred successfully
INFO:root:Collector 'netdev' was loaded and registred successfully
INFO:root:Start exporter, listen on 5876

Install from repository

The last option to install and run p3exporter is to install it from a local clone of our github repository.

$ git clone https://github.com/codeaffen/p3exporter.git
Cloning into 'p3exporter'...
remote: Enumerating objects: 158, done.
remote: Counting objects: 100% (158/158), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 158 (delta 63), reused 101 (delta 28), pack-reused 0
Receiving objects: 100% (158/158), 188.37 KiB | 1.08 MiB/s, done.
Resolving deltas: 100% (63/63), done.
$ cd p3exporter
$ pip install -e .

From now you can run it with:

$ p3exporter
INFO:root:Collector 'example' was loaded and registred successfully
INFO:root:Collector 'loadavg' was loaded and registred successfully
INFO:root:Collector 'netdev' was loaded and registred successfully
INFO:root:Start exporter, listen on 5876

Building your own container image

To build your own container image you can use the dockerfile which is delivered in our github repository. This file is also used to create our images on quay.io or dockerhub.

$ docker build -t p3exporter .
Sending build context to Docker daemon  181.8kB
...
Successfully built a6bdf60489f5
Successfully tagged p3exporter:latest

Now you can start the container. Here you can use the command from above. You have just to use your image

docker run -d --net="host" --pid="host" -v "/:/host:ro,rslave" p3exporter:latest

Collectors

Name Description
example example collector that actually does nothing but show how long a function has been executed
loadavg collects average load in 1, 5 and 15 minutes interval
netdev collects netword device information and statistics

Activation and Deactivation of collectors

To activate or deactive collectors you have to configure it in p3.yml within the collectors list. All collectors listed in this list will be activated a start time of p3exporter. If there are any issues e.g. collector can't be found or has failures in code a warning will be shown and it will not be activated.

exporter_name: "Python prammable Prometheus exporter"
collectors:
  - example
  - loadavg
  - netdev
collector_opts:
  netdev:
    whitelist:
    blacklist:
      - docker0
      - lo

Metadata

Release files for p3exporter 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for p3exporter 1.2.0
File Size Uploaded
p3exporter-1.2.0.tar.gz 22.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for p3exporter 1.2.0
File Interpreter ABI Platform
p3exporter-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.5 kB

Release files / p3exporter-1.2.0.tar.gz

Download URL p3exporter-1.2.0.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
08f122d7f896f9902ac8b9badd0d2dc5d481ba0acd7f1cc2cc726fe7067e94d5
BLAKE2b-256 checksum
How to use checksums
bb57eaa5898ae5fc470bd9c8e1cd34ee55b3f54b51deda0c55ff15b36f8a39b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / p3exporter-1.2.0-py3-none-any.whl

Download URL p3exporter-1.2.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8ddb1240becc46d7f22c652e3d5cf0778bb6d97b638ed0587810e3639c2256b
BLAKE2b-256 checksum
How to use checksums
9c208d7ee85d9c3d2a7cf846b26a6c94d646f6ed6538ad4685f66479b20ebbd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page