From 25664fcb07962e9fe4fc9f7e820b19d4be57688c Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Mon, 29 Jan 2024 20:09:13 +0200 Subject: [PATCH 1/5] Bugfix -Overview-Dashboard-has-wrong-alert-value (#378) --- .../chart-alert-daily-week.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts b/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts index c065de574..de30e0994 100644 --- a/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts +++ b/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts @@ -37,6 +37,7 @@ export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy { getDailyAlert() { this.overviewAlertDashboardService.getCardAlertTodayWeek().subscribe(response => { + console.log('Alerts:', response.body); this.dailyAlert = response.body; this.loadingChartDailyAlert = false; }); @@ -46,9 +47,9 @@ export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy { const queryParams = {}; queryParams[ALERT_GLOBAL_FIELD] = 'ALERT'; if (type !== 'today') { - queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now-7d/d,now'; + queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now-7d,now'; } else { - queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now/d,now'; + queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now,now'; } this.spinner.show('loadingSpinner'); this.router.navigate(['/data/alert/view'], { From 1cc91ed38b94142c57510762053eb44132c0fce9 Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Mon, 29 Jan 2024 20:14:03 +0200 Subject: [PATCH 2/5] Bugfix -Overview-Dashboard-has-wrong-alert-value (#378) --- .../src/main/java/com/park/utmstack/config/Constants.java | 3 +++ .../com/park/utmstack/service/overview/OverviewService.java | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/park/utmstack/config/Constants.java b/backend/src/main/java/com/park/utmstack/config/Constants.java index 21267b994..269170fca 100644 --- a/backend/src/main/java/com/park/utmstack/config/Constants.java +++ b/backend/src/main/java/com/park/utmstack/config/Constants.java @@ -69,7 +69,10 @@ public final class Constants { // - Alert index common fields // ---------------------------------------------------------------------------------- public static final String alertIdKeyword = "id.keyword"; + public static final String alertStatus = "status"; + + public static final String alertTags = "tags"; public static final String alertIsIncident = "isIncident"; public static final String alertNameKeyword = "name.keyword"; public static final String alertSeverityLabel = "severityLabel.keyword"; diff --git a/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java b/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java index 525a41722..691017761 100644 --- a/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java +++ b/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java @@ -59,7 +59,6 @@ public List countAlertsTodayAndLastWeek() throws DashboardOverviewExce result.add(new CardType("Last 7 days", 0)); return result; } - List filters = new ArrayList<>(); filters.add(new FilterType(Constants.alertStatus, OperatorType.IS_NOT, AlertStatus.AUTOMATIC_REVIEW.getCode())); @@ -67,8 +66,8 @@ public List countAlertsTodayAndLastWeek() throws DashboardOverviewExce .query(SearchUtil.toQuery(filters)).aggregations(AGG_NAME, Aggregation.of(agg -> agg .dateRange(dr -> dr.field(Constants.timestamp) .keyed(true).timeZone("UTC") - .ranges(r -> r.key(TODAY_KEY).from(f -> f.expr("now/d")).from(t -> t.expr("now"))) - .ranges(r -> r.key(LAST_WEEK_KEY).from(f -> f.expr("now-7d/d")).from(t -> t.expr("now")))))).size(0)); + .ranges(r -> r.key(TODAY_KEY).from(f -> f.expr("now/d")).to(t -> t.expr("now"))) + .ranges(r -> r.key(LAST_WEEK_KEY).from(f -> f.expr("now-7d")).to(t -> t.expr("now")))))).size(0)); SearchResponse response = elasticsearchService.search(sr, String.class); Aggregate aggregate = response.aggregations().get(AGG_NAME); From 008fcf1fed7607ca2b32b100239e20a4e25d3ccb Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Mon, 29 Jan 2024 22:20:12 +0200 Subject: [PATCH 3/5] Bugfix -Overview-Dashboard-has-wrong-alert-value (#378) --- .../com/park/utmstack/service/overview/OverviewService.java | 3 ++- version.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java b/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java index 691017761..11badbec4 100644 --- a/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java +++ b/backend/src/main/java/com/park/utmstack/service/overview/OverviewService.java @@ -59,6 +59,7 @@ public List countAlertsTodayAndLastWeek() throws DashboardOverviewExce result.add(new CardType("Last 7 days", 0)); return result; } + List filters = new ArrayList<>(); filters.add(new FilterType(Constants.alertStatus, OperatorType.IS_NOT, AlertStatus.AUTOMATIC_REVIEW.getCode())); @@ -67,7 +68,7 @@ public List countAlertsTodayAndLastWeek() throws DashboardOverviewExce .dateRange(dr -> dr.field(Constants.timestamp) .keyed(true).timeZone("UTC") .ranges(r -> r.key(TODAY_KEY).from(f -> f.expr("now/d")).to(t -> t.expr("now"))) - .ranges(r -> r.key(LAST_WEEK_KEY).from(f -> f.expr("now-7d")).to(t -> t.expr("now")))))).size(0)); + .ranges(r -> r.key(LAST_WEEK_KEY).from(f -> f.expr("now-7d/d")).to(t -> t.expr("now")))))).size(0)); SearchResponse response = elasticsearchService.search(sr, String.class); Aggregate aggregate = response.aggregations().get(AGG_NAME); diff --git a/version.yml b/version.yml index 4b21a570b..736260096 100644 --- a/version.yml +++ b/version.yml @@ -1 +1 @@ -version: 10.2.1 \ No newline at end of file +version: 10.2.2 \ No newline at end of file From 0a5b7357a6e031a5dcbd1c375a4a12f1427cf2fc Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Mon, 29 Jan 2024 22:22:00 +0200 Subject: [PATCH 4/5] Bugfix -Overview-Dashboard-has-wrong-alert-value (#378) --- backend/src/main/java/com/park/utmstack/config/Constants.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/src/main/java/com/park/utmstack/config/Constants.java b/backend/src/main/java/com/park/utmstack/config/Constants.java index 269170fca..21267b994 100644 --- a/backend/src/main/java/com/park/utmstack/config/Constants.java +++ b/backend/src/main/java/com/park/utmstack/config/Constants.java @@ -69,10 +69,7 @@ public final class Constants { // - Alert index common fields // ---------------------------------------------------------------------------------- public static final String alertIdKeyword = "id.keyword"; - public static final String alertStatus = "status"; - - public static final String alertTags = "tags"; public static final String alertIsIncident = "isIncident"; public static final String alertNameKeyword = "name.keyword"; public static final String alertSeverityLabel = "severityLabel.keyword"; From b9a7db3a9544b3d018ad3d30617b45d4881adc0b Mon Sep 17 00:00:00 2001 From: Manuel Abascal Date: Mon, 29 Jan 2024 22:25:54 +0200 Subject: [PATCH 5/5] Bugfix -Overview-Dashboard-has-wrong-alert-value (#378) --- .../chart-alert-daily-week.component.ts | 5 ++--- .../elastic-filter-time/elastic-filter-time.component.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts b/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts index de30e0994..c065de574 100644 --- a/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts +++ b/frontend/src/app/defined-charts/components/alert/chart-alert-daily-week/chart-alert-daily-week.component.ts @@ -37,7 +37,6 @@ export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy { getDailyAlert() { this.overviewAlertDashboardService.getCardAlertTodayWeek().subscribe(response => { - console.log('Alerts:', response.body); this.dailyAlert = response.body; this.loadingChartDailyAlert = false; }); @@ -47,9 +46,9 @@ export class ChartAlertDailyWeekComponent implements OnInit, OnDestroy { const queryParams = {}; queryParams[ALERT_GLOBAL_FIELD] = 'ALERT'; if (type !== 'today') { - queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now-7d,now'; + queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now-7d/d,now'; } else { - queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now,now'; + queryParams[ALERT_TIMESTAMP_FIELD] = ElasticOperatorsEnum.IS_BETWEEN + '->now/d,now'; } this.spinner.show('loadingSpinner'); this.router.navigate(['/data/alert/view'], { diff --git a/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts b/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts index 46b76335d..c810d9672 100644 --- a/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts +++ b/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts @@ -126,7 +126,7 @@ export class ElasticFilterTimeComponent implements OnInit, OnChanges, OnDestroy this.dateTo = 'now'; this.dateFrom = common.label; if (!this.formatInstant) { - const timeFrom = ElasticTimeEnum.NOW + '-' + common.last + common.time; + const timeFrom = ElasticTimeEnum.NOW + '-' + common.last + common.time + '/d' ; const timeTo = ElasticTimeEnum.NOW; this.emitElasticDate(timeFrom, timeTo); } else {