Skip to main content

FastStream Based Metrics Collection for Prometheus

Project description

FastStream Prometheus Collector

FastStream Based Metrics Collection for Prometheus

PyPI PyPI - Python Version GitLab last commit Docs

Test coverage Downloads GitLab stars

Functionality

  • Collection metrics via middleware
  • Collecting general metrics
  • Collecting details kafka metrics

Installation

pip install faststream-prometheus

Quick start

See example for details

import uvicorn
from fastapi import FastAPI
from faststream.kafka.fastapi import KafkaRouter
from prometheus_fastapi_instrumentator import Instrumentator

# Import Faststream Middleware for collect metrics 
from faststream_prometheus import FaststreamPrometheusMiddleware

# Adding middleware 
faststream_router = KafkaRouter(
    'localhost:9092',
    middlewares=[FaststreamPrometheusMiddleware(prefix='test_faststream')],
)

# Setup export metrics via FastAPI -> HTTP GET /metrics
app = FastAPI(lifespan=faststream_router.lifespan_context)
app.include_router(faststream_router)

instrumentator = Instrumentator().instrument(app, metric_namespace='fastapi').expose(app)
# see default metrics
curl localhost:8000/metrics

Contribute

Issue Tracker: https://gitlab.com/rocshers/python/faststream-prometheus/-/issues
Source Code: https://gitlab.com/rocshers/python/faststream-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

faststream_prometheus-0.1.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

faststream_prometheus-0.1.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file faststream_prometheus-0.1.5.tar.gz.

File metadata

  • Download URL: faststream_prometheus-0.1.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.8.0-40-generic

File hashes

Hashes for faststream_prometheus-0.1.5.tar.gz
Algorithm Hash digest
SHA256 69e200e535577b239215057485ace97d56d853c174e2ff1257de08d528e1277e
MD5 ed42e02d9caa53ee24ac4aea7f79e587
BLAKE2b-256 3bcecabbd854f6cedc55eb4866c3de2f5adf858c786cc7434cd6bb4927edc721

See more details on using hashes here.

File details

Details for the file faststream_prometheus-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for faststream_prometheus-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fc00b21c9da56e5bda96074769e812ee5b7f1e27c2511a265130237ba3138b9f
MD5 4b7e3e21411bb969b1e9ccd32fbc9b28
BLAKE2b-256 b2f48b43941c00d593119c21673620015a523f85274fe0a01f2106d793fec430

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