Troubleshoot
Find your symptom below. Each section lists the checks in the order to run them.
Most fixes change a variable in .env. After each change, run php artisan config:cache if the configuration is cached, and restart the queue workers.
/metrics answers 404
Section titled “/metrics answers 404”-
The route is off. Set
METRICS_PROMETHEUS=true. The route is off by default. -
Metrics are off. With
METRICS_ENABLED=false, the route is not registered. Check withphp artisan config:show metrics. -
The routes are cached. With cached routes, the package does not register the route itself. After you change
METRICS_PROMETHEUSorMETRICS_PROMETHEUS_PATH, runphp artisan config:cache, thenphp artisan route:cache. The route cache is built from the cached configuration. -
The path is another one. Check
METRICS_PROMETHEUS_PATH, and look for the route:Terminal window php artisan route:list --name=metrics.prometheus
/metrics answers 503
Section titled “/metrics answers 503”The store cannot be built or read. The cause is reported through the exception handler, so look in the application log.
-
Unknown driver.
METRICS_STOREmust beredisorcache. The log saysUnknown metrics store driver. -
Redis is unreachable. Check the connection in
METRICS_REDIS_CONNECTION:Terminal window php artisan tinker --execute="Redis::connection(config('metrics.store.connection'))->ping()" -
A phpredis cluster connection. It is not supported. The log says
The metrics store needs a phpredis or predis connection. Use a connection to one Redis instance. -
A cache driver without locks. With
METRICS_STORE=cache, the cache store must support locks.apcdoes not.
/metrics answers, but shows nothing
Section titled “/metrics answers, but shows nothing”- Metrics are off, and the route is your own or cached. With
METRICS_ENABLED=false, every export is empty, even if the store still holds values. - Nothing was recorded yet. Send a request to another route, then scrape again. With
ignore_routes, ignored routes record nothing. - The web servers write to another store. Compare
METRICS_STORE,METRICS_REDIS_CONNECTIONandMETRICS_PREFIXof the process that records and the process that answers the scrape. - The cache store uses the
arraydriver. It keeps the store for one process only. Usefile,databaseorredis. See Develop without Redis. - The store could not be built in the recording process. That process records nothing and reports the error once. Look in the log.
A metric is missing
Section titled “A metric is missing”- Its instrumentation is off. Check
METRICS_HTTP,METRICS_DB,METRICS_ELOQUENT,METRICS_QUEUE,METRICS_CACHE,METRICS_SCHEDULER,METRICS_EXCEPTIONS,METRICS_RUNTIME,METRICS_DB_SERVERandMETRICS_MIGRATIONS. - A filter leaves it out. Look for
Metrics::exclude()calls. - The event never happens. Each built-in metric has cases it does not record, such as failed queries or unreported exceptions. See the page of the metric under Built-in metrics.
- The command or daemon has not ended. A long command merges when it ends. Call
Metrics::flush(). See Flush in long-running work. - OPcache metrics in
metrics:push. OPcache is off on the command line by default, so a push has no OPcache metrics. Scrape over the web server to get them.
metrics:push exits with 1
Section titled “metrics:push exits with 1”The command prints the cause.
The metrics store cannot be read: see /metrics answers 503. The causes are the same.The OTLP endpoint did not accept the metrics:- Check the URL. The package appends
/v1/metrics, soOTEL_EXPORTER_OTLP_ENDPOINTmust not end with it. - Check that the endpoint speaks OTLP over HTTP, usually port 4318. Port 4317 is gRPC, which the package does not send.
- Check the protocol. Some backends accept only
http/protobuf, the default. - Check the headers in
metrics.push.headers, such as the API key. - Check the timeout,
metrics.push.timeout, 10 seconds by default.
- Check the URL. The package appends
The OTLP exporter logs the reason, such as the HTTP status, through the OpenTelemetry logger: the PHP error log by default, not the Laravel log.
“Set metrics.push.endpoint (OTEL_EXPORTER_OTLP_ENDPOINT) to push metrics.”
Section titled ““Set metrics.push.endpoint (OTEL_EXPORTER_OTLP_ENDPOINT) to push metrics.””metrics:push has something to send but no endpoint.
- Set
OTEL_EXPORTER_OTLP_ENDPOINTin.env. - If the configuration is cached, run
php artisan config:cacheagain. A cached configuration does not read.env. - Check that the scheduler process has the variable, for example in its container or its systemd unit.
Counters reset
Section titled “Counters reset”Backends show a reset when the store starts again from empty. Look for one of these:
- Redis evicted keys. The store’s Redis must have
maxmemory-policy noeviction. Check withredis-cli CONFIG GET maxmemory-policy. - Redis restarted without persistence. Turn on RDB or AOF persistence on the store’s Redis.
- Someone cleared it.
FLUSHDBorFLUSHALLon that Redis clear the store. With thecachestore,php artisan cache:clearon its cache store does too. - The prefix or the connection changed. A new
METRICS_PREFIXor another Redis starts an empty store.
Rate functions, such as rate() in Prometheus, handle a reset.
Values come from one server only
Section titled “Values come from one server only”- The servers write to different stores. Give every server the same Redis,
REDIS_PREFIXandMETRICS_PREFIX. See Run several applications on one Redis. - The cache store uses the
filedriver. Each server then has its own file. Use theredisstore in production. - It is a metric read on export. OPcache, PHP-FPM, load average and disk usage describe the server that answers the export. This is expected.
Values show twice as high
Section titled “Values show twice as high”Prometheus scrapes more than one address. Every address serves the same store, so a sum across targets counts each value once per target. Scrape one address only. See Scrape with Prometheus.
Warnings in the PHP error log
Section titled “Warnings in the PHP error log”A merge that fails writes a warning through the OpenTelemetry logger. By default, it goes to the PHP error log. The request goes on, and the metrics of that merge are lost.
- Redis is unreachable or slow. Check the store’s Redis, as for /metrics answers 503.
- The cache store waited for its lock. A flush that waits more than 1 second for the lock is dropped. Use the
redisstore under load. - A phpredis cluster connection. It is not supported.
A series has otel_metric_overflow="true"
Section titled “A series has otel_metric_overflow="true"”A metric reached the cardinality limit: 2000 series by default. Every new attribute set now goes to one overflow series.
-
Find the attribute with many values. In Prometheus:
count by (__name__) ({__name__=~".+", otel_metric_overflow="true"})Then count the values of each label of that metric, for example:
count(count by (http_route) (http_server_request_duration_seconds_count)) -
Bound the attribute. Replace IDs, URLs or user input with a value from a small set. For a built-in attribute, override it with
Metrics::attributes(). See Add attributes to built-in metrics. -
If the values are legitimate, raise
cardinality_limitinconfig/metrics.php.
The overflow series and the old series stay in the store until it is cleared.