{"id":15293877,"url":"https://github.com/zlodes/php-prometheus-client-laravel","last_synced_at":"2025-04-13T14:08:43.489Z","repository":{"id":165281115,"uuid":"637359568","full_name":"zlodes/php-prometheus-client-laravel","owner":"zlodes","description":"Laravel adapter for zlodes/php-prometheus-client","archived":false,"fork":false,"pushed_at":"2025-03-30T14:54:10.000Z","size":99,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:08:32.747Z","etag":null,"topics":["hacktoberfest","laravel","laravel-framework","prometheus-client","prometheus-exporter","prometheus-metrics"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/zlodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-07T10:13:33.000Z","updated_at":"2025-03-30T14:54:14.000Z","dependencies_parsed_at":"2024-01-02T13:37:14.274Z","dependency_job_id":"b9e960c9-25c6-4bdb-97d7-8c377466c868","html_url":"https://github.com/zlodes/php-prometheus-client-laravel","commit_stats":null,"previous_names":["zlodes/php-prometheus-client-laravel","zlodes/php-prometheus-exporter-laravel"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlodes%2Fphp-prometheus-client-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlodes%2Fphp-prometheus-client-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlodes%2Fphp-prometheus-client-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlodes%2Fphp-prometheus-client-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zlodes","download_url":"https://codeload.github.com/zlodes/php-prometheus-client-laravel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724629,"owners_count":21151561,"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":["hacktoberfest","laravel","laravel-framework","prometheus-client","prometheus-exporter","prometheus-metrics"],"created_at":"2024-09-30T16:53:33.850Z","updated_at":"2025-04-13T14:08:43.463Z","avatar_url":"https://github.com/zlodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Prometheus Exporter for Laravel\n\n[![codecov](https://codecov.io/gh/zlodes/php-prometheus-client-laravel/branch/master/graph/badge.svg?token=JYPUW0UYT5)](https://codecov.io/gh/zlodes/php-prometheus-client-laravel)\n\nThis is a Laravel adapter/bridge package for [zlodes/prometheus-client](https://github.com/zlodes/php-prometheus-client).\n\n## First steps\n\n### Installation \n\n```shell\ncomposer require zlodes/prometheus-client-laravel\n```\n\n### Register a route for the metrics controller\n\nYour application is responsible for metrics route registration. \nThere is a [controller](src/Http/MetricsExporterController.php) ready to use. \nYou can configure groups, middleware or prefixes as you want.\n\nExample:\n\n```php\nuse Illuminate\\Support\\Facades\\Route;\nuse Zlodes\\PrometheusClient\\Laravel\\Http\\MetricsExporterController;\n\nRoute::get('/metrics', MetricsExporterController::class);\n```\n\n### Configure Storage for metrics [optional]\n\nBy default, it uses Redis storage. \nIf you want to use other storage, you can do it easily following these three steps:\n\n1. Create a class implements `Storage` interface.\n2. Publish a config:\n   ```shell\n   php artisan vendor:publish --tag=prometheus-client\n   ```\n3. Set your `storage` class in the config.\n\n\n## Metrics registration\n\nIn your `ServiceProvider::register`:\n```php\n$this-\u003ecallAfterResolving(Registry::class, static function (Registry $registry): void {\n   $registry\n       -\u003eregisterMetric(\n           new Counter('dummy_controller_hits', 'Dummy controller hits count')\n       )\n       -\u003eregisterMetric(\n           new Gauge('laravel_queue_size', 'Laravel queue length by Queue')\n       );\n});\n```\n\n## Metrics Collector usage\n\nYou can work with your metrics whenever you want. Just use `Collector`: \n\n```php\nuse Zlodes\\PrometheusClient\\Collector\\CollectorFactory;\n\nclass DummyController\n{\n    public function __invoke(CollectorFactory $collector)\n    {\n         $collector-\u003ecounter('dummy_controller_hits')-\u003eincrement();\n    }\n}\n```\n\n## Schedulable collectors\n\nAt times, there may be a need to gather metrics on a scheduled basis. The package offers a feature to register a SchedulableCollector that executes every minute using the Laravel Scheduler.\n\nYou can define your `SchedulableCollectors` using a [config](config/prometheus-exporter.php) or register it in SchedulableCollectorRegistry directly in a `ServiceProvider`:\n\n```php\n$this-\u003ecallAfterResolving(\n   SchedulableCollectorRegistry::class,\n   static function (SchedulableCollectorRegistry $schedulableCollectorRegistry): void {\n       $schedulableCollectorRegistry-\u003epush(YourSchedulableCollector::class);\n   }\n);\n```\n\n\u003e **Note**\n\u003e For further details, see [zlodes/prometheus-client](https://github.com/zlodes/php-prometheus-client)\n\n### Available console commands\n\n| Command                     | Description                                    |\n|-----------------------------|------------------------------------------------|\n| `php artisan metrics:list`  | Lists all registered metrics                   |\n| `php artisan metrics:clear` | Clears metrics storage                         |\n| `metrics:collect-scheduled` | Runs `ScheduledCollectors`. Using by Scheduler |\n\n## Upgrade guide\n\n### From 1.x to 2.x\n\n1. Run `php artisan vendor:publish --tag=prometheus-client` to publish a brand-new config\n2. Configure the new config based on the previous one (`prometheus-exporter.php`)\n3. Drop legacy config (`prometheus-exporter.php`)\n\n## Testing\n\n### Run tests\n\n```shell\nphp ./vendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlodes%2Fphp-prometheus-client-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzlodes%2Fphp-prometheus-client-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlodes%2Fphp-prometheus-client-laravel/lists"}