php-fpm_exporter
php-fpm_exporter copied to clipboard
Access denied when trying to use PHP unix sock
I'm trying to use the docker image hipages/php-fpm_exporter
with docker-compose.
Which user runs the php-fpm exporter
process? I keep seeing this error:
2023-08-25 21:56:59 time="2023-08-25T19:56:59Z" level=error msg="Pool[unix:///socket/fpm/unix.sock]: Access denied.\n"
The permissions for this sock are set to:
/fpm/unix.sock
srw-rw---- 1 2002 web 0 Aug 25 19:28 /socket/fpm/unix.sock
I added the root
user to the web
group, but this didn't solve the problem.
Do you have rights set up on pool?
listen.mode = 0660
(default). I'm using 0666, since I need to flush opcache with library via pipeline and read it, but you should be ok with 0664
Having the same error, but on a Ubuntu 20 machine:
ll /run/php/php8.1-fpm.sock
srw-rw---- 1 www-data www-data 0 Oct 10 13:49 /run/php/php8.1-fpm.sock
sudo -u www-data ./php-fpm-exporter server --phpfpm.scrape-uri=unix:/run/php/php8.1-fpm.sock
INFO[0000] Starting server on :9253 with path /metrics
ERRO[0003] Pool[unix:/run/php/php8.1-fpm.sock]: Access denied.
ERRO[0003] invalid character 'A' looking for beginning of value
ERRO[0003] invalid character 'A' looking for beginning of value
ERRO[0003] Error scraping PHP-FPM: invalid character 'A' looking for beginning of value
but curl seems to respond with a valid result:
curl -L 127.0.0.1:9253/metrics
go_memstats_heap_inuse_bytes 2.760704e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 14270
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 974848
You're missing the path and therefore you're getting the access denied error and incomplete data.
It needs to be like this sudo -u www-data ./php-fpm-exporter server --phpfpm.scrape-uri='unix:/run/php/php8.1-fpm.sock;/status'