Skip to main content

Module for exporting monitoring values for Prometheus

Project description

Faust Prometheus Exporter

Module for exporting monitoring values for Prometheus

PyPI PyPI - Python Version GitLab last commit

Test coverage Downloads GitLab stars

Functionality

  • Adds /metrics endpoint
  • Gives basic Prometheus-client metrics
  • Gives custom user`s metrics
  • Adds internal faust metrics

Installation

pip install faust-prometheus-exporter

Quick start

import faust
from faust_prometheus import FaustPrometheusExporter

app = faust.App('app', broker='localhost:9092')

# Adding the Prometheus Exporter
exporter = FaustPrometheusExporter(app)
# see default metrics
curl localhost:8000/metrics

Playground

import logging
from random import randint

import faust
from prometheus_client import Counter, Histogram

from faust_prometheus import FaustPrometheusExporter

logger = logging.getLogger('app')

# Prometheus custom metrics
prometheus_counter_topic_1_messages = Counter('topic_1_messages', 'Count of messages successfully processed from topic_1')
prometheus_histogram_size_messages = Histogram('size_messages', 'Histogram about messages size')

app = faust.App(
    'faust_prometheus',
    broker='localhost:9092',
)

# Adding the Prometheus Exporter
exporter = FaustPrometheusExporter(app)

topic_1 = app.topic('topic_1')

@app.agent(topic_1)
async def agent_topic_1(messages: faust.Stream[str]):
    async for message in messages:
        logger.info(f'Received topic_1 message: {message}')
        prometheus_counter_topic_1_messages.inc()
        prometheus_histogram_size_messages.observe(len(message))

@app.timer(interval=1.0)
async def example_sender(app):
    await topic_1.send(value='Nisi lorem ullamco veniam elit' * randint(1, 10))

if __name__ == '__main__':
    app.main()

Contribute

Issue Tracker: https://gitlab.com/rocshers/python/faust-prometheus/-/issues
Source Code: https://gitlab.com/rocshers/python/faust-prometheus

Before adding changes:

make install-dev

After changes:

make format test

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faust_prometheus_exporter-0.1.2a2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file faust_prometheus_exporter-0.1.2a2.tar.gz.

File metadata

  • Download URL: faust_prometheus_exporter-0.1.2a2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/5.15.0-83-generic

File hashes

Hashes for faust_prometheus_exporter-0.1.2a2.tar.gz
Algorithm Hash digest
SHA256 63d13f3c85b217bdbdedc4d1ae528da14bfd0d51027d104e42ac9c2a0869fb25
MD5 e9f43ecd19e81392b31deb1bdb5fc024
BLAKE2b-256 8386a808b8ac8e45e5def7254c802cb03e41609b962cf7eeb9c31fbd18e1ddd8

See more details on using hashes here.

File details

Details for the file faust_prometheus_exporter-0.1.2a2-py3-none-any.whl.

File metadata

File hashes

Hashes for faust_prometheus_exporter-0.1.2a2-py3-none-any.whl
Algorithm Hash digest
SHA256 b64a0d84c4e5bdffac52cf8e70b7dd2c71358589f9e955154ef3d82b4b8c9129
MD5 320903968e77b9a8c2bc73496404b24b
BLAKE2b-256 b7a93c9cd2e18a746613fe98737a3db4e6feeb57641cb74aa84446ca7889a5b5

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