Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/butschster/prometheus-parser
Prometheus data parser to AST written on PHP8
https://github.com/butschster/prometheus-parser
parser php php8 prometheus
Last synced: 3 months ago
JSON representation
Prometheus data parser to AST written on PHP8
- Host: GitHub
- URL: https://github.com/butschster/prometheus-parser
- Owner: butschster
- License: mit
- Created: 2022-11-02T17:14:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T07:44:42.000Z (about 2 years ago)
- Last Synced: 2024-02-15T07:22:47.845Z (12 months ago)
- Topics: parser, php, php8, prometheus
- Language: PHP
- Homepage:
- Size: 27.3 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Prometheus metrics parser for PHP
[![PHP Version Require](https://poser.pugx.org/butschster/prometheus-parser/require/php)](https://packagist.org/packages/butschster/prometheus-parser)
[![Latest Stable Version](https://poser.pugx.org/butschster/prometheus-parser/v/stable)](https://packagist.org/packages/butschster/prometheus-parser)
[![phpunit](https://github.com/butschster/prometheus-parser/actions/workflows/phpunit.yml/badge.svg)](https://github.com/butschster/prometheus-parser/actions)
[![psalm](https://github.com/butschster/prometheus-parser/actions/workflows/psalm.yml/badge.svg)](https://github.com/butschster/prometheus-parser/actions)
[![Total Downloads](https://poser.pugx.org/butschster/prometheus-parser/downloads)](https://packagist.org/packages/butschster/prometheus-parser)![Github cover Prometheus parser](https://user-images.githubusercontent.com/773481/199663705-3540ce54-086e-476e-bf91-cd607c98df9f.jpg)
Welcome 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.
With just a few lines of code, you can easily extract valuable insights from your Prometheus metrics.
## Requirements
- PHP 8.1 and above
## Quick start
To install the package, run the following command from the root directory of your project:
```shell
composer require butschster/prometheus-parser
```That's it!
## Usage
To 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:
```php
use Butschster\Prometheus\ParserFactory;$parser = ParserFactory::create();
$schema = $parser->parse(<<getMetrics(); // array of Metric
$metrics['http_requests_total']->description; // The total number of HTTP requests.
$metrics['http_requests_total']->type; // counter
$metrics['http_requests_total']->name; // http_requests_totalforeach ($metrics['go_gc_duration_seconds'] as $metric) {
$metric->name; // go_gc_duration_seconds
$metric->value; // Value
$metric->timestamp; // Timestamp
$metric->lables; // Array of labels
}
```# Enjoy!
---
## License
The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.