{"id":18753232,"url":"https://github.com/kpn/arq-prometheus","last_synced_at":"2025-04-13T00:31:33.900Z","repository":{"id":48160125,"uuid":"516374415","full_name":"kpn/arq-prometheus","owner":"kpn","description":"Prometheus metrics for arq job queues","archived":false,"fork":false,"pushed_at":"2023-08-04T14:19:45.000Z","size":29,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-04T21:09:47.471Z","etag":null,"topics":["async-task","asyncio","prometheus-metrics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kpn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-21T13:04:34.000Z","updated_at":"2024-09-30T21:10:05.000Z","dependencies_parsed_at":"2022-09-14T21:00:57.158Z","dependency_job_id":null,"html_url":"https://github.com/kpn/arq-prometheus","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Farq-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Farq-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Farq-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Farq-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpn","download_url":"https://codeload.github.com/kpn/arq-prometheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650590,"owners_count":21139670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-task","asyncio","prometheus-metrics"],"created_at":"2024-11-07T17:24:55.181Z","updated_at":"2025-04-13T00:31:33.449Z","avatar_url":"https://github.com/kpn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arq-prometheus\n\n![Build status](https://github.com/kpn/arq-prometheus/actions/workflows/test.yaml/badge.svg)\n[![PyPI Package latest release](https://img.shields.io/pypi/v/arq-prometheus.svg?style=flat-square)](https://pypi.org/project/arq-prometheus/)\n[![PyPI Package download count (per month)](https://img.shields.io/pypi/dm/arq-prometheus?style=flat-square)](https://pypi.org/project/arq-prometheus/)\n[![Supported versions](https://img.shields.io/pypi/pyversions/arq-prometheus.svg?style=flat-square)](https://pypi.org/project/arq-prometheus/)\n[![Codecov](https://img.shields.io/codecov/c/github/kpn/arq-prometheus.svg?style=flat-square)](https://codecov.io/gh/kpn/arq-prometheus)\n\n\nPrometheus metrics for [arq](https://github.com/samuelcolvin/arq)\n\n⚠️ WARNING! This is a project in alpha phase ⚠️\n\n## Installation\n\n[Pip](https://pip.pypa.io/en/stable/)\n\n```sh\npip install -U arq-prometheus\n```\n\n[Poetry](https://python-poetry.org/)\n\n```sh\npoetry add arq-prometheus\n```\n\n## Description\n\nThe metrics exposed are the same as the health check.\n\n| Metric name             | Description                      |\n| ----------------------- | -------------------------------- |\n| `arq_jobs_completed`    | The number of jobs completed     |\n| `arq_jobs_failed`       | The total number of errored jobs |\n| `arq_jobs_retried`      | The total number of retried jobs |\n| `arq_ongoing_jobs`      | The number of jobs in progress   |\n| `arq_queued_inprogress` | The number of jobs in progress   |\n\nWhen working with `arq` I found some limitations, it was specially hard to get access to\nthe worker in order to retrieve information like the `queue_name` or `health_check_key`.\nThe startup and shutdown functions only make available a `ctx` with the redis connection.\nThis means that if you provide a custom `queue_name` or `health_check_key`, you will\nalso have to provide them to `ArqPrometheusMetrics`.\n\n## Usage\n\n````python\n# example_worker.py\nfrom arq_prometheus import ArqPrometheusMetrics\n\nasync def startup(ctx):\n    arq_prometheus = ArqPrometheusMetrics(ctx, delay=delay)\n    ctx[\"arq_prometheus\"] = await arq_prometheus.start()\n\nasync def shutdown(ctx):\n    await ctx[\"arq_prometheus\"].stop()\n\nclass WorkerSettings:\n    on_startup = startup\n    on_shutdown = shutdown\n    function = []  # your arq jobs\n    ... # other settings\n\n````\n\nStart your arq worker,\n\n```sh\narq example_worker.WorkerSettings\n```\n\nMake request to `localhost:8081` (or open in browser).\n\n```sh\ncurl localhost:8081\n```\n\n\n## Arguments\n\n- `ctx: dict`: arq context\n- `queue_name: str = default_queue_name`: name of the arq queue\n- `health_check_key: Optional[str] = None`: arq health key\n- `delay: datetime.timedelta = datetime.timedelta(seconds=5)`: a datetime.timedelta\n- `enable_webserver: bool = True`: set to True if you want a web server exposing the metrics\n- `addr: str = \"0.0.0.0\"`: webserver address\n- `port: int = 8081`: webserver port\n- `registry: prom.CollectorRegistry = prom.REGISTRY`: the prometheus registry, usually you do not have to override this","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpn%2Farq-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpn%2Farq-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpn%2Farq-prometheus/lists"}