Closed luispabon closed 3 years ago
Do you have
Artprima\PrometheusMetricsBundle\ArtprimaPrometheusMetricsBundle::class => ['all' => true],
in your config/bundles.php
?
As of the docs, you are right, I need to improve them to give more information on what are the default metrics.
Yes, correct. The symfony recipe works fine. It wasn't collecting anything because of my config:
artprima_prometheus_metrics:
namespace: my-api
type: apcu
ignored_routes:
- prometheus_bundle_prometheus
- _wdt
Turns out you cannot use -
on the namespace, but underscore _
instead. After renaming to my_api
it started collecting data and working normally. Would be good to perhaps document this as well as what metrics are being collected.
Hm... Not sure this is the case, will check it, and if it's true, I will add some validation to this parameter.
Anyway, jfyi:
namespace Artprima\PrometheusMetricsBundle\Metrics;
/**
* Class AppMetrics is an implementation of basic metrics collector that is turned on by default.
*
* Collected metrics:
* - requests (per method and route)
* - responses (per method, route and response type)
* - request duration histogram (per method and route)
*/
class AppMetrics implements MetricsGeneratorInterface { /* implementation */ }
This is the default metrics class that is registered automatically (the interface name has a confusing name due to historical reasons; I'm thinking to rename it).
This happens when using hyphen:
php-fpm_1 | [2021-01-06T12:32:46.352799+00:00] app.ERROR: Invalid metric name: 'my-api_instance_name' {"from":"request_collector","class":"Artprima\\PrometheusMetricsBundle\\Metrics\\AppMetrics"} []
php-fpm_1 | [2021-01-06T12:32:46.360506+00:00] app.ERROR: Invalid metric name: 'my-api_http_2xx_responses_total' {"from":"response_collector","class":"Artprima\\PrometheusMetricsBundle\\Metrics\\AppMetrics"} []
Digging some more, the exception is actually thrown from here: https://github.com/PromPHP/prometheus_client_php/blob/master/src/Prometheus/Collector.php#L46
Looks like it's validating the metric name against '/^[a-zA-Z_:][a-zA-Z0-9_:]*$/
Thank you for your investigation! I'll update the bundle in terms of validation and docs. Please don't close the issue for now.
Of course :ok_hand:
Fixed in #34.
Just trying this bundle out now. Upon installation on an api-platorm project via symfony flex recipe, the only output I'm getting from the prometheus endpoint is:
I'm quite confused on what metrics the bundle collects by default (if any), as the docs don't really have anything to say on that particular subject.