Skip to content

Commit 773a852

Browse files
Status chart colors update (#309) (#312)
* [FEATURE] Detector must have at least one alert set #288 Signed-off-by: Jovan Cvetkovic <[email protected]> * [BUG] Change colors for Alerts STATUS chart #299 [BUG] Change color for Alerts SEVERITY chart #300 [BUG] Change color for Finding RULE SEVERITY chart #301 Signed-off-by: Jovan Cvetkovic <[email protected]> * [BUG] Change colors for Alerts STATUS chart #299 [BUG] Change color for Alerts SEVERITY chart #300 [BUG] Change color for Finding RULE SEVERITY chart #301 Signed-off-by: Jovan Cvetkovic <[email protected]> * [BUG] Change colors for Alerts STATUS chart #299 [BUG] Change color for Alerts SEVERITY chart #300 [BUG] Change color for Finding RULE SEVERITY chart #301 Signed-off-by: Jovan Cvetkovic <[email protected]> Signed-off-by: Jovan Cvetkovic <[email protected]> (cherry picked from commit f3ddb23) Co-authored-by: Jovan Cvetkovic <[email protected]>
1 parent f8baf63 commit 773a852

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

public/pages/Alerts/containers/Alerts/Alerts.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ class Alerts extends Component<AlertsProps, AlertsState> {
296296

297297
let alerts: AlertItem[] = [];
298298
const detectorId = this.props.match.params['detectorId'];
299+
299300
for (let id of detectorIds) {
300301
if (!detectorId || detectorId === id) {
301302
const alertsRes = await alertService.getAlerts({ detector_id: id });

public/pages/Overview/utils/__snapshots__/helper.test.ts.snap

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ Object {
2929
"color": Object {
3030
"field": "",
3131
"scale": Object {
32+
"domain": Array [
33+
"5 (Lowest)",
34+
"4 (Low)",
35+
"3 (Medium)",
36+
"2 (High)",
37+
"1 (Highest)",
38+
],
3239
"range": Array [
33-
"#54B399",
34-
"#6092C0",
35-
"#D36086",
36-
"#9170B8",
37-
"#CA8EAE",
38-
"#D6BF57",
39-
"#B9A888",
40-
"#DA8B45",
41-
"#AA6556",
42-
"#E7664C",
40+
"#209280",
41+
"#54b399",
42+
"#d6bf57",
43+
"#e7664c",
44+
"#cc5642",
4345
],
4446
},
4547
"title": "Alert severity",
@@ -150,17 +152,19 @@ Object {
150152
"color": Object {
151153
"field": "",
152154
"scale": Object {
155+
"domain": Array [
156+
"info",
157+
"low",
158+
"medium",
159+
"high",
160+
"critical",
161+
],
153162
"range": Array [
154-
"#54B399",
155-
"#6092C0",
156-
"#D36086",
157-
"#9170B8",
158-
"#CA8EAE",
159-
"#D6BF57",
160-
"#B9A888",
161-
"#DA8B45",
162-
"#AA6556",
163-
"#E7664C",
163+
"#209280",
164+
"#54b399",
165+
"#d6bf57",
166+
"#e7664c",
167+
"#cc5642",
164168
],
165169
},
166170
"title": "Rule severity",

public/pages/Overview/utils/helpers.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SummaryData } from '../components/Widgets/Summary';
99
import dateMath from '@elastic/datemath';
1010
import _ from 'lodash';
1111
import { DEFAULT_DATE_RANGE } from '../../../utils/constants';
12+
import { severityOptions } from '../../Alerts/utils/constants';
1213

1314
export interface TimeUnit {
1415
unit: string;
@@ -202,6 +203,11 @@ export function getFindingsVisualizationSpec(
202203
domain: defaultScaleDomain,
203204
}
204205
) {
206+
const severities = ['info', 'low', 'medium', 'high', 'critical'];
207+
const isGroupedByLogType = groupBy === 'logType';
208+
const logTitle = 'Log type';
209+
const severityTitle = 'Rule severity';
210+
const title = isGroupedByLogType ? logTitle : severityTitle;
205211
return getVisualizationSpec('Findings data overview', visualizationData, [
206212
addInteractiveLegends({
207213
mark: {
@@ -214,16 +220,17 @@ export function getFindingsVisualizationSpec(
214220
getTimeTooltip(dateOpts),
215221
{
216222
field: groupBy,
217-
title: groupBy === 'logType' ? 'Log type' : 'Rule severity',
223+
title: title,
218224
},
219225
],
220226
x: getXAxis(dateOpts),
221227
y: getYAxis('finding', 'Count'),
222228
color: {
223229
field: groupBy,
224-
title: groupBy === 'logType' ? 'Log type' : 'Rule severity',
230+
title: title,
225231
scale: {
226-
range: euiPaletteColorBlind(),
232+
domain: isGroupedByLogType ? undefined : severities,
233+
range: groupBy === 'logType' ? euiPaletteColorBlind() : euiPaletteForStatus(5),
227234
},
228235
},
229236
},
@@ -240,6 +247,19 @@ export function getAlertsVisualizationSpec(
240247
domain: defaultScaleDomain,
241248
}
242249
) {
250+
const isGroupedByStatus = groupBy === 'status';
251+
let severities = severityOptions.map((severity) => severity.text);
252+
severities.reverse().pop();
253+
254+
let states = ['ACTIVE', 'ACKNOWLEDGED'];
255+
const statusColors = {
256+
euiColorVis6: '#B9A888',
257+
euiColorVis9: '#E7664C',
258+
};
259+
260+
const statusTitle = 'Alert status';
261+
const severityTitle = 'Alert severity';
262+
const title = isGroupedByStatus ? statusTitle : severityTitle;
243263
return getVisualizationSpec('Alerts data overview', visualizationData, [
244264
addInteractiveLegends({
245265
mark: {
@@ -252,16 +272,17 @@ export function getAlertsVisualizationSpec(
252272
getTimeTooltip(dateOpts),
253273
{
254274
field: groupBy,
255-
title: groupBy === 'status' ? 'Alert status' : 'Alert severity',
275+
title: title,
256276
},
257277
],
258278
x: getXAxis(dateOpts),
259279
y: getYAxis('alert', 'Count'),
260280
color: {
261281
field: groupBy,
262-
title: groupBy === 'status' ? 'Alert status' : 'Alert severity',
282+
title: title,
263283
scale: {
264-
range: groupBy === 'status' ? euiPaletteForStatus(5) : euiPaletteColorBlind(),
284+
domain: isGroupedByStatus ? states : severities,
285+
range: isGroupedByStatus ? Object.values(statusColors) : euiPaletteForStatus(5),
265286
},
266287
},
267288
},

0 commit comments

Comments
 (0)