-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
"max_listen_queue": c.Int("max listen queue"), | ||
"queued": c.Int("listen queue"), | ||
type phpFpmStatus struct { | ||
Name string `json:"pool"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Hi @narph Thanks for the contribution. Haven't checked the PR in detail yet but can you add a changelog entry and run |
There was a problem hiding this 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, | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
metricbeat/module/php_fpm/url.go
Outdated
DefaultPath: defaultPath, | ||
QueryParams: defaultQueryParams, | ||
PathConfigKey: "status_path", | ||
}.Build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation here looks weird.
CHANGELOG.asciidoc
Outdated
@@ -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] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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"] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
Details on proceses and description here https://brandonwamboldt.ca/understanding-the-php-fpm-status-page-1603/
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
thanks @jsoriano for elastic#8466
jenkins, test this again please |
Add new `process` metricset to collect list of processes in php fpm pools using the full status report. (cherry picked from commit 184793f)
I have exposed a new config variable
status_full: true
which optionally retrieves a more detailed status output fromphp-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 parserparse.URLHostParserBuilder
was not flexible enough to read to read from the config.