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

New PHP-FPM metricbeat module #3415

Merged
merged 10 commits into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions metricbeat/_meta/beat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ metricbeat.modules:
# Path to server status. Default server-status
#server_status_path: "server-status"

#------------------------------- php_fpm Module ------------------------------
- module: php_fpm
metricsets: ["pool"]
enabled: true
period: 10s
hosts: ["localhost"]


#----------------------------- PostgreSQL Module -----------------------------
#- module: postgresql
#metricsets:
Expand Down
8 changes: 8 additions & 0 deletions metricbeat/_meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ metricbeat.modules:
period: 10s
processes: ['.*']

#------------------------------- php_fpm Module ------------------------------
- module: php_fpm
metricsets: ["pool"]
enabled: true
period: 10s
hosts: ["localhost"]



245 changes: 245 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ grouped in the following categories:
* <<exported-fields-mongodb>>
* <<exported-fields-mysql>>
* <<exported-fields-nginx>>
* <<exported-fields-php_fpm>>
* <<exported-fields-postgresql>>
* <<exported-fields-prometheus>>
* <<exported-fields-redis>>
Expand Down Expand Up @@ -3802,6 +3803,250 @@ type: long
The current number of idle client connections waiting for a request.


[[exported-fields-php_fpm]]
== php_fpm Fields

PHP-FPM server status metrics collected from PHP-FPM.



[float]
== php_fpm Fields

`php_fpm` contains the metrics that were obtained from PHP-FPM status page call.



[float]
== pool Fields

`pool` contains the metrics that were obtained from the PHP-FPM process pool.



[float]
=== php_fpm.pool.pool

type: keyword

The name of the pool.


[float]
=== php_fpm.pool.process_manager

type: keyword

`static`, `dynamic` or `ondemand`.


[float]
=== php_fpm.pool.start_time

type: long

The date and time FPM has started.


[float]
=== php_fpm.pool.start_since

type: long

Number of seconds since FPM has started.


[float]
=== php_fpm.pool.accepted_conn

type: long

The number of request accepted by the pool.


[float]
=== php_fpm.pool.listen_queue

type: long

The number of request in the queue of pending connections.


[float]
=== php_fpm.pool.max_listen_queue

type: long

The maximum number of requests in the queue of pending connections since FPM has started.


[float]
=== php_fpm.pool.listen_queue_len

type: long

The size of the socket queue of pending connections.


[float]
=== php_fpm.pool.idle_processes

type: long

The number of idle processes.


[float]
=== php_fpm.pool.active_processes

type: long

The number of active processes.


[float]
=== php_fpm.pool.total_processes

type: long

The number of idle + active processes.


[float]
=== php_fpm.pool.max_active_processes

type: long

The maximum number of active processes since FPM has started.


[float]
=== php_fpm.pool.max_children_reached

type: long

Number of times, the process limit has been reached, when pm tries to start more children (works only for pm `dynamic` and `ondemand`)


[float]
=== php_fpm.pool.slow_requests

type: long

Number of times a request execution time has exceeded `request_slowlog_timeout`.


[float]
== proc Fields

`proc` contains the metrics that were obtained from a PHP process managed by the PHP-FPM process pool.



[float]
=== php_fpm.proc.pid

type: keyword

The PID of the process.


[float]
=== php_fpm.proc.state

type: keyword

The state of the process (`Idle`, `Running`, ...).


[float]
=== php_fpm.proc.start_time

type: long

The date and time the process has started.


[float]
=== php_fpm.proc.start_since

type: long

Number of seconds since the process has started.


[float]
=== php_fpm.proc.requests

type: long

The number of requests the process has served.


[float]
=== php_fpm.proc.request_duration

type: long

The duration in microseconds of the requests.


[float]
=== php_fpm.proc.request_method

type: keyword

The request method (`GET`, `POST`, ...).


[float]
=== php_fpm.proc.request_uri

type: keyword

The request URI with the query string.


[float]
=== php_fpm.proc.content_length

type: long

The content length of the request (only with `POST`).


[float]
=== php_fpm.proc.user

type: keyword

The user (`PHP_AUTH_USER`) (or `-` if not set).


[float]
=== php_fpm.proc.script

type: keyword

The main script called (or `-` if not set).


[float]
=== php_fpm.proc.last_request_cpu

type: float

The %cpu the last request consumed it's always 0 if the process is not in `Idle` state because CPU calculation is done when the request processing has terminated.


[float]
=== php_fpm.proc.last_request_memory

type: long

The max amount of memory the last request consumed it's always 0 if the process is not in `Idle` state because memory calculation is done when the request processing has terminated.


[[exported-fields-postgresql]]
== PostgreSQL Fields

Expand Down
65 changes: 65 additions & 0 deletions metricbeat/docs/modules/php_fpm.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-module-php_fpm]]
== PHP-FPM Module

This module periodically fetches metrics from https://php-fpm.org[PHP-FPM]
servers.

[float]
=== Module-Specific Configuration Notes

You need to enable the PHP-FPM status page by properly configuring
`pm.status_path`.

Here is a sample nginx configuration to forward requests to the PHP-FPM status
page (assuming `pm.status_path` is configured with default value `/status`):
```nginx
location ~ /status {
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
```

[float]
=== Compatibility

The PHP-FPM metricsets were tested with PHP 5.6.29 and are expected to
work with all versions >= 5.


[float]
=== Example Configuration

The php_fpm module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: php_fpm
metricsets: ["pool"]
enabled: true
period: 10s
hosts: ["localhost"]
Copy link
Member

Choose a reason for hiding this comment

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

What is the default port the metrics are exposed? 80 or is it 9000 ?

Copy link
Author

@tsouza tsouza Jan 20, 2017

Choose a reason for hiding this comment

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

php-fpm default port is 9000 and default status endpoint is /status. But these defaults does matter much since it's fastcgi protocol and can't be accessed directly. So there is a need to configure a proxy (with fastcgi support) and that can be any port and path (no defaults)

Copy link
Member

Choose a reason for hiding this comment

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

Hm, problem is with the above port 80 is the default. Not sure what we should set here best.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we can use the "default non-default" 8080 (which is at least nginx's default, iirc)

Copy link
Member

Choose a reason for hiding this comment

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

SGTM


----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-php_fpm-pool,pool>>

* <<metricbeat-metricset-php_fpm-proc,proc>>

include::php_fpm/pool.asciidoc[]

include::php_fpm/proc.asciidoc[]

19 changes: 19 additions & 0 deletions metricbeat/docs/modules/php_fpm/pool.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-php_fpm-pool]]
include::../../../module/php_fpm/pool/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-php_fpm,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/php_fpm/pool/_meta/data.json[]
----
19 changes: 19 additions & 0 deletions metricbeat/docs/modules/php_fpm/proc.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-php_fpm-proc]]
include::../../../module/php_fpm/proc/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-php_fpm,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/php_fpm/proc/_meta/data.json[]
----
Loading