itk-dev / metrics-bundle
Provide metrics for prometheus
Installs: 6 277
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.1|^8.2|^8.3
- promphp/prometheus_client_php: ^2.2
- symfony/config: ~6.4|~7.0
- symfony/dependency-injection: ~6.4|~7.0
- symfony/framework-bundle: ~6.4|~7.0
- symfony/http-foundation: ~6.4|~7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- vimeo/psalm: ^4.7
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/