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

Add support for full php-fpm status (#7529) #8394

Merged
merged 12 commits into from
Sep 29, 2018
Merged

Conversation

narph
Copy link
Contributor

@narph narph commented Sep 21, 2018

I have exposed a new config variable status_full: true which optionally retrieves a more detailed status output from php-fpm (/status?full).

This fixes #7529

Description on process details can be found here https://brandonwamboldt.ca/understanding-the-php-fpm-status-page-1603/

I have extracted the set query parameter handling to a separate func SetQueryParams so I can reuse the functionality inside the Fetch method (pool.go) as the url parser parse.URLHostParserBuilder was not flexible enough to read to read from the config.

@narph narph requested a review from ruflin September 24, 2018 11:22
"max_listen_queue": c.Int("max listen queue"),
"queued": c.Int("listen queue"),
type phpFpmStatus struct {
Name string `json:"pool"`
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 reason you switched from the schema library to defining the types?

Copy link
Contributor Author

@narph narph Sep 24, 2018

Choose a reason for hiding this comment

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

hi @ruflin , the response returned an array of objects and could not find a way to preserve it using the schema lib. Also remapped everything in the baseEvent (https://github.com/elastic/beats/pull/8394/files#diff-6fa6396eb9530b802ab7b56fb9a8f13fR88) in order to replace the spaces with underscore.
Let me know if there is a better way to handle this.

@ruflin ruflin added module review Metricbeat Metricbeat :Generator Related to code generators for building custom Beats or modules. labels Sep 24, 2018
@ruflin
Copy link
Member

ruflin commented Sep 24, 2018

Hi @narph Thanks for the contribution. Haven't checked the PR in detail yet but can you add a changelog entry and run make update? This should bring all the generated files up-to-date.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

@narph awesome contribution, thanks! I wonder if it would be better to do it as a different metricset istead of an optional extension of an existing one. Let me know what you think.

"script": process.Script,
"last_request_cpu": process.LastRequestCPU,
"last_request_memory": process.LastRequestMemory,
}
Copy link
Member

@jsoriano jsoriano Sep 25, 2018

Choose a reason for hiding this comment

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

I think this would be more valuable as an event for each process, in a similar fashion to system process and process_summary metricsets.
We could keep the current metricset as a summary of current processes and connections, and create a new one with the info for each process in a different event.
What do you think?

metricbeat/mb/parse/url.go Show resolved Hide resolved
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Thanks for changing it to a new metricset, this is looking great, I have added some comments.

//remapping process details to match the naming format
for _, process := range status.Processes {
proc := common.MapStr{
"pool_name": status.Name,
Copy link
Member

Choose a reason for hiding this comment

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

This could be placed as php_fpm.pool.name using the ModuleFields attribute of mb.Event. This way it uses a common schema for common fields in both metricsets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good suggestion, I have addressed it in the latest commit

// MetricSet has been created then Fetch will begin to be called periodically.
func init() {
mb.Registry.MustAddMetricSet("php_fpm", "process", New, mb.WithHostParser(php_fpm.HostParser),
mb.DefaultMetricSet())
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this metricset should be a default one. In the previous approach, was the full mode intended to be enabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copy/paste error, learned something new today, pool remains the default metricset

DefaultPath: defaultPath,
QueryParams: defaultQueryParams,
PathConfigKey: "status_path",
}.Build()
Copy link
Member

Choose a reason for hiding this comment

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

Indentation here looks weird.

metricbeat/module/php_fpm/pool/pool.go Show resolved Hide resolved
metricbeat/module/php_fpm/process/process.go Show resolved Hide resolved
@@ -137,6 +137,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
- Added 'died' PID state to process_system metricset on system module{pull}8275[8275]
- Added `ccr` metricset to Elasticsearch module. {pull}8335[8335]
- Support for Kafka 2.0.0 {pull}8399[8399]
- Add support for `full` status page output for php-fpm module {pull}8394[8394]
Copy link
Member

Choose a reason for hiding this comment

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

We may want to mention here that a new metricset has been added.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

It mostly LGTM, just a small comment about reference config.

@@ -1,5 +1,5 @@
- module: php_fpm
metricsets: ["pool"]
metricsets: ["pool", "process"]
Copy link
Member

Choose a reason for hiding this comment

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

This could be written as a list for reference with non-default metricset commented out, like this:

metricsets:
  - pool
  #- process

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @jsoriano , I have made the changes in my latest commit.
I have tried using #8292 in order to clean up the handling of the "full" query param (inside the Fetch func) but it seems that I need the "query" config setting to reside somewhere at the metricset level and not at module level as it is at the moment. Am I missing something obvious here?

Now adhering to goimports
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 41: ordinal not in range(128)
Using make on WSL (Windows 10 + Ubuntu)
This emits separate events for each process in the pool "processes" list.
- add `pool.name` using the ModuleFields attribute of mb.Event, updated fields.yml at module level
- changed the process metricset to non-default (`pool` seems to be the default metricset in this case)
- fixed formatting for url.go
- fix and tested integration tests for `pool` and `process` metricsets after updating Fetch method (ReporterV2)
- generated headers using `make add-headers`
- updated the changelog
@jsoriano
Copy link
Member

jenkins, test this again please

@jsoriano jsoriano merged commit 184793f into elastic:master Sep 29, 2018
@jsoriano jsoriano added needs_backport PR is waiting to be backported to other branches. v6.5.0 labels Sep 29, 2018
jsoriano pushed a commit to jsoriano/beats that referenced this pull request Oct 18, 2018
Add new `process` metricset to collect list of processes in
php fpm pools using the full status report.

(cherry picked from commit 184793f)
@jsoriano jsoriano removed the needs_backport PR is waiting to be backported to other branches. label Oct 18, 2018
jsoriano added a commit that referenced this pull request Oct 18, 2018
Add new `process` metricset to collect list of processes in
php fpm pools using the full status report.

(cherry picked from commit 184793f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Generator Related to code generators for building custom Beats or modules. Metricbeat Metricbeat module review v6.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

php-fpm full status
5 participants