{"id":17347652,"url":"https://github.com/cryptiklemur/async-prometheus-client","last_synced_at":"2025-06-12T13:41:41.299Z","repository":{"id":142597736,"uuid":"170650445","full_name":"cryptiklemur/async-prometheus-client","owner":"cryptiklemur","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-29T18:43:50.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T15:45:18.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptiklemur.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-02-14T07:54:02.000Z","updated_at":"2019-03-29T18:43:49.000Z","dependencies_parsed_at":"2024-03-12T06:08:14.057Z","dependency_job_id":"12d0ff8f-4608-4d98-93f4-6a1489083ec4","html_url":"https://github.com/cryptiklemur/async-prometheus-client","commit_stats":null,"previous_names":["cryptiklemur/async-prometheus-client"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fasync-prometheus-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fasync-prometheus-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fasync-prometheus-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fasync-prometheus-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptiklemur","download_url":"https://codeload.github.com/cryptiklemur/async-prometheus-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245832747,"owners_count":20679702,"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":[],"created_at":"2024-10-15T16:49:40.999Z","updated_at":"2025-03-27T11:20:41.504Z","avatar_url":"https://github.com/cryptiklemur.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Async Node.JS Prometheus Client\n[![Build Status](https://travis-ci.org/aequasi/async-prometheus-client.svg?branch=master)](https://travis-ci.org/aequasi/async-prometheus-client) [![codecov](https://codecov.io/gh/aequasi/async-prometheus-client/branch/master/graph/badge.svg)](https://codecov.io/gh/aequasi/async-prometheus-client)\n\nThis library was built to allow for asynchronous metric tracking. This mostly just means that it was built in order to \nuse Redis as a registry.\n\nThe specific use case this was created for, was tracking metrics on Zeit.co's Now v2 platform, without using a PushGateway.\n\n### How does it work?\n\nNormally, NodeJS process are long running, and share memory. With the advent of serverless frameworks and technologies,\nNodeJS apps are starting to scale across multiple processes and \"servers\". This can be\nproblematic for metric tracking and Prometheus, as you need to set it up to scrape\na particular endpoint. You might not always know what the direct endpoint is!\n\nSome might suggest using a PushGateway, but this comes with its own list of problems to solve.\n\nThis solution was heavily inspired (pretty much a clone) from the [PHP library](https://github.com/Jimdo/prometheus_client_php).\n \n### Usage\n\n##### Create your registry:\n\n```typescript\nimport {Registry, RedisAdapter} from 'async-prometheus-client'\nimport {createClient} from 'redis';\n\n// By default, this will use an In Memory registry\nconst registry = Registry.getDefault();\n// Or, a Redis one!\nconst registry = new Registry(new RedisAdapter(createClient()));\n```\n\n##### Create some metrics\n\n```typescript\nconst counter = registry.getOrRegisterCounter({\n    namespace: 'test',\n    name: 'some_counter',\n    help: 'it increases',\n    labels: ['type'],\n});\nawait counter.inc('blue');\nawait counter.incBy(3, 'green');\n\nconst gauge = registry.getOrRegisterGauge({\n    namespace: 'test',\n    name: 'some_gauge',\n    help: 'it sets',\n    labels: ['type'],\n})\nawait gauge.set(2.5, ['blue']);\nawait gauge.inc(['green']);\n\nconst histogram = registry.getOrRegisterHistogram({\n    namespace: 'test',\n    name: 'some_histogram',\n    help: 'it observers',\n    labels: ['type'],\n    buckets: [0.1, 1, 2, 3.5, 4, 5, 6, 7, 8, 9],\n})\nhistogram.observe(3.5, ['blue']);\n```\n\n##### Expose the metrics\n\n```typescript\nimport {Renderer} from 'async-prometheus-client';\n\napp.get('/metrics', async (req, res) =\u003e {\n    res.set('Content-Type', Renderer.MIME_TYPE);\n    \n    res.send(await Renderer.render(registry));\n})\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fasync-prometheus-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptiklemur%2Fasync-prometheus-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fasync-prometheus-client/lists"}