Skip to content

Commit

Permalink
Metricbeat php-fpm module
Browse files Browse the repository at this point in the history
Add pool start time and start since stats

Add support for proc stats

Refactor stats api call

Fix listen_queue => listen_queue_len"

Revert "Fix listen_queue => listen_queue_len""

This reverts commit 46ff489fa8cce8d73c2aba42758a51bde4d68a77.

Add suport for "listen_queue_len"

Add documentation

Minor const refactor

Add generated doc

Add basic testing

Fix illegal char in asciidoc

Fix type

Update generated files

Fix package name

Add integration tests
  • Loading branch information
Thiago Souza committed Jan 19, 2017
1 parent fc5ee58 commit 539f229
Show file tree
Hide file tree
Showing 30 changed files with 1,241 additions and 0 deletions.
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"]
----

[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

0 comments on commit 539f229

Please sign in to comment.