Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a6ec8a8
generic histogram container
angorayc Jan 6, 2020
4ea7fbf
generic histogram container
angorayc Jan 6, 2020
078534d
rename params
angorayc Jan 6, 2020
4288679
fix inspect
angorayc Jan 6, 2020
0ba67ef
fix update with timerange
angorayc Jan 7, 2020
57f0259
clean up props
angorayc Jan 7, 2020
dbbeda9
send stackByField to server side
angorayc Jan 7, 2020
369b881
fix inspect button
angorayc Jan 7, 2020
81b2145
helper node xavier
XavierM Jan 7, 2020
e6ce51b
Merge branch 'histogram-enhacement' of github.com:angorayc/kibana int…
XavierM Jan 7, 2020
23d4980
fix DNS histogram
angorayc Jan 12, 2020
421a408
fix DNS query params
angorayc Jan 12, 2020
71aa58a
move utils for fetch data into containers
angorayc Jan 12, 2020
c24e20c
cleanup graphql template on client side
angorayc Jan 12, 2020
cefb6b9
rename grqphql data
angorayc Jan 12, 2020
e4c2806
i18n
angorayc Jan 12, 2020
b1291da
fix type
angorayc Jan 12, 2020
27d0816
Merge remote-tracking branch 'upstream/master' into histogram-enhance…
angorayc Jan 12, 2020
e40e46b
fix i18n
angorayc Jan 13, 2020
5dbbf86
fix i18n
angorayc Jan 13, 2020
a2ba0d2
Merge branch 'master' into histogram-enhancement-2
elasticmachine Jan 13, 2020
dab70a9
Merge branch 'master' into histogram-enhancement-2
elasticmachine Jan 13, 2020
d374bac
Merge branch 'master' into histogram-enhancement-2
elasticmachine Jan 13, 2020
c9241ff
fix subtitle
angorayc Jan 13, 2020
96c15ac
Merge branch 'histogram-enhancement-2' of github.com:angorayc/kibana …
angorayc Jan 13, 2020
1d6f064
fix subtitle
angorayc Jan 13, 2020
cfa2fbd
fix i18n
angorayc Jan 13, 2020
8c4bd66
fix for reviews
angorayc Jan 14, 2020
21fce3d
fix types
angorayc Jan 14, 2020
dd49f34
Merge remote-tracking branch 'upstream/master' into histogram-enhance…
angorayc Jan 14, 2020
2403220
Merge branch 'master' into histogram-enhancement-2
elasticmachine Jan 14, 2020
88b5e4e
Merge branch 'master' into histogram-enhancement-2
elasticmachine Jan 14, 2020
96fab0f
Merge remote-tracking branch 'upstream/master' into histogram-enhance…
angorayc Jan 14, 2020
68b4f97
remove unused test
angorayc Jan 14, 2020
3d421ac
fix integration
angorayc Jan 14, 2020
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 @@ -3,57 +3,74 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { noop } from 'lodash/fp';
import React from 'react';

import React, { useEffect, useCallback } from 'react';
import { EuiSpacer } from '@elastic/eui';
import { manageQuery } from '../page/manage_query';
import { AlertsOverTimeHistogram } from '../page/hosts/alerts_over_time';

import { AlertsComponentsQueryProps } from './types';
import { AlertsOverTimeQuery } from '../../containers/alerts/alerts_over_time';
import { hostsModel } from '../../store/model';
import { AlertsTable } from './alerts_table';
import * as i18n from './translations';
import { MatrixHistogramOption } from '../matrix_histogram/types';
import { MatrixHistogramContainer } from '../../containers/matrix_histogram';
import { MatrixHistogramGqlQuery } from '../../containers/matrix_histogram/index.gql_query';
const ID = 'alertsOverTimeQuery';
const alertsStackByOptions: MatrixHistogramOption[] = [
{
text: i18n.ALERTS_STACK_BY_MODULE,
value: 'event.module',
},
];
const dataKey = 'AlertsHistogram';

const AlertsOverTimeManage = manageQuery(AlertsOverTimeHistogram);
export const AlertsView = ({
defaultFilters,
deleteQuery,
endDate,
filterQuery,
pageFilters,
skip,
setQuery,
skip,
startDate,
type,
updateDateRange = noop,
}: AlertsComponentsQueryProps) => (
<>
<AlertsOverTimeQuery
endDate={endDate}
filterQuery={filterQuery}
sourceId="default"
startDate={startDate}
type={hostsModel.HostsType.page}
>
{({ alertsOverTime, loading, id, inspect, refetch, totalCount }) => (
<AlertsOverTimeManage
data={alertsOverTime!}
endDate={endDate}
id={id}
inspect={inspect}
loading={loading}
refetch={refetch}
setQuery={setQuery}
startDate={startDate}
totalCount={totalCount}
updateDateRange={updateDateRange}
/>
)}
</AlertsOverTimeQuery>
<EuiSpacer size="l" />
<AlertsTable endDate={endDate} startDate={startDate} pageFilters={pageFilters} />
</>
);
}: AlertsComponentsQueryProps) => {
useEffect(() => {
return () => {
if (deleteQuery) {
deleteQuery({ id: ID });
}
};
}, []);

const getSubtitle = useCallback(
(totalCount: number) => `${i18n.SHOWING}: ${totalCount} ${i18n.UNIT(totalCount)}`,
[]
);

return (
<>
<MatrixHistogramContainer
dataKey={dataKey}
deleteQuery={deleteQuery}
defaultStackByOption={alertsStackByOptions[0]}
endDate={endDate}
errorMessage={i18n.ERROR_FETCHING_ALERTS_DATA}
filterQuery={filterQuery}
id={ID}
isAlertsHistogram={true}
query={MatrixHistogramGqlQuery}
setQuery={setQuery}
skip={skip}
sourceId="default"
stackByOptions={alertsStackByOptions}
startDate={startDate}
subtitle={getSubtitle}
title={i18n.ALERTS_DOCUMENT_TYPE}
type={type}
updateDateRange={updateDateRange}
/>
<EuiSpacer size="l" />
<AlertsTable endDate={endDate} startDate={startDate} pageFilters={pageFilters} />
</>
);
};
AlertsView.displayName = 'AlertsView';
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,38 @@

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

export const ALERTS_DOCUMENT_TYPE = i18n.translate('xpack.siem.hosts.alertsDocumentType', {
export const ALERTS_DOCUMENT_TYPE = i18n.translate('xpack.siem.alertsView.alertsDocumentType', {
defaultMessage: 'Alerts',
});

export const TOTAL_COUNT_OF_ALERTS = i18n.translate('xpack.siem.hosts.totalCountOfAlerts', {
export const TOTAL_COUNT_OF_ALERTS = i18n.translate('xpack.siem.alertsView.totalCountOfAlerts', {
defaultMessage: 'alerts match the search criteria',
});

export const ALERTS_TABLE_TITLE = i18n.translate('xpack.siem.hosts.alertsDocumentType', {
export const ALERTS_TABLE_TITLE = i18n.translate('xpack.siem.alertsView.alertsDocumentType', {
defaultMessage: 'Alerts',
});

export const ALERTS_STACK_BY_MODULE = i18n.translate(
'xpack.siem.alertsView.alertsStackByOptions.module',
{
defaultMessage: 'module',
}
);

export const SHOWING = i18n.translate('xpack.siem.alertsView.showing', {
defaultMessage: 'Showing',
});

export const UNIT = (totalCount: number) =>
i18n.translate('xpack.siem.alertsView.unit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {alert} other {alerts}}`,
});

export const ERROR_FETCHING_ALERTS_DATA = i18n.translate(
'xpack.siem.alertsView.errorFetchingAlertsData',
{
defaultMessage: 'Failed to query alerts data',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { esFilters } from '../../../../../../../src/plugins/data/common';
import { HostsComponentsQueryProps } from '../../pages/hosts/navigation/types';
import { NetworkComponentQueryProps } from '../../pages/network/navigation/types';
import { MatrixHistogramOption } from '../matrix_histogram/types';

type CommonQueryProps = HostsComponentsQueryProps | NetworkComponentQueryProps;
export interface AlertsComponentsQueryProps
Expand All @@ -22,5 +23,7 @@ export interface AlertsComponentsQueryProps
| 'updateDateRange'
> {
pageFilters: esFilters.Filter[];
stackByOptions?: MatrixHistogramOption[];
defaultFilters?: esFilters.Filter[];
defaultStackByOption?: MatrixHistogramOption;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ScaleType,
SettingsSpecProps,
TickFormatter,
Position,
} from '@elastic/charts';
import styled from 'styled-components';
import { useUiSetting } from '../../lib/kibana';
Expand All @@ -35,6 +36,7 @@ export interface ChartData {

export interface ChartSeriesConfigs {
customHeight?: number;
customSeriesColors?: string[];
series?: {
xScaleType?: ScaleType | undefined;
yScaleType?: ScaleType | undefined;
Expand Down Expand Up @@ -105,6 +107,7 @@ export const chartDefaultSettings = {
showLegend: false,
showLegendDisplayValue: false,
debug: false,
legendPosition: Position.Bottom,
};

export const getChartHeight = (customHeight?: number, autoSizerHeight?: number): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { shallow } from 'enzyme';
import React from 'react';

import { MatrixHistogram } from '.';
import { MatrixHistogramGqlQuery as mockQuery } from '../../containers/matrix_histogram/index.gql_query';

jest.mock('../../lib/kibana');

Expand All @@ -31,18 +32,27 @@ jest.mock('../charts/barchart', () => {
};
});

describe('Load More Events Table Component', () => {
describe('Matrix Histogram Component', () => {
const mockMatrixOverTimeHistogramProps = {
data: [],
dataKey: 'mockDataKey',
defaultIndex: ['defaultIndex'],
defaultStackByOption: { text: 'text', value: 'value' },
endDate: new Date('2019-07-18T20:00:00.000Z').valueOf(),
errorMessage: 'error',
id: 'mockId',
loading: true,
updateDateRange: () => {},
isInspected: false,
isPtrIncluded: false,
query: mockQuery,
setQuery: jest.fn(),
skip: false,
sourceId: 'default',
stackByField: 'mockStackByField',
stackByOptions: [{ text: 'text', value: 'value' }],
startDate: new Date('2019-07-18T19:00: 00.000Z').valueOf(),
subtitle: 'mockSubtitle',
totalCount: -1,
title: 'mockTitle',
updateDateRange: jest.fn(),
};
describe('rendering', () => {
test('it renders EuiLoadingContent on initialLoad', () => {
Expand Down
Loading