Closed b2p-fred closed 2 years ago
To generate the default metrics, you first need to visit any non-ignored route
I still did opened several non-ignored routes. I also ran all my automatic tests.
My application has only one Twig templated page and a JSON API I implemented with api-platform. Whatever the requests I am doing the metrics page is always the same... only a php_info :(
Note, that you use in_memory storage type. It's only to be used in tests. You should switch to redis or to apcu.
I was aware of this. Do you think it may cause my lack of metrics ? I will give a try with redis...
I changed my configuration to :
artprima_prometheus_metrics:
namespace: mymetrics
# metrics backend
storage:
# # DSN of the storage. All parsed values will override explicitly set parameters. Ex: redis://127.0.0.1?timeout=0.1
# url: ~
# Known values: in_memory, apcu, apcng, redis
type: redis
# Available parameters used by redis
host: redis
port: 6379
timeout: 0.1
read_timeout: 10
persistent_connections: false
password: ~
database: 1 # Int value used by redis adapter
prefix: epr # String value used by redis and apcu
# A variable parameter to define additional options as key / value.
options:
foo: bar
ignored_routes:
- prometheus_bundle_prometheus
- _wdt
# used to disable default application metrics
disable_default_metrics: false
# used to disable default metrics from promphp/prometheus_client_php
disable_default_promphp_metrics: false
# used to enable console metrics
enable_console_metrics: true
and now I have a bunch of metrics!
When I switch back to the in_memory
storage there is only php_info ...
As I said in_memory
is not meant to be used in the real applications (unless you run php as a daemon, which is rarely the case). It will be flushed out with every http-request.
The memory storage is not shared. The controller could not have access to the metrics set by a different process.
IMHO, perhaps you should not define the in_memory
as the default configuration and you should raise an alert about this in the README ;)
Thanks for your replies
Some more information to help understanding missing metrics ...
Almost all the tests I ran are based on Phpunit or behat and they use a "simulated" browser client ... and as soon as I use a "real" client all the counters for all the routes are updated !
Just after a fresh install, I configured as:
and I only get:
when I request on
http://localhost:8000/metrics/prometheus
I expected to have, at minimum, the metrics listed in your example in the README.md:
Any idea of a misconfiguration ?