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 9 commits
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
#status_path: "/status"
#hosts: ["localhost:8080"]

#----------------------------- PostgreSQL Module -----------------------------
#- module: postgresql
#metricsets:
Expand Down
71 changes: 71 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,76 @@ 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]
=== 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 (displayed in real time).


[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]
=== 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`. (updated once per second)


[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`). (updated once per second)


[float]
=== php_fpm.pool.requests.slow

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
40 changes: 40 additions & 0 deletions metricbeat/metricbeat.template-es2x.json
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,46 @@
}
}
},
"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"
}
}
},
"requests": {
"properties": {
"slow": {
"type": "long"
}
}
}
}
}
}
},
"postgresql": {
"properties": {
"activity": {
Expand Down
39 changes: 39 additions & 0 deletions metricbeat/metricbeat.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,45 @@
}
}
},
"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"
}
}
},
"requests": {
"properties": {
"slow": {
"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:
Copy link
Member

Choose a reason for hiding this comment

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

Can you add here the experimental[] flag? We do that for all new modules so we can still break compatibility after the first release. This might be a beta flag soonish.

Also please add short_config: false so it does not show up in the short config. See https://github.com/elastic/beats/blob/master/metricbeat/module/prometheus/_meta/fields.yml#L7 as example.

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

I think I forgot to mention it in the review, but also the metricsets should have a log line in the New(...) part that has a warning that it is experimental. Also see prometheus.

- 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