Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/768#discussion_r144395087
--- Diff:
metron-interface/metron-alerts/src/app/alerts/alerts-list/tree-view/tree-view.component.ts
---
@@ -0,0 +1,319 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
+import {Router} from '@angular/router';
+import {Subscription} from 'rxjs/Rx';
+
+import {TableViewComponent} from '../table-view/table-view.component';
+import {SearchResponse} from '../../../model/search-response';
+import {SearchService} from '../../../service/search.service';
+import {TreeGroupData, TreeAlertsSubscription} from './tree-group-data';
+import {GroupResponse} from '../../../model/group-response';
+import {GroupResult} from '../../../model/group-result';
+import {Group} from '../../../model/group';
+import {SortField} from '../../../model/sort-field';
+import {Sort} from '../../../utils/enums';
+import {MetronDialogBox, DialogType} from
'../../../shared/metron-dialog-box';
+import {ElasticsearchUtils} from '../../../utils/elasticsearch-utils';
+import {SearchRequest} from '../../../model/search-request';
+
+@Component({
+ selector: 'app-tree-view',
+ templateUrl: './tree-view.component.html',
+ styleUrls: ['./tree-view.component.scss']
+})
+
+export class TreeViewComponent extends TableViewComponent implements
OnChanges {
+
+ groupByFields: string[] = [];
+ topGroups: TreeGroupData[] = [];
+ groupResponse: GroupResponse = new GroupResponse();
+ treeGroupSubscriptionMap: {[key: string]: TreeAlertsSubscription } = {};
+
+ constructor(router: Router,
+ searchService: SearchService,
+ metronDialogBox: MetronDialogBox) {
+ super(router, searchService, metronDialogBox);
+ }
+
+ collapseGroup(groupArray: TreeGroupData[], level: number, index: number)
{
+ for (let i = index + 1; i < groupArray.length; i++) {
+ if (groupArray[i].level > (level)) {
+ groupArray[i].show = false;
+ groupArray[i].expand = false;
+ } else {
+ break;
+ }
+ }
+ }
+
+ createQuery(selectedGroup: TreeGroupData) {
+ let searchQuery = this.queryBuilder.generateSelect();
+ let groupQery = Object.keys(selectedGroup.groupQueryMap).map(key => {
+ return key.replace(/:/g, '\\:') +
+ ':' +
+ String(selectedGroup.groupQueryMap[key])
+ .replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') //
replace single special characters
+ .replace(/\|\|/g, '\\||') // replace ||
+ .replace(/\&\&/g, '\\&&'); // replace &&
+ }).join(' AND ');
+
+ groupQery += searchQuery === '*' ? '' : (' AND ' + searchQuery);
+ return groupQery;
+ }
+
+ expandGroup(groupArray: TreeGroupData[], level: number, index: number) {
+ for (let i = index + 1; i < groupArray.length; i++) {
+ if (groupArray[i].level === (level + 1)) {
+ groupArray[i].show = true;
+ } else {
+ break;
+ }
+ }
+ }
+
+ getAlerts(selectedGroup: TreeGroupData): Subscription {
+ let searchRequest = new SearchRequest();
+ searchRequest.query = this.createQuery(selectedGroup);
+ searchRequest.from = selectedGroup.pagingData.from;
+ searchRequest.size = selectedGroup.pagingData.size;
+ searchRequest.sort = selectedGroup.sortField ?
[selectedGroup.sortField] : [];
+
+ return this.searchGroup(selectedGroup, searchRequest);
--- End diff --
I am also noticing another issue with the group header counts that may or
may not be related.
In this example, I am grouping by 'source:type' then 'host'. Since 'host'
is specific to bro, there should be no alerts under the "snort" group. If I
expand the Snort group, I correctly see no alerts.
The Snort group count is reported as 17,300 whereas I would expect that to
be 0. The count of 17,300 is tallying how many Snort alerts there are. But
adding a sub-group like 'host' can filter what the user will see when drilling
down in the alerts.
IMHO We should always expect the group count to reflect how many alerts the
user will see when drilling down.

---