Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for collecting metrics from nginx and php-fpm #49

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fcoelho
Copy link
Contributor

@fcoelho fcoelho commented Jul 18, 2024

/srv/deskpro# curl -si localhost:9598/metrics 
HTTP/1.1 200 OK
content-type: text/plain; version=0.0.4
content-length: 4944
date: Fri, 19 Jul 2024 11:11:12 GMT

# HELP nginx_connections_accepted_total connections_accepted_total
# TYPE nginx_connections_accepted_total counter
nginx_connections_accepted_total 2232 1721387451671
# HELP nginx_connections_active connections_active
# TYPE nginx_connections_active gauge
nginx_connections_active 3 1721387451671
# HELP nginx_connections_handled_total connections_handled_total
# TYPE nginx_connections_handled_total counter
nginx_connections_handled_total 2232 1721387451671
# HELP nginx_connections_reading connections_reading
# TYPE nginx_connections_reading gauge
nginx_connections_reading 0 1721387451671
# HELP nginx_connections_waiting connections_waiting
# TYPE nginx_connections_waiting gauge
nginx_connections_waiting 2 1721387451671
# HELP nginx_connections_writing connections_writing
# TYPE nginx_connections_writing gauge
nginx_connections_writing 1 1721387451671
# HELP nginx_http_requests_total http_requests_total
# TYPE nginx_http_requests_total counter
nginx_http_requests_total 3148 1721387451671
# HELP nginx_up up
# TYPE nginx_up gauge
nginx_up 1 1721387451671
# HELP phpfpm_accepted_connections phpfpm_accepted_connections
# TYPE phpfpm_accepted_connections counter
phpfpm_accepted_connections{pool="dp_gql"} 0 1721387451713
phpfpm_accepted_connections{pool="dp_internal"} 39 1721387451727
phpfpm_accepted_connections{pool="dp_default"} 399 1721387451685
phpfpm_accepted_connections{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_active_processes phpfpm_active_processes
# TYPE phpfpm_active_processes gauge
phpfpm_active_processes{pool="dp_gql"} 0 1721387451713
phpfpm_active_processes{pool="dp_internal"} 0 1721387451727
phpfpm_active_processes{pool="dp_default"} 0 1721387451685
phpfpm_active_processes{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_idle_processes phpfpm_idle_processes
# TYPE phpfpm_idle_processes gauge
phpfpm_idle_processes{pool="dp_gql"} 0 1721387451713
phpfpm_idle_processes{pool="dp_internal"} 0 1721387451727
phpfpm_idle_processes{pool="dp_default"} 1 1721387451685
phpfpm_idle_processes{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_listen_queue phpfpm_listen_queue
# TYPE phpfpm_listen_queue gauge
phpfpm_listen_queue{pool="dp_gql"} 0 1721387451713
phpfpm_listen_queue{pool="dp_internal"} 0 1721387451727
phpfpm_listen_queue{pool="dp_default"} 0 1721387451685
phpfpm_listen_queue{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_listen_queue_length phpfpm_listen_queue_length
# TYPE phpfpm_listen_queue_length gauge
phpfpm_listen_queue_length{pool="dp_gql"} 0 1721387451713
phpfpm_listen_queue_length{pool="dp_internal"} 0 1721387451727
phpfpm_listen_queue_length{pool="dp_default"} 0 1721387451685
phpfpm_listen_queue_length{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_max_active_processes phpfpm_max_active_processes
# TYPE phpfpm_max_active_processes counter
phpfpm_max_active_processes{pool="dp_gql"} 0 1721387451713
phpfpm_max_active_processes{pool="dp_internal"} 2 1721387451727
phpfpm_max_active_processes{pool="dp_default"} 1 1721387451685
phpfpm_max_active_processes{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_max_children_reached phpfpm_max_children_reached
# TYPE phpfpm_max_children_reached counter
phpfpm_max_children_reached{pool="dp_gql"} 0 1721387451713
phpfpm_max_children_reached{pool="dp_internal"} 0 1721387451727
phpfpm_max_children_reached{pool="dp_default"} 0 1721387451685
phpfpm_max_children_reached{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_max_listen_queue phpfpm_max_listen_queue
# TYPE phpfpm_max_listen_queue counter
phpfpm_max_listen_queue{pool="dp_gql"} 0 1721387451713
phpfpm_max_listen_queue{pool="dp_internal"} 0 1721387451727
phpfpm_max_listen_queue{pool="dp_default"} 0 1721387451685
phpfpm_max_listen_queue{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_slow_requests phpfpm_slow_requests
# TYPE phpfpm_slow_requests counter
phpfpm_slow_requests{pool="dp_gql"} 0 1721387451713
phpfpm_slow_requests{pool="dp_internal"} 0 1721387451727
phpfpm_slow_requests{pool="dp_default"} 0 1721387451685
phpfpm_slow_requests{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_start_since phpfpm_start_since
# TYPE phpfpm_start_since counter
phpfpm_start_since{pool="dp_gql"} 3982 1721387451713
phpfpm_start_since{pool="dp_internal"} 3982 1721387451727
phpfpm_start_since{pool="dp_default"} 3982 1721387451685
phpfpm_start_since{pool="dp_broadcaster"} 3982 1721387451699
# HELP phpfpm_total_processes phpfpm_total_processes
# TYPE phpfpm_total_processes gauge
phpfpm_total_processes{pool="dp_gql"} 0 1721387451713
phpfpm_total_processes{pool="dp_internal"} 0 1721387451727
phpfpm_total_processes{pool="dp_default"} 1 1721387451685
phpfpm_total_processes{pool="dp_broadcaster"} 0 1721387451699
# HELP phpfpm_up phpfpm_up
# TYPE phpfpm_up gauge
phpfpm_up{pool="dp_gql"} 1 1721387451713
phpfpm_up{pool="dp_internal"} 1 1721387451727
phpfpm_up{pool="dp_default"} 1 1721387451685
phpfpm_up{pool="dp_broadcaster"} 1 1721387451699

@fcoelho fcoelho force-pushed the add-metrics branch 4 times, most recently from 07ed5ea to ae5ae7c Compare July 19, 2024 11:21
@fcoelho fcoelho marked this pull request as ready for review July 19, 2024 14:32
"http://localhost:10001/fpm/dp_broadcaster/status?openmetrics",
"http://localhost:10001/fpm/dp_gql/status?openmetrics",
"http://localhost:10001/fpm/dp_internal/status?openmetrics",
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you are relying on the backlog count to be accurate here but AFAIK, the backlog count always returns 0 (https://bugs.php.net/bug.php?id=80739) - or at least it certainly did up until PHP 8.1.
I've had to use this command in a loop if I actively wanted to monitor the backlog status: ss -ln | grep "/run/php_fpm_dp" | grep -v status | awk '{print "["$3"]: "$5}'

[0]: /run/php_fpm_dp_default.sock
[0]: /run/php_fpm_dp_internal.sock
[0]: /run/php_fpm_dp_gql.sock
[0]: /run/php_fpm_dp_broadcaster.sock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't aware of that, thanks

the metrics I have immediate use for are mostly the number of active/idle/total processes (even though it seems like this number may not be always accurate: php/php-src#14212)


{{if getenv "METRICS_ENABLED" "false"}}
[sinks.metrics_prometheus_exporter]
type = "prometheus_exporter"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need more options here? i.e. address, auth, etc.

@fcoelho fcoelho marked this pull request as draft August 2, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants