Socket
Socket
Sign inDemoInstall

arq-prometheus

Package Overview
Dependencies
2
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arq-prometheus

Prometheus metrics for arq job queues


Maintainers
1

Readme

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 nameDescription
arq_jobs_completedThe number of jobs completed
arq_jobs_failedThe total number of errored jobs
arq_jobs_retriedThe total number of retried jobs
arq_ongoing_jobsThe number of jobs in progress
arq_queued_inprogressThe 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

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc