itk-dev/metrics-bundle

Provide metrics for prometheus

Installs: 636

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.0.1 2021-10-19 08:27 UTC

This package is auto-updated.

Last update: 2022-04-21 10:46:04 UTC


README

This bundle is a wrapper for Symfony to make it a little easier to expose metrics for Prometheus.

It has support for exporting Opcache and APCu metrics as well as custom metrics for you application.

Configuration

There are support for storing metrics information in 3 different storage adaptors. The default recommendation is to use Redis as it's persistent across reboots. So you will not miss any data if Prometheus scraper have not collection data.

Default configuration:

itkdev_metrics:
  # Prefix exported metrics (should be application name)
  namespace: ItkDevApp

  # Storage adapter to use
  adapter:
    type: redis # One of "apcu"; "memory"; "redis"

    # Connection options is only used by redis adapter
    options:
      host: 127.0.0.1
      port: 6379
      password: ~

  # Export metrics for these extensions
  extensions:
    opcache: false
    apcu: false

Route

The bundle exposes the route /metrics which can be prefixed by creating a route file under config/routes if the path is already in use.

itkdev_metrics:
  prefix: '/custom/path/prefix'
  resource: '@ItkDevMetricsBundle/Resources/config/routes.xml'

Service

The bundle comes with a single public service MetricsService that can be used to collection custom metrics. It supports the standard metrics support by Prometheus (counter, gauge, histogram). See the function documentation about the different between them and how to use them.

For more information also see: https://prometheus.io/docs/concepts/metric_types/