Skip to content

Commit

Permalink
New PHP-FPM metricbeat module (#3415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Souza authored and ruflin committed Jan 24, 2017
1 parent f9666ba commit 58ed51f
Show file tree
Hide file tree
Showing 23 changed files with 615 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
#status_path: "/status"
#hosts: ["localhost:8080"]

#----------------------------- PostgreSQL Module -----------------------------
#- module: postgresql
#metricsets:
Expand Down
85 changes: 85 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,90 @@ 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.
experimental[]
[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]
== connections Fields
Connection state specific statistics.
[float]
=== php_fpm.pool.connections.accepted
type: long
The number of incoming requests that the PHP-FPM server has accepted; when a connection is accepted it is removed from the listen queue.
[float]
=== php_fpm.pool.connections.queued
type: long
The current number of connections that have been initiated, but not yet accepted. If this value is non-zero it typically means that all the available server processes are currently busy, and there are no processes available to serve the next request. Raising `pm.max_children` (provided the server can handle it) should help keep this number low. This property follows from the fact that PHP-FPM listens via a socket (TCP or file based), and thus inherits some of the characteristics of sockets.
[float]
== processes Fields
Process state specific statistics.
[float]
=== php_fpm.pool.processes.idle
type: long
The number of servers in the `waiting to process` state (i.e. not currently serving a page). This value should fall between the `pm.min_spare_servers` and `pm.max_spare_servers` values when the process manager is `dynamic`.
[float]
=== php_fpm.pool.processes.active
type: long
The number of servers current processing a page - the minimum is `1` (so even on a fully idle server, the result will be not read `0`).
[float]
=== php_fpm.pool.slow_requests
type: long
The number of times a request execution time has exceeded `request_slowlog_timeout`.
[[exported-fields-postgresql]]
== PostgreSQL Fields
Expand Down
61 changes: 61 additions & 0 deletions metricbeat/docs/modules/php_fpm.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
////
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
#status_path: "/status"
#hosts: ["localhost:8080"]
----

[float]
=== Metricsets

The following metricsets are available:

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

include::php_fpm/pool.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[]
----
2 changes: 2 additions & 0 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This file is generated! See scripts/docs_collector.py
* <<metricbeat-module-mongodb,MongoDB>>
* <<metricbeat-module-mysql,MySQL>>
* <<metricbeat-module-nginx,Nginx>>
* <<metricbeat-module-php_fpm,php_fpm>>
* <<metricbeat-module-postgresql,PostgreSQL>>
* <<metricbeat-module-prometheus,Prometheus>>
* <<metricbeat-module-redis,Redis>>
Expand All @@ -27,6 +28,7 @@ include::modules/kafka.asciidoc[]
include::modules/mongodb.asciidoc[]
include::modules/mysql.asciidoc[]
include::modules/nginx.asciidoc[]
include::modules/php_fpm.asciidoc[]
include::modules/postgresql.asciidoc[]
include::modules/prometheus.asciidoc[]
include::modules/redis.asciidoc[]
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/include/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
_ "github.com/elastic/beats/metricbeat/module/mysql/status"
_ "github.com/elastic/beats/metricbeat/module/nginx"
_ "github.com/elastic/beats/metricbeat/module/nginx/stubstatus"
_ "github.com/elastic/beats/metricbeat/module/php_fpm"
_ "github.com/elastic/beats/metricbeat/module/php_fpm/pool"
_ "github.com/elastic/beats/metricbeat/module/postgresql"
_ "github.com/elastic/beats/metricbeat/module/postgresql/activity"
_ "github.com/elastic/beats/metricbeat/module/postgresql/bgwriter"
Expand Down
8 changes: 8 additions & 0 deletions metricbeat/metricbeat.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
#status_path: "/status"
#hosts: ["localhost:8080"]

#----------------------------- PostgreSQL Module -----------------------------
#- module: postgresql
#metricsets:
Expand Down
36 changes: 36 additions & 0 deletions metricbeat/metricbeat.template-es2x.json
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,42 @@
}
}
},
"php_fpm": {
"properties": {
"pool": {
"properties": {
"connections": {
"properties": {
"accepted": {
"type": "long"
},
"queued": {
"type": "long"
}
}
},
"pool": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"processes": {
"properties": {
"active": {
"type": "long"
},
"idle": {
"type": "long"
}
}
},
"slow_requests": {
"type": "long"
}
}
}
}
},
"postgresql": {
"properties": {
"activity": {
Expand Down
35 changes: 35 additions & 0 deletions metricbeat/metricbeat.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,41 @@
}
}
},
"php_fpm": {
"properties": {
"pool": {
"properties": {
"connections": {
"properties": {
"accepted": {
"type": "long"
},
"queued": {
"type": "long"
}
}
},
"pool": {
"ignore_above": 1024,
"type": "keyword"
},
"processes": {
"properties": {
"active": {
"type": "long"
},
"idle": {
"type": "long"
}
}
},
"slow_requests": {
"type": "long"
}
}
}
}
},
"postgresql": {
"properties": {
"activity": {
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/php_fpm/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM richarvey/nginx-php-fpm

RUN echo "pm.status_path = /status" >> /etc/php7/php-fpm.d/www.conf
ADD ./php-fpm.conf /etc/nginx/sites-enabled
6 changes: 6 additions & 0 deletions metricbeat/module/php_fpm/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#- module: php_fpm
#metricsets: ["pool"]
#enabled: true
#period: 10s
#status_path: "/status"
#hosts: ["localhost:8080"]
28 changes: 28 additions & 0 deletions metricbeat/module/php_fpm/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
== 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.
14 changes: 14 additions & 0 deletions metricbeat/module/php_fpm/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- key: php_fpm
title: "php_fpm"
description: >
PHP-FPM server status metrics collected from PHP-FPM.
experimental[]
short_config: false
fields:
- name: php_fpm
type: group
description: >
`php_fpm` contains the metrics that were obtained from PHP-FPM status
page call.
fields:
16 changes: 16 additions & 0 deletions metricbeat/module/php_fpm/_meta/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 81; ## listen for ipv4; this line is default and implied
listen [::]:81 default ipv6only=on; ## listen for ipv6

# Make site accessible from http://localhost/
server_name _;

error_log /dev/stdout info;
access_log /dev/stdout;

location ~ /status {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
include fastcgi_params;
}
}
4 changes: 4 additions & 0 deletions metricbeat/module/php_fpm/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Package php_fpm is a Metricbeat module that contains MetricSets.
*/
package php_fpm
Loading

0 comments on commit 58ed51f

Please sign in to comment.