-
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 filtering option by exact device names in system.diskio: diskio.include_devices
.
#6085
Add filtering option by exact device names in system.diskio: diskio.include_devices
.
#6085
Conversation
Can one of the admins verify this patch? |
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.
Few thoughts on the config option. We should find one that is reusable as this becomes a more common pattern. Here a few suggestions:
With the below, the assumption is that we potentially want to have more fields to filter on and regexp can be used for positive / negative:
#diskio.filter.name: ^sda
#raid.filter.name: ^md
The below is more specific on what it does. It allows to set a white and blacklist. Regexp are used to also define multiple patterns.
#diskio.include.name: ^sda
#diskio.exclude.name: ^sda
#raid.include.name: ^md
#raid.exclude.name: ^md
Same as the previous one except that having to define multiple patterns in regexp, an array can be used.
#diskio.include.name: [^sda]
#diskio.exclude.name: [^sda]
#raid.include.name: [^sda]
#raid.exclude.name: [^sda]
I was also thinking about a more generic option that the field can be defined and what it should match. But looking at it I think it's overkill and harder to document.
#diskio.includes:
- field: name
match: [^sda]
- field: other
match: [^sda]
Having written this, I'm asking myself if it's the right way to do this. We have processors and should use them whenever possible to have only 1 implementation. There are some special cases where the metricset is a sum of multiple events where this doesn't work. But that should not be the case here as diskio and raid are multiple events and can be filtered. The main problem it's hard to define a whitelist.
As far as I understand the initial request from @stefws the important part is that the data is already filtered before it's event retrieved (if that is possible). This changes does not seem to do this as far as I can see.
@stefws @iahmedov I would really appreciate to hear your thoughts on this.
@@ -21,14 +24,33 @@ func init() { | |||
type MetricSet struct { | |||
mb.BaseMetricSet | |||
statistics *DiskIOStat | |||
nameRegexp *regexp.Regexp |
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 should use our own Match package here as it's more efficient then the native regexp implementation: https://github.com/elastic/beats/tree/master/libbeat/common/match
I agree with you, we probably need some generic way of filtering. By the way, didn't know about libbeat.Processor, which can be applied here as a way of generic filtering.
This is going to be slower, since it works after fetching events, but it can be "ok" for some metricsets like
Yes possible, since methods we are using do not support filtering while parsing and if only 2 metricsets require this, we can open pull requests to 3rd party libs we depend on, not sure they can accept such request, since data for diskstats and mdstat most of the time is small and there is no need to add more code to do filtering inside parsers:
Any thoughts on this @ruflin ? |
On 17 Jan 2018, at 05.43, Ikhtiyor ***@***.***> wrote:
We should find one that is reusable as this becomes a more common pattern.
We have processors and should use them whenever possible to have only 1 implementation.
I agree with you, we probably need some generic way of filtering. By the way, didn't know about libbeat.Processor, which can be applied here as a way of generic filtering.
Something like this could do the job
- module: system
metricsets: ["diskio", "raid"]
processors:
- include_event:
regexp: ^sda
field: diskio.name
- drop_event:
regexp: ^md1
field: raid.name
This is going to be slower, since it works after fetching events,
Just my point, on own hypervisor nodes, there are hundredes of guest devices, that I’ll like not to pull data from just to drop such event again in processor action. Seems waste of time if filtering can be applied before collecting data ImHO
but it can be "ok" for some metricsets like raid where there is not too much data. For performance critical cases, there is always a way to write specific filters inside metricsets. If this is okay we can add regexp filter to processor actions.
As far as I understand the initial request from @stefws <https://github.com/stefws> the important part is that the data is already filtered before it's event retrieved (if that is possible)
@ruffin: correct
Yes possible, since methods we are using do not support filtering while parsing and if only 2 metricsets require this, we can open pull requests to 3rd party libs we depend on:
diskio (https://github.com/shirou/gopsutil <https://github.com/shirou/gopsutil>)
raid (https://github.com/elastic/gosigar <https://github.com/elastic/gosigar>)
Any thoughts on this @ruflin <https://github.com/ruflin> ?
Maybe if architecture would allow preprocessor filter actions more generic it could be used by other metric sets going forward…
/Steffen
|
@stefws now I understand your point, if you have exact names of devices to include, then there is a quicker way, to add it inside diskio metricset, since psutil/disk.IOCounters (which diskio uses) supports filtering by exact match names |
@stefws @iahmedov Thanks for the input. Moving forward I suggest not to add any post processing features to the metricsets if the processors can be used. If the processors can't do what we need, we should discuss if we should extend the processors or add special functionality. For the pre processing it really depends if the client library supports it as stated. If the feature is useful we should definitively try to make a contribution. In some cases the libs are even under our control as we already forked it because of other changes that were critical for us. For this PR I suggest we change it to focus only on pre-processing as @stefws initially request. So if the lib already supports it, lets see if we can use it (didn't dig into it). |
@iahmedov 'add it inside diskio metricset, since psutil/disk.IOCounters (which diskio uses) supports filtering by exact match names' Howto utilize this for diskio? |
@stefws I will change the PR soon (I am on mobile now), so that in config you can give an array of device names to include in events
@ruflin, @stefws what do you think about this field, is this fine? As for |
@iahmedov I like your suggestion. Could you also a CHANGELOG? Looking at the code I somehow missed where the actual implementation in the call to fetch the data happens. Did I miss something? |
Thankfully you didn't miss anything @ruflin , instead I missed to push changes |
metricbeat/metricbeat.reference.yml
Outdated
@@ -111,6 +111,9 @@ metricbeat.modules: | |||
#socket.reverse_lookup.success_ttl: 60s | |||
#socket.reverse_lookup.failure_ttl: 60s | |||
|
|||
# Diskio configurations | |||
#diskio.include_devices: ["sda", "sda1", "sda2"] |
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 wonder what we should have as default config. Should we have [ ]
to disable it or ["*"]
? Alternatives?
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 specifying the config or just empty array disables filtering
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.
As our config normally follow the logic to have the "default" configure I suggest we have here []
. It's good to have the examples in our docs as you did.
@iahmedov Good to know. Somehow Github did not published my comments before, so perhaps some are not valid anymore. Will review later again. |
jenkins, test it |
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.
Code wise it looks good to me. I left some minor docs / config comments.
metricbeat/metricbeat.reference.yml
Outdated
@@ -111,6 +111,9 @@ metricbeat.modules: | |||
#socket.reverse_lookup.success_ttl: 60s | |||
#socket.reverse_lookup.failure_ttl: 60s | |||
|
|||
# Diskio configurations | |||
#diskio.include_devices: ["sda", "sda1", "sda2"] |
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.
As our config normally follow the logic to have the "default" configure I suggest we have here []
. It's good to have the examples in our docs as you did.
There are no configuration options for this metricset. | ||
*`diskio.include_devices`*:: When the `diskio` metricset is enabled, you can use the | ||
`diskio.include_devices` option to define a list of device names to pre-filter the | ||
devices that are reported. Filters only exact matches |
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.
Can you change this to: This filters only exact matches.
(dot at the end).
*`diskio.include_devices`*:: When the `diskio` metricset is enabled, you can use the | ||
`diskio.include_devices` option to define a list of device names to pre-filter the | ||
devices that are reported. Filters only exact matches | ||
If not set, all disk devices are returned |
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.
If not set or an empty array is set, all disk devices are returned.
(also missing dot at the end).
} | ||
|
||
// New is a mb.MetricSetFactory that returns a new MetricSet. | ||
func New(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
ms := &MetricSet{ | ||
config := struct { | ||
Names []string `config:"diskio.include_devices"` |
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.
Can we name this variable IncludeDevices
. This makes it easier to follow the code I 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.
+1 would make sense.
Right so this means that this feature isn't already in place as I was lead to believe initially...
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.
@stefws Not sure I get your comment above?
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.
@ruflin I seconded your comment on the more sensible name for the variable and since this is a code change it means that this feature isn't currently available yet (as in v.5.6.5) which I mistakenly thought was whats iahmedov ment when he said:
'since psutil/disk.IOCounters (which diskio uses) supports filtering by exact match names'
metricbeat/modules.d/system.yml
Outdated
@@ -14,6 +14,7 @@ | |||
process.include_top_n: | |||
by_cpu: 5 # include top 5 processes by CPU | |||
by_memory: 5 # include top 5 processes by memory | |||
#diskio.include_devices: ["sda", "sda1", "sda2"] |
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 should not add this here.
@@ -41,6 +41,7 @@ metricbeat.modules: | |||
process.include_top_n: | |||
by_cpu: 5 # include top 5 processes by CPU | |||
by_memory: 5 # include top 5 processes by memory | |||
#diskio.include_devices: ["sda", "sda1", "sda2"] |
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 don't think it should be added here as the above is our "default" config.
@iahmedov Can you ping me when you pushed an update. I don't think I get a notification on commits. |
@ruflin, its ready, can you please review again, thanks. |
jenkins, test it |
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.
Code LGTM. I left 2 minor comments for the short config files to remove it as it should not be in the short configs. We try to have there only the most common options. Thanks for adding docs.
@@ -14,6 +14,7 @@ | |||
process.include_top_n: | |||
by_cpu: 5 # include top 5 processes by CPU | |||
by_memory: 5 # include top 5 processes by memory | |||
#diskio.include_devices: [] |
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.
Can you remove this line? We should not have this in our short config. Also run make update
afterwards.
metricbeat/modules.d/system.yml
Outdated
@@ -14,6 +14,7 @@ | |||
process.include_top_n: | |||
by_cpu: 5 # include top 5 processes by CPU | |||
by_memory: 5 # include top 5 processes by memory | |||
#diskio.include_devices: [] |
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 line should also be removed here (if make update
does not cover it).
@ruflin comments are implemented, could you please review again |
jenkins, test it |
CHANGELOG.asciidoc
Outdated
@@ -51,6 +51,8 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di | |||
- Rename `golang.heap.system.optained` field to `golang.heap.system.obtained`. {issue}5703[5703] | |||
- Support haproxy stats gathering using http (additionaly to tcp socket). {pull}5819[5819] | |||
- De dot keys in jolokia/jmx metricset to prevent collisions. {pull}5957[5957] | |||
- Support to optionally 'de dot' keys in http/json metricset to prevent collisions. {pull}5957[5957] |
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 sneaked in during rebasing?
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.
Turns out yes, removed entry from changelog which is not related to this pull request (just tagging to inform about change @ruflin )
jenkins, test it |
Thanks @iahmedov for the ping. I just pushed one more commit as there was now a conflict in the changelog. Waiting for green from CI now. |
@iahmedov Could you run |
@ruflin new commit |
@karmi fixed mistake, rebased commit |
jenkins, test it |
jenkins, test it |
diskio.include_devices
.
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@iahmedov Finally merged. Took a bit longer then expected. Thanks a lot for the contribution. |
@ruflin Thanks for thorough and patient review 👍 |
Per feature request #6083 added system.diskio and system.raid regular expression filters