-
-
Notifications
You must be signed in to change notification settings - Fork 98
Support import filter expressions #1742
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
Conversation
5ff41e4
to
95bc328
Compare
We have long advertised this feature in the documentation of the import command, but never gotten around to implementing it. Turns out it really is quite simple to implement with the new `filter` function on table slices. Here's how you can use it: ```bash # Do not import Suricata.stats events as they are rather meaningless. vast import suricata '#type != "suricata.stats"' # Import only indicators to a matcher that have whose 'type' field is # 'ip' or 'ipv6' (requires the proprietary Live Matching plugin). vast matcher import -t my-ioc csv my-matcher 'type == "ip" || type == "ipv6"' ```
95bc328
to
ca1940b
Compare
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.
Looks good, but let's avoid flooding VERBOSE
.
const auto unfiltered_rows = slice.rows(); | ||
if (self->state.filter) { | ||
if (auto filtered_slice | ||
= filter(std::move(slice), *self->state.filter)) { | ||
VAST_VERBOSE("{} forwards {}/{} produced {} events after filtering", | ||
self, filtered_slice->rows(), unfiltered_rows, | ||
slice.layout().name()); | ||
self->state.mgr->out().push(std::move(*filtered_slice)); | ||
} else { | ||
VAST_VERBOSE("{} forwards 0/{} produced {} events after filtering", | ||
self, unfiltered_rows, slice.layout().name()); | ||
} | ||
} else { | ||
VAST_VERBOSE("{} forwards {} produced {} events", self, | ||
unfiltered_rows, slice.layout().name()); | ||
self->state.mgr->out().push(std::move(slice)); | ||
} |
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.
The log severity for all of those messages has to be DEBUG
.
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.
Done. I also moved the logic to a function in the source state that is used for both source types.
📔 Description
We have long advertised this feature in the documentation of the import command, but never gotten around to implementing it. Turns out it really is quite simple to implement with the new
filter
function on table slices.Here's how you can use it:
📝 Checklist
🎯 Review Instructions
File-by-file. Give it a spin locally.