-
Notifications
You must be signed in to change notification settings - Fork 505
Metron-1252: Build ui for grouping alerts into meta alerts #803
Conversation
|
|
||
|
|
||
| it('should have sort working for group details for multiple sub groups', () => { | ||
| xit('should have sort working for group details for multiple sub groups', () => { |
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.
What does xit mean here? Just curious.
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.
x skips the execution. Since sort on guid is not working anymore, I wanted to skip the test
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 sort on a different field instead? Timestamp maybe? I don't think the right answer is to just disable the test.
| let patchRequest = new PatchRequest(); | ||
| patchRequest.guid = this.selectedMetaAlert; | ||
| patchRequest.sensorType = 'metaalert'; | ||
| patchRequest.index = META_ALERTS_INDEX; |
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.
should be patchRequest.index = META_ALERTS_INDEX + '_index';
| import {environment} from '../../environments/environment'; | ||
|
|
||
| export const META_ALERTS_SENSOR_TYPE = 'metaalert'; | ||
| export const META_ALERTS_INDEX = 'metaalerts'; |
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.
should be export const META_ALERTS_INDEX = 'metaalert';
| export let DEFAULT_FACETS = ['source:type', 'ip_src_addr', 'ip_dst_addr', 'host', 'enrichments:geo:ip_dst_addr:country']; | ||
| export let DEFAULT_GROUPS = ['source:type', 'ip_src_addr', 'ip_dst_addr', 'host', 'enrichments:geo:ip_dst_addr:country']; | ||
| export let INDEXES = environment.indices ? environment.indices.split(',') : ['websphere', 'snort', 'asa', 'bro', 'yaf']; | ||
| export let INDEXES = environment.indices ? environment.indices.split(',') : ['websphere', 'snort', 'asa', 'bro', 'yaf', 'metaalerts']; |
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.
should be export let INDEXES = environment.indices ? environment.indices.split(',') : ['websphere', 'snort', 'asa', 'bro', 'yaf', 'metaalert'];
| patchRequest.patch = [new Patch('replace', 'alert', alertSources)]; | ||
|
|
||
| this.updateService.patch(patchRequest).subscribe(rep => { | ||
| console.log('Meta alert saved'); |
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.
should this be here?
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 mentioned in the Next Section of CC, we need some kind of notification once actions like add/remove are done otherwise it is confusing. These are placeholders till we have a notification mechanism. If it is not a problem I would suggest we leave them else I can remove them.
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 you are planning on replace that with something in the future then I'm ok with it.
| console.log('Unable to get a single meta alert'); | ||
| } | ||
| }); | ||
| console.log(this.selectedMetaAlert); |
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.
should this be here?
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 mentioned in the Next Section of CC, we need some kind of notification once actions like add/remove are done otherwise it is confusing. These are placeholders till we have a notification mechanism. If it is not a problem I would suggest we leave them else I can remove them.
| @NgModule({ | ||
| imports: [ routing, SharedModule ], | ||
| declarations: [ MetaAlertsComponent ], | ||
| providers: [ UpdateService, MetaAlertService ], |
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.
Should UpdateService be in the list of providers here? Isn't it application-wide and provided at the app root level as well?
| searchRequest.facetFields = []; | ||
| searchRequest.indices = [META_ALERTS_INDEX]; | ||
| searchRequest.sort = [new SortField('threat:triage:score', 'desc')]; | ||
| searchRequest.fields = ['id', 'alert_status', 'threat:triage:score', 'count', 'guid', 'name']; |
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.
should 'alert_status' be 'status'?
|
|
||
| this.searchService.search(searchRequest).subscribe((searchResponse: SearchResponse) => { | ||
| if (searchResponse.results.length === 1) { | ||
| searchResponse.results[0].source.alert = [...searchResponse.results[0].source.alert, |
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.
Why are you reassigning old and new alerts back to searchResponse.results[0].source.alert? Makes it a little confusing to read.
| searchRequest.sort = []; | ||
| searchRequest.fields = []; | ||
|
|
||
| this.searchService.search(searchRequest).subscribe((searchResponse: SearchResponse) => { |
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 should be a findOne call instead of a search. Seems inefficient to search and filter down to a single record using a guid.
| } | ||
|
|
||
| public updateAlertState(alerts: Alert[], state: string): Observable<{}> { | ||
| public updateAlertState(alerts: Alert[], state: string, fireChangeListner = true): Observable<{}> { |
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 fireChangeListner used in this function?
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 is passed to patch function and is used there. This is specifically needed in the case where we select multiple rows on the table to update the status. There are too many unnecessary find one calls fired.
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 agree with you and I think that's a good approach. The problem is you're not actually using that variable in this method. Maybe you meant to pass it to this.patch(patchRequest) on line 69?
| constructor(private http: Http) { } | ||
|
|
||
| public patch(patchRequest: PatchRequest): Observable<{}> { | ||
| public patch(patchRequest: PatchRequest, fireChangeListner = true): Observable<{}> { |
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.
Could we fix the typo in Listner?
| } | ||
| } | ||
| } | ||
| /**********************/ |
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.
need newline
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.
fixed
| </div> | ||
| </div> | ||
| </div> | ||
| </div> No newline at end of file |
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.
need newline
|
|
||
| .dropdown-cell { | ||
| padding-left: 0.6rem; | ||
| } |
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.
need newline
| .disabled { | ||
| opacity: 0.5; | ||
| cursor: not-allowed; | ||
| } |
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.
need newline
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.
Added newline
|
I did an initial review of this and I see several things we need to work through. It's a pretty significant feature so that's not surprising. I know there are some other PRs being worked on that this PR depends on (#806). Some questions I have:
Some initial bugs I found (commented on some of these):
I'm also assuming more e2e tests are coming soon. |
|
In this PR description, what does 'Change the state of meta alert' mean?
Can I create a new empty metaalert?
Can I create a metaalert by manually selecting alerts?
How do I create a metaalert from a group that is >1 levels deep?
How do I see all metaalerts? I was able to query with "exists:alert.*" but that is not intuitive.
Can I only remove 1 alert from a metaalert at a time?
Would it be useful to assign a name to your metaalert in the confirmation form rather than having to find it after you create it and rename in the detail view?
Not a fan of vertical scrolling through alerts in metaalert detail, would it be possible to add pagination?
|
|
I filed the following follow-on PRs per your comments: https://issues.apache.org/jira/browse/METRON-1268 |
|
I just submitted a PR against this PR that addresses all of the bugs reported above except 1:
I think we need more discussion on what should happen in that scenario (sorting on fields that doesn't exist in metaalerts). Let me know what you think. |
|
Potentially we want to expose some abstraction for the ES options for missing field sorting (that I admittedly don't know exist in Solr). https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-sort.html#_missing_values |
METRON-1252 bug fixes
- Added better assertions for few tests - Added test specs for 1)Creating a meta alert from a group that is nested by more than 1 level 2)Meta Alert should appear in Filters 3)Meta Alert should not appear in Groups 4)Delete a meta alert from the middle and check the data
|
@justinleet Thanks for taking time to test the PR. I was using an incorrect index to find the alert to delete when I implemented the new API's I fixed it now. Also added tests for all the issues I fixed so far. |
|
I noticed that when I am running e2e test's, the comments that were added in the previous run are still visible at times. The e2e tests delete's all the comments that it added and the only way I can see this happening is if in the previous run of tests add comment was successful and remove comment fails. The best fix for this would be to clean the metron_update table before running the tests. Since we don't have a rest API's for Hbase I am looking at finding alternatives. For the time being, if you bump into this issue I request you to truncate the meton_update table manually. |
|
Hi @iraghumitra - The UI does not refresh itself after a metaalert is deleted. If this is something easy to fix, let's tackle it. Otherwise, I can create a JIRA to track this and we can fix it as a separate PR. EDIT: More specifically, after I delete a metaalert, I can still see in the Filters panel; under source:type, a count of metaalerts equal to 1. If that panel refreshed, it should show 0 metaalerts in this case. Once the UI is refreshed, either manually or through the background refresh, the Filters panel state is corrected. EDIT: Same thing happens if I delete a child alert from a metaalert. In the main panel, I do not immediately see the child alert that was removed from the metaalert. After a manual or background refresh, I then see the results I would expect. |
|
@nickwallen I am not refreshing on purpose. If I refresh the UI after any operation users would lose the current context and see new alerts (If available). If you think this is not a major concern I can add a call to refresh the UI. |
Ok @iraghumitra. Since you have a valid concern about whether this is the right approach, then let's NOT change this in your PR. We can track this separately and come to the right resolution after your PR goes in. Thanks. |
…r-metron into missing-filters
Missing intermediate filters
|
@merrimanr Thanks for iraghumitra#5. It was a pretty significant issue. I merged the fix 👍 |
|
Edit: The issue is with "Recent Searches", not "Saved Searches". Something seems to be wrong with Recent Searches. When I run through a manual test script of creating metaalerts, deleting and navigating, most (if not all) of my recent searches are these giant query strings that are incorrect. I am not sure if this is a pre-existing condition or not. |
|
@nickwallen I haven't been able to get into the same sort of state, but I know you've used/tested the UI more than me. Do you know a repeatable way to reproduce this? Or have you been able to determine if it's preexisting, assuming you've looked into it. |
|
@nickwallen That looks wicked can you share your manual steps that lead to this? |
|
@justinleet @iraghumitra I am glad that no one else can reproduce. I will work on trying to get a set of steps to reproduce this. Let's not worry about this on the current PR. |
|
@nickwallen I agree, unless I'm missing something, it seems like a bug with recent searches, since you didn't say searches were weird during the initial attempts. |
|
@nickwallen I will raise a jira to track this. Even if we are able to reproduce this issue it is unlikely bcoz this PR. |
|
IMHO I think the functionality is good on this PR. There are 3 functional tests that failed, but they are minor and can be addressed after we get this PR in. My only hold-up right now is that I cannot get the e2e tests to pass. I am going to rebuild Full Dev and try again. It might have something to do with stale data.
UPDATE: I am still seeing these e2e failures. The functional tests that I am working with...
|
|
Most of the functional tests worked for me as well. I was able to get the e2e tests to pass after several runs with the exception of a time picker test that I believe is due to a timezone issue and not related to this PR. I was also able to test that meta alerts show up in search results when a search matches a child alert field. However I don't see this case covered in the e2e tests. I think this is a pretty critical function and needs a test. |
…for a alert - Fixed issue with timezone in date picker
|
@merrimanr Added the test case for searching an alert inside meta-alert. Also took the liberty to fix the timezone issue it was a one-liner. |
|
@iraghumitra Are all these e2e tests passing for you? I am still getting failures. I manually truncated the |
|
@nickwallen This is unfortunate I am not seeing these failures login to application metron-alerts App metron-alerts configure table metron-alerts Search metron-alerts tree view metron-alerts facets metron-alerts alert status metron-alerts alert status meta-alerts workflow Executed 44 of 44 specs SUCCESS in 6 mins 31 secs.
|
|
Just a quick update... I was working with @iraghumitra yesterday on getting the e2e tests to pass for me. It seems that with older versions of NPM the tests do pass, but then only various shades of success with newer versions. I don't totally understand why that is. Still working through it. |
|
@iraghumitra Can you describe how you install Node/NPM on your development box? I want to install using the same mechanism (and versions) and see if I can get the e2e tests all working like you. Thanks |
|
+1 I'd like to see sign-off from at least one other committer (if not more) before this gets merged. I previously outlined the manual functional testing that I performed. All the core functionality is there. We also have sufficient test coverage for the functionality that was added. I have been able to get the e2e tests to run good enough (IMO) to move forward with the PR. Based on the experimentation that I describe below, I believe that the test failures are due to the tests and test infrastructure and not the core functionality in the PR. The intermittent failures are a pre-existing condition to this PR. This makes me comfortable enough to merge this PR and then follow-on with test fixes. @iraghumitra mentioned that he is currently working on improving the tests and will open a separate PR.
Thanks for working through this with me @iraghumitra. |
|
I agree with @nickwallen. I think we're good to merge this as long as e2e tests are being addressed in a separate PR. +1 |
|
I agree. I'm fine with going ahead with this, but I'd like to see end to end stability being addressed as the next UI priority, which I believe @iraghumitra is already doing some work on. +1 |
|
Great. I will get this PR merged. I am glad to see that this one is ready to go. |

Contributor Comments
The purpose of the PR is to provide GUI for grouping multiple alerts into a meta alert, the rest api for this is already available via METRON-1158
The current implementation has following features
Caveats
The meta alert index is deleted and recreated few times by e2e test's. I ensured that the index remains available irrespective of the tests succeeding/failing. Just wanted to bring it up.
Limitations
Next
I noticed that search on GUID was not working before I fixed it in this PR.
E2E tests are incoming I wanted to check if the community has any suggestion on this.PS: I had to comment one of the test cases since sort by guid is broke. I will raise a ticket for itPull 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.