Skip to main content

Prometheus metrics for arq job queues

Project description

Arq-prometheus

Build status PyPI Package latest release PyPI Package download count (per month) Supported versions Codecov

Prometheus metrics for arq

⚠️ WARNING! This is a project in alpha phase ⚠️

Installation

Pip

pip install -U arq-prometheus

Poetry

poetry add arq-prometheus

Description

The metrics exposed are the same as the health check.

Metric name Description
arq_jobs_completed The number of jobs completed
arq_jobs_failed The total number of errored jobs
arq_jobs_retried The total number of retried jobs
arq_ongoing_jobs The number of jobs in progress
arq_queued_inprogress The number of jobs in progress

When working with arq I found some limitations, it was specially hard to get access to the worker in order to retrieve information like the queue_name or health_check_key. The startup and shutdown functions only make available a ctx with the redis connection. This means that if you provide a custom queue_name or health_check_key, you will also have to provide them to ArqPrometheusMetrics.

Usage

# example_worker.py
from arq_prometheus import ArqPrometheusMetrics

async def startup(ctx):
    arq_prometheus = ArqPrometheusMetrics(ctx, delay=delay)
    ctx["arq_prometheus"] = await arq_prometheus.start()

async def shutdown(ctx):
    await ctx["arq_prometheus"].stop()

class WorkerSettings:
    on_startup = startup
    on_shutdown = shutdown
    function = []  # your arq jobs
    ... # other settings

Start your arq worker,

arq example_worker.WorkerSettings

Make request to localhost:8081 (or open in browser).

curl localhost:8081

Arguments

  • ctx: dict: arq context
  • queue_name: str = default_queue_name: name of the arq queue
  • health_check_key: Optional[str] = None: arq health key
  • delay: datetime.timedelta = datetime.timedelta(seconds=5): a datetime.timedelta
  • enable_webserver: bool = True: set to True if you want a web server exposing the metrics
  • addr: str = "0.0.0.0": webserver address
  • port: int = 8081: webserver port
  • registry: prom.CollectorRegistry = prom.REGISTRY: the prometheus registry, usually you do not have to override this

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

arq_prometheus-0.3.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

arq_prometheus-0.3.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file arq_prometheus-0.3.0.tar.gz.

File metadata

  • Download URL: arq_prometheus-0.3.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

File hashes

Hashes for arq_prometheus-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2a4f21543150390170ffb484d9c959e92eb6977859fdf61d4afe8fbc0433954e
MD5 6a815bad172eca2cf4edc9efd8c165a2
BLAKE2b-256 ebf32a052bede18cfba7308bde19be21f9e4b002c8a97d2435127fb175d75450

See more details on using hashes here.

File details

Details for the file arq_prometheus-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: arq_prometheus-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

File hashes

Hashes for arq_prometheus-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea19b1fe9d547a757e410496bed34f03f26a2c6c259c6ece76145d331ece80e3
MD5 a17f2d2928f699dd383b8bfde077faef
BLAKE2b-256 00a9376d34a65805b62b0467c45cbac4f0978cf8ee4ef5a4d2ba638042c3dcfc

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