2017 © Pedro Peláez
 

library prometheus-bundle

Symfony bundle for Prometheus client

image

tweedegolf/prometheus-bundle

Symfony bundle for Prometheus client

  • Thursday, September 28, 2017
  • by rnijveld
  • Repository
  • 3 Watchers
  • 5 Stars
  • 4,718 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 5 Versions
  • 56 % Grown

The README.md

TweedeGolfPrometheusBundle

A Symfony bundle for the tweede golf prometheus client. For more information on Prometheus you can check their website., (*1)

Installation and configuration

Using Composer add the bundle to your dependencies using the require command:, (*2)

composer require tweedegolf/prometheus-bundle

Add the bundle to your AppKernel

Add the bundle in your app/AppKernel.php:, (*3)

public function registerBundles()
{
    return array(
        // ...
        new TweedeGolf\PrometheusBundle\TweedeGolfPrometheusBundle(),
        // ...
    );
}

Configure storage, collectors and routes

To allow prometheus to scrape your metrics from your application, make sure you make a route available for the prometheus metrics controller:, (*4)

tweede_golf_prometheus:
    resource: "@TweedeGolfPrometheusBundle/Resources/config/routing.yml"
    prefix: /

You can also implement your own controller, take a look at the source code of TweedeGolf\PrometheusBundle\Controller\MetricsController::metricsAction. You can configure some aspects of the prometheus client using the configuration, the default values are shown below:, (*5)

tweede_golf_prometheus:
    storage_adapter_service: TweedeGolf\PrometheusClient\Storage\ApcuAdapter
    metrics_path: /metrics
    make_memory_adapter: true
    register_defaults: true
    collectors: ~

To adjust, create a section tweede_golf_prometheus in your config.yml. You may specify any number of collectors. An example where four different collectors are defined is shown below:, (*6)

tweede_golf_prometheus:
    collectors:
        requests:
            counter:
                labels: [url]
                help: Number of requests
        throughput:
            gauge:
                labels: [url]
                help: Throughput per url
                initializer: 10.0
        response_timing:
            histogram:
                labels: [url]
                help: Response timings
                buckets: [0.1, 0.2, 0.3, 0.5, 0.7, 1, 2, 5, 10, 30, 60]
        shorthand_example:
            counter: ~

Modifying (incrementing/observing/setting) metrics

To modify a metric, retrieve it via the CollectorRegistry service and call one of the type specific metric modification methods., (*7)

use TweedeGolf\PrometheusClient\CollectorRegistry;

public function exampleAction()
{
    $metric = $this->get(CollectorRegistry::class)->getCounter('requests');
    $metric->inc();
}

Register a collector service

You can also register services as collectors with the collector registry. To do this, add a tweede_golf_prometheus.collector tag to your service and make sure the service implements the CollectorInterface. You can also use the factory methods of the registry service:, (*8)

services:
    example.collector.test:
        class: TweedeGolf\PrometheusClient\Collector\Counter
        factory: TweedeGolf\PrometheusClient\CollectorRegistry:createCounter
        arguments: [test]
        tags: [tweede_golf_prometheus.collector]

The Versions

28/09 2017

dev-master

9999999-dev

Symfony bundle for Prometheus client

  Sources   Download

MIT

The Requires

 

by Ruben Nijveld

28/09 2017

v0.2.2

0.2.2.0

Symfony bundle for Prometheus client

  Sources   Download

MIT

The Requires

 

by Ruben Nijveld

22/09 2017

v0.2.1

0.2.1.0

Symfony bundle for Prometheus client

  Sources   Download

MIT

The Requires

 

by Ruben Nijveld

21/09 2017

v0.2.0

0.2.0.0

Symfony bundle for Prometheus client

  Sources   Download

MIT

The Requires

 

by Ruben Nijveld

06/07 2017

v0.1.0

0.1.0.0

Symfony bundle for Prometheus client

  Sources   Download

MIT

The Requires

 

by Ruben Nijveld