Skip to content

Commit

Permalink
Add support for full php-fpm status (#7529) (#8394)
Browse files Browse the repository at this point in the history
Add new `process` metricset to collect list of processes in
php fpm pools using the full status report.
  • Loading branch information
narph authored and jsoriano committed Sep 29, 2018
1 parent 7b4cb29 commit 184793f
Show file tree
Hide file tree
Showing 24 changed files with 587 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
- Added support for query params in configuration {issue}8286[8286] {pull}8292[8292]
- Support for Kafka 2.0.0 {pull}8399[8399]
- Add container image for docker metricsets. {issue}8214[8214] {pull}8438[8438]
- Add support for `full` status page output for php-fpm module as a separate metricset called `process`. {pull}8394[8394]

*Packetbeat*

Expand Down
146 changes: 146 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14321,6 +14321,13 @@ The name of the pool.
--
[float]
== pool fields
`pool` contains the metrics that were obtained from the PHP-FPM process pool.
*`php_fpm.pool.process_manager`*::
+
--
Expand Down Expand Up @@ -14465,6 +14472,145 @@ format: epoch_second
The date and time FPM has started.
--
[float]
== process fields
process contains the metrics that were obtained from the PHP-FPM process.
*`php_fpm.process.pid`*::
+
--
type: integer
The PID of the process
--
*`php_fpm.process.state`*::
+
--
type: keyword
The state of the process (Idle, Running, etc)
--
*`php_fpm.process.start_time`*::
+
--
type: date
format: epoch_second
The date and time the process has started
--
*`php_fpm.process.start_since`*::
+
--
type: integer
The number of seconds since the process has started
--
*`php_fpm.process.requests`*::
+
--
type: integer
The number of requests the process has served
--
*`php_fpm.process.request_duration`*::
+
--
type: integer
The duration in microseconds (1 million in a second) of the current request (my own definition)
--
*`php_fpm.process.request_method`*::
+
--
type: keyword
The request method (GET, POST, etc) (of the current request)
--
*`php_fpm.process.request_uri`*::
+
--
type: text
The request URI with the query string (of the current request)
--
*`php_fpm.process.content_length`*::
+
--
type: integer
The content length of the request (only with POST) (of the current request)
--
*`php_fpm.process.user`*::
+
--
type: keyword
The user (PHP_AUTH_USER) (or - if not set) (for the current request)
--
*`php_fpm.process.script`*::
+
--
type: text
The main script called (or - if not set) (for the current request)
--
*`php_fpm.process.last_request_cpu`*::
+
--
type: long
The max amount of memory the last request consumed (it is always 0 if the process is not in Idle state because memory calculation is done when the request processing has terminated)
--
*`php_fpm.process.last_request_memory`*::
+
--
type: integer
The content length of the request (only with POST) (of the current request)
--
[[exported-fields-postgresql]]
Expand Down
8 changes: 7 additions & 1 deletion metricbeat/docs/modules/php_fpm.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ in <<configuration-metricbeat>>. Here is an example configuration:
----
metricbeat.modules:
- module: php_fpm
metricsets: ["pool"]
metricsets:
- pool
#- process
enabled: true
period: 10s
status_path: "/status"
Expand All @@ -67,5 +69,9 @@ The following metricsets are available:

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

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

include::php_fpm/pool.asciidoc[]

include::php_fpm/process.asciidoc[]

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

[[metricbeat-metricset-php_fpm-process]]
=== PHP_FPM process metricset

beta[]

include::../../../module/php_fpm/process/_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/process/_meta/data.json[]
----
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ This file is generated! See scripts/docs_collector.py
|<<metricbeat-module-nginx,Nginx>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.1+| .1+| |<<metricbeat-metricset-nginx-stubstatus,stubstatus>>
|<<metricbeat-module-php_fpm,PHP_FPM>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-php_fpm-pool,pool>> beta[]
.2+| .2+| |<<metricbeat-metricset-php_fpm-pool,pool>> beta[]
|<<metricbeat-metricset-php_fpm-process,process>> beta[]
|<<metricbeat-module-postgresql,PostgreSQL>> |image:./images/icon-no.png[No prebuilt dashboards] |
.4+| .4+| |<<metricbeat-metricset-postgresql-activity,activity>>
|<<metricbeat-metricset-postgresql-bgwriter,bgwriter>>
Expand Down
1 change: 1 addition & 0 deletions metricbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions metricbeat/mb/parse/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,27 @@ func getURL(rawURL, scheme, username, password, path, query string) (*url.URL, e
u.Path = path
}

// Add the query params to existing query parameters overwriting any
// keys that already exist.
//Adds the query params in the url
u, err = SetQueryParams(u, query)
return u, err
}

// SetQueryParams adds the query params to existing query parameters overwriting any
// keys that already exist.
func SetQueryParams(u *url.URL, query string) (*url.URL, error) {
q := u.Query()
params, err := url.ParseQuery(query)
if err != nil {
return u, err
}
for key, values := range params {
for _, v := range values {
q.Set(key, v)
}
}
u.RawQuery = q.Encode()

return u, nil

}

// redactURLCredentials returns the URL as a string with the username and
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ metricbeat.modules:

#------------------------------- PHP_FPM Module ------------------------------
- module: php_fpm
metricsets: ["pool"]
metricsets:
- pool
#- process
enabled: true
period: 10s
status_path: "/status"
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/php_fpm/_meta/config.reference.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- module: php_fpm
metricsets: ["pool"]
metricsets:
- pool
#- process
enabled: true
period: 10s
status_path: "/status"
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/php_fpm/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- module: php_fpm
#metricsets:
# - pool
# - process
period: 10s
hosts: ["localhost:8080"]
status_path: "/status"
Expand Down
10 changes: 10 additions & 0 deletions metricbeat/module/php_fpm/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@
`php_fpm` contains the metrics that were obtained from PHP-FPM status
page call.
fields:
- name: pool
type: group
description: >
`pool` contains the metrics that were obtained from the PHP-FPM process pool.
release: beta
fields:
- name: name
type: keyword
description: >
The name of the pool.
2 changes: 1 addition & 1 deletion metricbeat/module/php_fpm/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion metricbeat/module/php_fpm/pool/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"start_time": 1512631228
}
}
}
}
4 changes: 0 additions & 4 deletions metricbeat/module/php_fpm/pool/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
pool.
release: beta
fields:
- name: name
type: keyword
description: >
The name of the pool.
- name: process_manager
type: keyword
description: >
Expand Down
Loading

0 comments on commit 184793f

Please sign in to comment.