Skip to main content

Python Programmable Prometheus exporter

Project description

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

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

p3exporter-1.2.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

p3exporter-1.2.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file p3exporter-1.2.0.tar.gz.

File metadata

  • Download URL: p3exporter-1.2.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for p3exporter-1.2.0.tar.gz
Algorithm Hash digest
SHA256 08f122d7f896f9902ac8b9badd0d2dc5d481ba0acd7f1cc2cc726fe7067e94d5
MD5 ec0369dd8423cd70206a6952be61f72d
BLAKE2b-256 bb57eaa5898ae5fc470bd9c8e1cd34ee55b3f54b51deda0c55ff15b36f8a39b9

See more details on using hashes here.

File details

Details for the file p3exporter-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: p3exporter-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for p3exporter-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8ddb1240becc46d7f22c652e3d5cf0778bb6d97b638ed0587810e3639c2256b
MD5 888821183ae1e9bd23f7a08f63e468a0
BLAKE2b-256 9c208d7ee85d9c3d2a7cf846b26a6c94d646f6ed6538ad4685f66479b20ebbd7

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