-
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 condition to filters #1395
Add condition to filters #1395
Conversation
85276b1
to
a670f83
Compare
|
||
switch value.(type) { | ||
case int, int8, int16, int32, int64: | ||
int_value := reflect.ValueOf(value).Int() |
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.
@urso Thanks! I already changed it with reflect. Please let me know if you find any other issues.
Should we also update the libbeat.yml file with these options to have at least 1 example per "type" in there? |
type EqualsValue struct { | ||
Int int | ||
Str string | ||
} |
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's kind of confusing that this one is defined here, but the RangeValue
is in config.go. I'd say move one of them near the other.
The conditions can: - check if the field is equal with a string or integer (equals) - check if the field contains a given string (contains) - check if the field matches a given regular expression (regexp) - check if the field is in a given range and the supported values can be integer or float (range)
b5d455b
to
cba9786
Compare
I resolved all the comments. It's ready for the final review. |
|
||
for field, value := range equals { | ||
|
||
i, err := strconv.Atoi(value) |
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 far as I understand, the current implementation for equal supports strings
and int
. In case someone wants to use float it will return an error.
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.
Yes, that's right. For float values, there is range
.
Do you plan to update the libbeat.yml in this PR? Would be good to have in a later PR some system tests inside the specific beats to valide this implementation. For example having filters on the global and module level in metricbeat and see if all works as expected. |
The current implementation doesn't work in case the filtering rule contains a field containing a ".". I am planning to open a different PR for that. |
Yes, this is just the initial PR. More small PRs will follow to this one once this is merged. |
@monicasarbu Merged. It would be nice to have some method docs in the source code to clarify the questions we discussed above. |
This implements a task from the meta issue: #1447
This PR adds
equals
,contains
,regexp
andrange
conditions.Please note that in the current implementation you cannot pass fields that contain
.
. The fix will come in a different PR.