{"id":17810071,"url":"https://github.com/butschster/prometheus-parser","last_synced_at":"2025-10-09T08:32:47.400Z","repository":{"id":62609053,"uuid":"560979568","full_name":"butschster/prometheus-parser","owner":"butschster","description":"Prometheus data parser to AST written on PHP8","archived":false,"fork":false,"pushed_at":"2022-12-29T07:44:42.000Z","size":28,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T08:32:16.115Z","etag":null,"topics":["parser","php","php8","prometheus"],"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/butschster.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}},"created_at":"2022-11-02T17:14:43.000Z","updated_at":"2025-02-20T21:30:13.000Z","dependencies_parsed_at":"2023-01-31T08:16:16.280Z","dependency_job_id":null,"html_url":"https://github.com/butschster/prometheus-parser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/butschster/prometheus-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fprometheus-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fprometheus-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fprometheus-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fprometheus-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/butschster","download_url":"https://codeload.github.com/butschster/prometheus-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butschster%2Fprometheus-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001051,"owners_count":26082991,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["parser","php","php8","prometheus"],"created_at":"2024-10-27T15:25:15.104Z","updated_at":"2025-10-09T08:32:47.365Z","avatar_url":"https://github.com/butschster.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prometheus metrics parser for PHP\n\n[![PHP Version Require](https://poser.pugx.org/butschster/prometheus-parser/require/php)](https://packagist.org/packages/butschster/prometheus-parser)\n[![Latest Stable Version](https://poser.pugx.org/butschster/prometheus-parser/v/stable)](https://packagist.org/packages/butschster/prometheus-parser)\n[![phpunit](https://github.com/butschster/prometheus-parser/actions/workflows/phpunit.yml/badge.svg)](https://github.com/butschster/prometheus-parser/actions)\n[![psalm](https://github.com/butschster/prometheus-parser/actions/workflows/psalm.yml/badge.svg)](https://github.com/butschster/prometheus-parser/actions)\n[![Total Downloads](https://poser.pugx.org/butschster/prometheus-parser/downloads)](https://packagist.org/packages/butschster/prometheus-parser)\n\n![Github cover Prometheus parser](https://user-images.githubusercontent.com/773481/199663705-3540ce54-086e-476e-bf91-cd607c98df9f.jpg)\n\nWelcome to the Prometheus Metrics Parser! This package makes it easy to extract valuable information from metrics in the Prometheus text-based format. Whether you're looking to analyze your metrics data, integrate it into other systems, or just want a better way to visualize it, this package has you covered.\n\nWith just a few lines of code, you can easily extract valuable insights from your Prometheus metrics.\n\n## Requirements\n\n- PHP 8.1 and above\n\n## Quick start\n\nTo install the package, run the following command from the root directory of your project:\n\n```shell\ncomposer require butschster/prometheus-parser\n```\n\nThat's it!\n\n\n## Usage\n\nTo get started, simply pass a string containing your Prometheus metric data to the `parse()` method. The method will return a schema object with metric objects, each of which contains the following properties:\n\n```php\nuse Butschster\\Prometheus\\ParserFactory;\n\n$parser = ParserFactory::create();\n\n$schema = $parser-\u003eparse(\u003c\u003c\u003cSCHEMA\n# HELP http_requests_total The total number of HTTP requests.\n# TYPE http_requests_total counter\nhttp_requests_total{method=\"post\",code=\"200\"} 1027 1395066363000\nhttp_requests_total{method=\"post\",code=\"400\"}    3 1395066363000\n\n# Escaping in label values:\nmsdos_file_access_time_seconds{path=\"C:\\\\DIR\\\\FILE.TXT\",error=\"Cannot find file:\\n\\\"FILE.TXT\\\"\"} 1.458255915e9\n\n# Minimalistic line:\nmetric_without_timestamp_and_labels 12.47\n\n# A weird metric from before the epoch:\nsomething_weird{problem=\"division by zero\"} +Inf -3982045\n\n# A histogram, which has a pretty complex representation in the text format:\n# HELP http_request_duration_seconds A histogram of the request duration.\n# TYPE http_request_duration_seconds histogram\nhttp_request_duration_seconds_bucket{le=\"0.05\"} 24054\nhttp_request_duration_seconds_bucket{le=\"0.1\"} 33444\nhttp_request_duration_seconds_bucket{le=\"0.2\"} 100392\nhttp_request_duration_seconds_bucket{le=\"0.5\"} 129389\nhttp_request_duration_seconds_bucket{le=\"1\"} 133988\nhttp_request_duration_seconds_bucket{le=\"+Inf\"} 144320\nhttp_request_duration_seconds_sum 53423\nhttp_request_duration_seconds_count 144320\n\n# Finally a summary, which has a complex representation, too:\n# HELP rpc_duration_seconds A summary of the RPC duration in seconds.\n# TYPE rpc_duration_seconds summary\nrpc_duration_seconds{quantile=\"0.01\"} 3102\nrpc_duration_seconds{quantile=\"0.05\"} 3272\nrpc_duration_seconds{quantile=\"0.5\"} 4773\nrpc_duration_seconds{quantile=\"0.9\"} 9001\nrpc_duration_seconds{quantile=\"0.99\"} 76656\nrpc_duration_seconds_sum 1.7560473e+07\nrpc_duration_seconds_count 2693\n    SCHEMA\n);\n```\n\n### Schema data\n\n```php\n$metrics = $schema-\u003egetMetrics(); // array of Metric\n\n$metrics['http_requests_total']-\u003edescription; // The total number of HTTP requests.\n$metrics['http_requests_total']-\u003etype; // counter\n$metrics['http_requests_total']-\u003ename; // http_requests_total\n\nforeach ($metrics['go_gc_duration_seconds'] as $metric) {\n    $metric-\u003ename; // go_gc_duration_seconds\n    $metric-\u003evalue; // Value\n    $metric-\u003etimestamp; // Timestamp\n    $metric-\u003elables; // Array of labels\n}\n```\n\n# Enjoy!\n\n---\n\n## License\n\nThe MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutschster%2Fprometheus-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbutschster%2Fprometheus-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutschster%2Fprometheus-parser/lists"}