Skip to content

Commit 0c6366f

Browse files
committed
fix: Last log not displayed for a generated alert
1 parent 60e342b commit 0c6366f

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
-Fixed an issue preventing incident status updates when entering long solutions.
44
-Fixed an issue blocking incident creation from the Alerts panel.
55
-Added Asia/Jakarta timezone to the TIMEZONES list.
6-
-Fixed Timezone changes on an instance don't get updated when access by Federation Server
6+
-Fixed Timezone changes on an instance don't get updated when access by Federation Server
7+
-Fixed Last log not displayed for a generated alert

frontend/src/app/data-management/alert-management/alert-view/alert-view.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ <h6 class="card-title text-blue-800 font-weight-light">
227227
[alert]="alertDetail"
228228
[hideEmptyField]=" true"
229229
[tags]="tags"
230+
[timeFilter]="getFilterTime()"
230231
[dataType]="dataType"></app-alert-view-detail>
231232
</div>
232233
</div>

frontend/src/app/data-management/alert-management/alert-view/alert-view.component.ts

+4
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ export class AlertViewComponent implements OnInit, OnDestroy {
550550
modal.componentInstance.alert = alert;
551551
}
552552

553+
getFilterTime(){
554+
return this.filters.find(f => f.field === ALERT_TIMESTAMP_FIELD);
555+
}
556+
553557
ngOnDestroy(): void {
554558
this.destroy$.next();
555559
this.destroy$.complete();

frontend/src/app/data-management/alert-management/shared/components/alert-view-detail/alert-view-detail.component.html

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@
176176
</span>
177177
</div>
178178
</ng-template>
179+
<ng-container *ngIf="isEmptyResponse()">
180+
<div class="d-flex has-fixed-height w-100 justify-content-center align-items-center">
181+
<app-no-data-found></app-no-data-found>
182+
</div>
183+
</ng-container>
179184
</div>
180185
</div>
181186
</div>

frontend/src/app/data-management/alert-management/shared/components/alert-view-detail/alert-view-detail.component.ts

+16-12
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import {
1616
ALERT_PROTOCOL_FIELD,
1717
ALERT_SENSOR_FIELD,
1818
ALERT_SEVERITY_FIELD_LABEL,
19-
ALERT_STATUS_FIELD,
20-
ALERT_TACTIC_FIELD,
21-
ALERT_TIMESTAMP_FIELD
19+
ALERT_STATUS_FIELD, ALERT_TACTIC_FIELD, ALERT_TIMESTAMP_FIELD
2220
} from '../../../../../shared/constants/alert/alert-field.constant';
2321
import {LOG_ROUTE} from '../../../../../shared/constants/app-routes.constant';
2422
import {LOG_INDEX_PATTERN, LOG_INDEX_PATTERN_ID} from '../../../../../shared/constants/main-index-pattern.constant';
@@ -34,7 +32,6 @@ import {AlertUpdateHistoryBehavior} from '../../behavior/alert-update-history.be
3432
import {AlertUpdateTagBehavior} from '../../behavior/alert-update-tag.behavior';
3533
import {AlertHistoryActionEnum} from '../../enums/alert-history-action.enum';
3634
import {EventDataTypeEnum} from '../../enums/event-data-type.enum';
37-
import {AlertManagementService} from '../../services/alert-management.service';
3835

3936
@Component({
4037
selector: 'app-alert-view-detail',
@@ -47,6 +44,7 @@ export class AlertViewDetailComponent implements OnInit {
4744
@Input() hideEmptyField = false;
4845
@Input() dataType: EventDataTypeEnum;
4946
@Input() tags: AlertTags[];
47+
@Input() timeFilter: ElasticFilterType;
5048
@Output() refreshData = new EventEmitter<boolean>();
5149
ALERT_NAME = ALERT_NAME_FIELD;
5250
STATUS_FIELD = ALERT_STATUS_FIELD;
@@ -77,19 +75,17 @@ export class AlertViewDetailComponent implements OnInit {
7775
hideLastChange = false;
7876
incidentResponse = false;
7977

80-
constructor(private alertServiceManagement: AlertManagementService,
81-
private utmToastService: UtmToastService,
82-
private alertUpdateHistoryBehavior: AlertUpdateHistoryBehavior,
78+
constructor(private alertUpdateHistoryBehavior: AlertUpdateHistoryBehavior,
8379
private alertUpdateTagBehavior: AlertUpdateTagBehavior,
8480
private spinner: NgxSpinnerService,
8581
private elasticDataService: ElasticDataService,
8682
private moduleService: UtmModulesService,
87-
private router: Router) {
83+
private router: Router,
84+
private toastService: UtmToastService) {
8885
}
8986

9087
ngOnInit() {
9188
this.viewLog = this.fullScreen;
92-
// @ts-ignore
9389
this.logs = this.alert.logs.reverse();
9490
this.countRelatedEvents = this.logs.length;
9591
const ref = this.alert.reference;
@@ -155,14 +151,18 @@ export class AlertViewDetailComponent implements OnInit {
155151
searchLastLog() {
156152
if (!this.log) {
157153
this.getLastLog = true;
158-
const filter: ElasticFilterType[] = [{field: ALERT_ID_FIELD, operator: ElasticOperatorsEnum.IS, value: this.logs[0]}];
154+
const filters: ElasticFilterType[] = [
155+
...(this.timeFilter ? [this.timeFilter] : []),
156+
{ field: ALERT_ID_FIELD, operator: ElasticOperatorsEnum.IS, value: this.logs[0] }
157+
];
159158
this.elasticDataService.search(1, 1,
160-
1, LOG_INDEX_PATTERN, filter).subscribe(
159+
1, LOG_INDEX_PATTERN, filters).subscribe(
161160
(res: HttpResponse<any>) => {
162-
this.log = res.body[0];
161+
this.log = res.body[0] ? res.body[0] : {};
163162
this.getLastLog = false;
164163
},
165164
(res: HttpResponse<any>) => {
165+
this.toastService.showError('Error', 'An error occurred while trying to retrieve the latest log.');
166166
}
167167
);
168168
}
@@ -171,6 +171,10 @@ export class AlertViewDetailComponent implements OnInit {
171171
viewLastLog() {
172172
this.searchLastLog();
173173
}
174+
175+
isEmptyResponse() {
176+
return Object.entries(this.log).length === 0;
177+
}
174178
}
175179

176180
export enum AlertDetailTabEnum {

0 commit comments

Comments
 (0)