-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-1158: Build backend for grouping alerts into meta alerts #734
Conversation
…assing through another function in meta dao
Create Meta AlertThe first thing to do is to build and deploy full dev with this PR. Afterwards, we're going to set up a bit of base data. In this case, we care about At this point, we'll group these alerts together. In Ambari, go to Metron -> Quick Links -> Swagger UI and go to the "Meta Alert Controller". Validate that the metaalert was created and looks good: Note that both sub alerts are present, the various counts are filled in, a GUID has been given specifically to this meta alert, etc. SearchingSearching from the REST API works mostly as expected. After the above data has been created, use the search endpoint to run this query: The result should look similar to the following, and have the messages we'd expect (one from snort and one from metaalerts): |
| * guid - GUID of the alert | ||
| * Returns: | ||
| * 200 - Returns the meta alerts associated with this alert | ||
| * 404 - Either Kafka topic is missing or contains no messages |
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.
Is this a mistake?
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.
Absolutely a mistake. Thought I'd fixed that, but apparently not.
| public static void setup() throws Exception { | ||
| buildMetaMappingSource(); | ||
| // setup the client | ||
| es = new ElasticSearchComponent.Builder() |
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.
You might want to consider moving this to TestConfig instead. The REST layer depends heavily on the InMemory components and reuses them across all the integration tests. You are breaking the pattern although I understand why because setting up InMemory components is usually done in @BeforeClass in other modules. This would allow other controller integration tests to leverage this infrastructure without having to do anything.
The SearchController uses a mock ES backend but, in my humble opinion, it's hard to maintain and is unnecessary. Would be nice to switch that to what you've done here someday.
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 actually is the metron-elasticsearch integration testing, so it's outside the scope of the REST layer. This is pretty much the pattern that exists within that module.
The MetaAlertControllerIntegrationTest does use the mock ES backend (InMemoryMetaAlertDao maintains the mock and delegates to it similar to how the actual DAOs work)
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.
You are correct. I read this wrong and thought it was the REST controller test.
|
Great job on this. I spent a lot of time testing and had trouble finding anything wrong. The one thing I did notice was that the "timestamp" field was missing from documents in the metaalerts index. This is the field we commonly use for sorting so we might want to consider adding it or switching our default sort field to "_timestamp" instead. |
|
@merrimanr I added the timestamp field in the meta alert create with current timestamp. Should take care of it lining up with the other sources. |
|
Tested this again in full dev and now the default sort is working as expected (due to timestamp being added). +1 from me. Nice job. |
|
@merrimanr I added in one fix for some typing on meta alert updates and also merged in master and the group stuff |
8d8b9ce to
88fc2a1
Compare
|
@merrimanr Are you still +1 after the most recent changes before I commit this? |
|
I'm still +1 |
Contributor Comments
The motivation for this is also in the ticket, but the idea is that we want to be able to group alerts into a meta alert that lives and is queryable alongside the alerts from the standard sources. These would be manually created, particularly from the UI, as a result of investigations and slicing and dicing done there.
A REST API endpoint allows for the creation of a meta alert and another allows for retrieving all meta alerts associated with a given alert (by GUID). The first is obviously directly useful, and the second is more useful for testing and validation, but may be useful in other contexts (e.g. finding events that tend to get swept up into sets of investigations).
The various search endpoints should work as expected, and be able to query on the metaalerts index.
A test plan is incoming, and a couple more things need to be checked out a bit more thoroughly, but it should be pretty set for review. If anyone is interested, it should be easy enough to spin up, use the REST APIs (both the couple small meta alert ones along with the other search ones) and interrogation of ES to see what's going on.
It's not completely transparent, because searches against the child alerts of meta alerts need to be done against thePretty sure I made a mistake when testing this, because it worked fine in the example provided in the comments.alert.<field>, e.g."query": "alert.guid:35adafd5-ffd1-4b80-806b-91d336b87220 OR guid:35adafd5-ffd1-4b80-806b-91d336b87220"The basic test plan outline is going to be along the lines:
Spin up full dev
Create a couple meta alerts through the REST API.
Ensure they come back as expected from queries.
Ensure they link up appropriately as seen from the other endpoint.
Ensure the other endpoints still work as expected (e.g. search should still work, etc.)
Documentation also needs some updating and will be added (but I'll obviously take into account anything anybody wants as I write more of it).
Notes
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html:Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.