hipages / php-fpm_exporter

A prometheus exporter for PHP-FPM.
Apache License 2.0
604 stars 123 forks source link

Using http protocol instead of tcp #97

Closed erfansahaf closed 4 years ago

erfansahaf commented 4 years ago

First of all, thanks for your time and for developing this exporter for the open-source community.

I wish to use php-fpm_exporter alongside my application container by a docker-compose file. My PHP pool status is accessible by http://application/status page, but the exporter can not pull the metrics from this endpoint. The request to the mentioned endpoint will be proxied by Nginx to the fastcgi 127.0.0.1:9000.

location ~ ^/(status)$ {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
    }

I guess there is something wrong with the protocol (that in my case is http) but your examples are all using tcp. When I try to see the exporter container logs, it shows the following error (I tried with the tcp protocol but didn't work either and the phpfpm_up was still 0) :

$ docker-compose logs php-fpm_exporter   

php-fpm_exporter_1  | time="2020-05-16T19:18:26Z" level=info msg="Starting server on :9253 with path /metrics"
php-fpm_exporter_1  | time="2020-05-16T19:18:31Z" level=error msg="dial http: unknown network http"
php-fpm_exporter_1  | time="2020-05-16T19:18:31Z" level=error msg="dial http: unknown network http"
php-fpm_exporter_1  | time="2020-05-16T19:18:31Z" level=debug msg="Updated 1 pool(s) in 7.307171ms"
php-fpm_exporter_1  | time="2020-05-16T19:18:31Z" level=error msg="Error scraping PHP-FPM: dial http: unknown network http"

My docker-compose.yml file:

  application:
   image: my-application:latest
    ports:
      - 3000:80

  php-fpm_exporter:
    image: hipages/php-fpm_exporter
    depends_on:
      - application
    environment:
      - PHP_FPM_SCRAPE_URI=http://application:80/status
      - PHP_FPM_LOG_LEVEL=debug
    ports:
    - 9253:9253
vasekboch commented 4 years ago

You should be connecting directly to the fpm PHP_FPM_SCRAPE_URI=tcp://application:9000/status

erfansahaf commented 4 years ago

@vasekboch When I try to use the TCP protocol as PHP_FPM_SCRAPE_URI=tcp://application:9000/status, it just doesn't work. It shows no error in logs, but the fail metric is always one (instead of being zero).

estahn commented 4 years ago

@erfansahaf As @vasekboch already pointed out correctly you should connect php-fpm_exporter directly to PHP-FPM. You can find docker-compose examples here in the test directory.

My guess is that applications is not exposing the port.

erfansahaf commented 4 years ago

@estahn What is the difference between hipages/php image and the PHP official image? Since application and the php-fpm_exporter are both on the same network, there is no need to exposing port to the outside world, right?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

estahn commented 4 years ago

@estahn What is the difference between hipages/php image and the PHP official image? Since application and the php-fpm_exporter are both on the same network, there is no need to exposing port to the outside world, right?

@erfansahaf Apologies, I haven't seen your comment in my notifications. We had some customisations around NewRelic and things to make it easier to work with.

You don't need to expose the port to the outside world.

erfansahaf commented 4 years ago

Thanks for your response. My problem solved in another way and I didn't use this exporter. Closing it.