Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status chart colors update #309

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class Alerts extends Component<AlertsProps, AlertsState> {

let alerts: AlertItem[] = [];
const detectorId = this.props.match.params['detectorId'];

for (let id of detectorIds) {
if (!detectorId || detectorId === id) {
const alertsRes = await alertService.getAlerts({ detector_id: id });
Expand Down
44 changes: 24 additions & 20 deletions public/pages/Overview/utils/__snapshots__/helper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ Object {
"color": Object {
"field": "",
"scale": Object {
"domain": Array [
"5 (Lowest)",
"4 (Low)",
"3 (Medium)",
"2 (High)",
"1 (Highest)",
],
"range": Array [
"#54B399",
"#6092C0",
"#D36086",
"#9170B8",
"#CA8EAE",
"#D6BF57",
"#B9A888",
"#DA8B45",
"#AA6556",
"#E7664C",
"#209280",
"#54b399",
"#d6bf57",
"#e7664c",
"#cc5642",
],
},
"title": "Alert severity",
Expand Down Expand Up @@ -150,17 +152,19 @@ Object {
"color": Object {
"field": "",
"scale": Object {
"domain": Array [
"info",
"low",
"medium",
"high",
"critical",
],
"range": Array [
"#54B399",
"#6092C0",
"#D36086",
"#9170B8",
"#CA8EAE",
"#D6BF57",
"#B9A888",
"#DA8B45",
"#AA6556",
"#E7664C",
"#209280",
"#54b399",
"#d6bf57",
"#e7664c",
"#cc5642",
],
},
"title": "Rule severity",
Expand Down
33 changes: 27 additions & 6 deletions public/pages/Overview/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SummaryData } from '../components/Widgets/Summary';
import dateMath from '@elastic/datemath';
import _ from 'lodash';
import { DEFAULT_DATE_RANGE } from '../../../utils/constants';
import { severityOptions } from '../../Alerts/utils/constants';

export interface TimeUnit {
unit: string;
Expand Down Expand Up @@ -202,6 +203,11 @@ export function getFindingsVisualizationSpec(
domain: defaultScaleDomain,
}
) {
const severities = ['info', 'low', 'medium', 'high', 'critical'];
const isGroupedByLogType = groupBy === 'logType';
const logTitle = 'Log type';
const severityTitle = 'Rule severity';
const title = isGroupedByLogType ? logTitle : severityTitle;
return getVisualizationSpec('Findings data overview', visualizationData, [
addInteractiveLegends({
mark: {
Expand All @@ -214,16 +220,17 @@ export function getFindingsVisualizationSpec(
getTimeTooltip(dateOpts),
{
field: groupBy,
title: groupBy === 'logType' ? 'Log type' : 'Rule severity',
title: title,
},
],
x: getXAxis(dateOpts),
y: getYAxis('finding', 'Count'),
color: {
field: groupBy,
title: groupBy === 'logType' ? 'Log type' : 'Rule severity',
title: title,
scale: {
range: euiPaletteColorBlind(),
domain: isGroupedByLogType ? undefined : severities,
range: groupBy === 'logType' ? euiPaletteColorBlind() : euiPaletteForStatus(5),
},
},
},
Expand All @@ -240,6 +247,19 @@ export function getAlertsVisualizationSpec(
domain: defaultScaleDomain,
}
) {
const isGroupedByStatus = groupBy === 'status';
let severities = severityOptions.map((severity) => severity.text);
severities.reverse().pop();

let states = ['ACTIVE', 'ACKNOWLEDGED'];
const statusColors = {
euiColorVis6: '#B9A888',
euiColorVis9: '#E7664C',
Copy link

@kamingleung kamingleung Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jovancacvetkovic @amsiglan Active should be euiColorVis9 and acknowledged should be euiColorVis6.
Incorrect colors shown in screenshot:
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kamingleung you are right, I switched the colors, and fixed in the next PR (under review PR #350 350)

};

const statusTitle = 'Alert status';
const severityTitle = 'Alert severity';
const title = isGroupedByStatus ? statusTitle : severityTitle;
return getVisualizationSpec('Alerts data overview', visualizationData, [
addInteractiveLegends({
mark: {
Expand All @@ -252,16 +272,17 @@ export function getAlertsVisualizationSpec(
getTimeTooltip(dateOpts),
{
field: groupBy,
title: groupBy === 'status' ? 'Alert status' : 'Alert severity',
title: title,
},
],
x: getXAxis(dateOpts),
y: getYAxis('alert', 'Count'),
color: {
field: groupBy,
title: groupBy === 'status' ? 'Alert status' : 'Alert severity',
title: title,
scale: {
range: groupBy === 'status' ? euiPaletteForStatus(5) : euiPaletteColorBlind(),
domain: isGroupedByStatus ? states : severities,
range: isGroupedByStatus ? Object.values(statusColors) : euiPaletteForStatus(5),
},
},
},
Expand Down