Download the PHP package ns3777k/prometheus-bundle without Composer
On this page you can find all versions of the php package ns3777k/prometheus-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ns3777k/prometheus-bundle
More information about ns3777k/prometheus-bundle
Files in ns3777k/prometheus-bundle
Package prometheus-bundle
Short Description Symfony bundle for collecting and exposing prometheus metrics
License MIT
Informations about the package prometheus-bundle
Prometheus bundle
Requirements
- PHP 7.3+
- Symfony 4+
Installing
There are 2 ways to install the bundle: automatically with flex or manually.
Using symfony flex
Manually
-
Require the package:
-
Register the bundle in
config/bundles.php
: - Configure (see below)
Usage
Configuration
config/packages/ns3777k_prometheus.yaml
:
To register the metrics route, add to config/routes.yaml
:
or:
Builtin listener
By default the listener is turned on and collects only one histogram with
request duration in seconds (request_duration_seconds
) with 3 labels: code
,
method
and route
.
Histogram creates total
and count
metrics automatically.
Usually you don't wanna collect the metrics for routes like _wdt
and metrics
(that's the route for /metrics
) and that's where listener.ignored_routes
comes in.
Common PromQL queries for the listener:
-
HTTP Request Rate
-
HTTP Successful Responses
-
HTTP Failed Responses
- HTTP Success Response Time 5m 95p
Collect own metrics
Builtin listener covers only basic information about the request and response. You can use it to get top 10 requests, slow responses, calculate request rate and etc.
But most of the time you wanna collect your own metrics. It's easy to do using
CollectorRegistryInterface
(implemented by NamespacedCollectorRegistry
).
Histogram example:
No worries about the namespace. It will be prepended automatically from the bundle's configuration.
Security
Remember that when you add /metrics
route it becomes publicly available from
the internet.
It's you job to restrict access to it (using nginx for example).
All versions of prometheus-bundle with dependencies
endclothing/prometheus_client_php Version ^1.0
php Version ^7.1
symfony/config Version ^4.3.0|^5.0.0
symfony/dependency-injection Version ^4.3.0|^5.0.0