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

[7.x] [SIEM] Add Authentications histogram (#48260) #49522

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export interface MatrixOverTimeBasicProps {
}

export interface MatrixOverTimeProps extends MatrixOverTimeBasicProps {
customChartData?: ChartSeriesData[];
title: string;
subtitle: string;
subtitle?: string;
dataKey: string;
}

Expand Down Expand Up @@ -73,6 +74,7 @@ const getBarchartConfigs = (from: number, to: number, onBrushEnd: UpdateDateRang
});

export const MatrixOverTimeHistogram = ({
customChartData,
id,
loading,
data,
Expand All @@ -91,7 +93,7 @@ export const MatrixOverTimeHistogram = ({
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
const [loadingInitial, setLoadingInitial] = useState(false);

const barChartData: ChartSeriesData[] = [
const barChartData: ChartSeriesData[] = customChartData || [
{
key: dataKey,
value: data,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';

import * as i18n from './translation';
import { getCustomChartData } from './utils';
import { MatrixOverTimeHistogram, MatrixOverTimeBasicProps } from '../../../matrix_over_time';

export const AuthenticationsOverTimeHistogram = (props: MatrixOverTimeBasicProps) => {
const dataKey = 'authenticationsOverTime';
const { data, ...matrixOverTimeProps } = props;

const customChartData = getCustomChartData(data);

return (
<MatrixOverTimeHistogram
title={i18n.AUTHENTICATIONS_COUNT}
dataKey={dataKey}
data={data}
customChartData={customChartData}
{...matrixOverTimeProps}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';

export const AUTHENTICATIONS_COUNT = i18n.translate(
'xpack.siem.authenticationsOverTime.authenticationCountTitle',
{
defaultMessage: 'Authentications count',
}
);

export const UNIT = (totalCount: number) =>
i18n.translate('xpack.siem.authenticationsOverTime.unit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {authentication} other {authentications}}`,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { groupBy, map, toPairs } from 'lodash/fp';

import { ChartSeriesData } from '../../../charts/common';
import { MatrixOverTimeHistogramData } from '../../../../graphql/types';
import { KpiHostsChartColors } from '../kpi_hosts/types';

const formatToChartDataItem = ([key, value]: [
string,
MatrixOverTimeHistogramData[]
]): ChartSeriesData => ({
key,
value,
});

const addCustomColors = (item: ChartSeriesData) => {
if (item.key === 'authentication_success') {
item.color = KpiHostsChartColors.authSuccess;
}

if (item.key === 'authentication_failure') {
item.color = KpiHostsChartColors.authFailure;
}

return item;
};

export const getCustomChartData = (data: MatrixOverTimeHistogramData[]): ChartSeriesData[] => {
const dataGroupedByEvent = groupBy('g', data);
const dataGroupedEntries = toPairs(dataGroupedByEvent);
const formattedChartData = map(formatToChartDataItem, dataGroupedEntries);

return map(addCustomColors, formattedChartData);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ export const EVENT_COUNT_FREQUENCY_BY_ACTION = i18n.translate(
}
);

export const LOADING_EVENTS_OVER_TIME = i18n.translate(
'xpack.siem.eventsOverTime.loadingEventsOverTimeTitle',
{
defaultMessage: 'Loading events histogram',
}
);

export const SHOWING = i18n.translate('xpack.siem.eventsOverTime.showing', {
defaultMessage: 'Showing',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

import * as i18n from './translations';
import { StatItems } from '../../../stat_items';

const euiColorVis0 = '#00B3A4';
const euiColorVis2 = '#DB1374';
const euiColorVis3 = '#490092';
const euiColorVis9 = '#920000';
import { KpiHostsChartColors } from './types';

export const kpiHostDetailsMapping: Readonly<StatItems[]> = [
{
Expand All @@ -22,15 +18,15 @@ export const kpiHostDetailsMapping: Readonly<StatItems[]> = [
name: i18n.SUCCESS_CHART_LABEL,
description: i18n.SUCCESS_UNIT_LABEL,
value: null,
color: euiColorVis0,
color: KpiHostsChartColors.authSuccess,
icon: 'check',
},
{
key: 'authFailure',
name: i18n.FAIL_CHART_LABEL,
description: i18n.FAIL_UNIT_LABEL,
value: null,
color: euiColorVis9,
color: KpiHostsChartColors.authFailure,
icon: 'cross',
},
],
Expand All @@ -48,15 +44,15 @@ export const kpiHostDetailsMapping: Readonly<StatItems[]> = [
name: i18n.SOURCE_CHART_LABEL,
description: i18n.SOURCE_UNIT_LABEL,
value: null,
color: euiColorVis2,
color: KpiHostsChartColors.uniqueSourceIps,
icon: 'visMapCoordinate',
},
{
key: 'uniqueDestinationIps',
name: i18n.DESTINATION_CHART_LABEL,
description: i18n.DESTINATION_UNIT_LABEL,
value: null,
color: euiColorVis3,
color: KpiHostsChartColors.uniqueDestinationIps,
icon: 'visMapCoordinate',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

import * as i18n from './translations';
import { StatItems } from '../../../stat_items';

const euiColorVis0 = '#00B3A4';
const euiColorVis1 = '#3185FC';
const euiColorVis2 = '#DB1374';
const euiColorVis3 = '#490092';
const euiColorVis9 = '#920000';
import { KpiHostsChartColors } from './types';

export const kpiHostsMapping: Readonly<StatItems[]> = [
{
Expand All @@ -21,7 +16,7 @@ export const kpiHostsMapping: Readonly<StatItems[]> = [
{
key: 'hosts',
value: null,
color: euiColorVis1,
color: KpiHostsChartColors.hosts,
icon: 'storage',
},
],
Expand All @@ -38,15 +33,15 @@ export const kpiHostsMapping: Readonly<StatItems[]> = [
name: i18n.SUCCESS_CHART_LABEL,
description: i18n.SUCCESS_UNIT_LABEL,
value: null,
color: euiColorVis0,
color: KpiHostsChartColors.authSuccess,
icon: 'check',
},
{
key: 'authFailure',
name: i18n.FAIL_CHART_LABEL,
description: i18n.FAIL_UNIT_LABEL,
value: null,
color: euiColorVis9,
color: KpiHostsChartColors.authFailure,
icon: 'cross',
},
],
Expand All @@ -64,15 +59,15 @@ export const kpiHostsMapping: Readonly<StatItems[]> = [
name: i18n.SOURCE_CHART_LABEL,
description: i18n.SOURCE_UNIT_LABEL,
value: null,
color: euiColorVis2,
color: KpiHostsChartColors.uniqueSourceIps,
icon: 'visMapCoordinate',
},
{
key: 'uniqueDestinationIps',
name: i18n.DESTINATION_CHART_LABEL,
description: i18n.DESTINATION_UNIT_LABEL,
value: null,
color: euiColorVis3,
color: KpiHostsChartColors.uniqueDestinationIps,
icon: 'visMapCoordinate',
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export enum KpiHostsChartColors {
authSuccess = '#00B3A4',
authFailure = '#920000',
uniqueSourceIps = '#DB1374',
uniqueDestinationIps = '#490092',
hosts = '#3185FC',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import gql from 'graphql-tag';

export const AuthenticationsOverTimeGqlQuery = gql`
query GetAuthenticationsOverTimeQuery(
$sourceId: ID!
$timerange: TimerangeInput!
$defaultIndex: [String!]!
$filterQuery: String
$inspect: Boolean!
) {
source(id: $sourceId) {
id
AuthenticationsOverTime(
timerange: $timerange
filterQuery: $filterQuery
defaultIndex: $defaultIndex
) {
authenticationsOverTime {
x
y
g
}
totalCount
inspect @include(if: $inspect) {
dsl
response
}
}
}
}
`;
Loading