-
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
Generic filtering Implementation #830
Conversation
6f8fc1c
to
dd01b2b
Compare
672c482
to
4115a5c
Compare
keyPart := keyParts[i] | ||
|
||
if _, ok := mapp[keyPart]; ok { | ||
mapp = mapp[keyPart].(MapStr) |
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.
panic possible here.
4fa7a64
to
2d3b680
Compare
filters, err := filter.New(b.Config.Filter) | ||
if err != nil { | ||
fmt.Printf("Error Initialising filters: %v\n", err) | ||
logp.Critical(err.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.
I noticed we spell "initializing" two different ways in messages in this file. We should stop choose one way and change them all.
1b95eca
to
9528839
Compare
be22cfe
to
8b6f82f
Compare
return nil | ||
} | ||
|
||
func (m MapStr) Clone() MapStr { |
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.
Maybe replace it with copystructure?
Both actions receive fields as argument that can be of type map or a value. For example: "proc", "proc.cpu.total_p". Each event MUST contain a few fields that cannot be removed. For now, these "mandatory" fields are: ["@timestamp", "beat", type", "count"]. If you configure one of these fields in the drop_fields, it will be ignored. In case there is a field to include that is not available in the event, then just ignore the field. If none of the fields to include are part of the event, then drop the event as it contains no information except the "mandatory" fields. When multiple filtering rules are defined, we start with a copy of the event and apply the filtering rules one by to the event. event -> filter rule 1 -> event 1 -> filter rule 2 -> event 2 ... where event is the initial event, event1 is the event resulted after applying "filter rule1" and it's considered input for the "filter rule 2" and so on.
The event checker verifies if no field has the struct or pointer type and it's called by the publisher just before publishing the event.
Check if the event (of type MapStr) passed to the publisher contains the expected types. If not, then convert the values by calling json.marshall & json.unmarshall.
0529fe8
to
f8ecee6
Compare
Closing this PR in favor of #1120. |
The proposal for the generic filtering can be found here: #451
In this implementation two actions are implemented:
and both accept
fields
as argument:Each event MUST contain a few fields that cannot be removed. For now, these "mandatory" fields are: ["@timestamp", "beat", type", "count"]. If you configure one of these fields in the
drop_fields
, it will be ignored.A field can be a dictionary or a value. Example: `proc.cpu.total_p", "proc", "proc.cpu".
Special cases to consider:
type != process
will be dropped as they don't contain any of the fields:proc.mem
,proc.cpu
.event -> filter rule 1 -> event 1 -> filter rule 2 -> event 2 ...
Testing: