Skip to content

Commit

Permalink
Merge branch 'master' into alerting/fix-duration-flaky-test
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 23, 2020
2 parents d652806 + b03a362 commit 3b559f1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const AuthenticationTableManage = manageQuery(AuthenticationTable);
const ID = 'authenticationsOverTimeQuery';
const authStackByOptions: MatrixHistogramOption[] = [
{
text: 'event.type',
value: 'event.type',
text: 'event.outcome',
value: 'event.outcome',
},
];
const DEFAULT_STACK_BY = 'event.type';
const DEFAULT_STACK_BY = 'event.outcome';

enum AuthMatrixDataGroup {
authSuccess = 'authentication_success',
authFailure = 'authentication_failure',
authSuccess = 'success',
authFailure = 'failure',
}

export const authMatrixDataMappingFields: MatrixHistogramMappingTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const buildQuery = ({
failures: {
filter: {
term: {
'event.type': 'authentication_failure',
'event.outcome': 'failure',
},
},
aggs: {
Expand All @@ -86,7 +86,7 @@ export const buildQuery = ({
successes: {
filter: {
term: {
'event.type': 'authentication_success',
'event.outcome': 'success',
},
},
aggs: {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/legacy/plugins/siem/server/lib/kpi_hosts/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ export const mockKpiHostDetailsUniqueIpsQuery = [
];

const mockAuthAggs = {
authentication_success: { filter: { term: { 'event.type': 'authentication_success' } } },
authentication_success: { filter: { term: { 'event.outcome': 'success' } } },
authentication_success_histogram: {
auto_date_histogram: { field: '@timestamp', buckets: '6' },
aggs: { count: { filter: { term: { 'event.type': 'authentication_success' } } } },
aggs: { count: { filter: { term: { 'event.outcome': 'success' } } } },
},
authentication_failure: { filter: { term: { 'event.type': 'authentication_failure' } } },
authentication_failure: { filter: { term: { 'event.outcome': 'failure' } } },
authentication_failure_histogram: {
auto_date_histogram: { field: '@timestamp', buckets: '6' },
aggs: { count: { filter: { term: { 'event.type': 'authentication_failure' } } } },
aggs: { count: { filter: { term: { 'event.outcome': 'failure' } } } },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const buildAuthQuery = ({
authentication_success: {
filter: {
term: {
'event.type': 'authentication_success',
'event.outcome': 'success',
},
},
},
Expand All @@ -62,7 +62,7 @@ export const buildAuthQuery = ({
count: {
filter: {
term: {
'event.type': 'authentication_success',
'event.outcome': 'success',
},
},
},
Expand All @@ -71,7 +71,7 @@ export const buildAuthQuery = ({
authentication_failure: {
filter: {
term: {
'event.type': 'authentication_failure',
'event.outcome': 'failure',
},
},
},
Expand All @@ -84,7 +84,7 @@ export const buildAuthQuery = ({
count: {
filter: {
term: {
'event.type': 'authentication_failure',
'event.outcome': 'failure',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ export const buildAuthenticationsOverTimeQuery = ({
sourceConfiguration: {
fields: { timestamp },
},
stackByField = 'event.type',
stackByField = 'event.outcome',
}: MatrixHistogramRequestOptions) => {
const filter = [
...createQueryFilterClauses(filterQuery),
{
bool: {
must: [
{
term: {
'event.category': 'authentication',
},
},
],
},
},
{
range: {
[timestamp]: {
Expand Down Expand Up @@ -45,7 +56,7 @@ export const buildAuthenticationsOverTimeQuery = ({
eventActionGroup: {
terms: {
field: stackByField,
include: ['authentication_success', 'authentication_failure'],
include: ['success', 'failure'],
order: {
_count: 'desc',
},
Expand Down
65 changes: 30 additions & 35 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,16 @@ type MlDependencies = MlSetupDependencies & MlStartDependencies;
interface AppProps {
coreStart: CoreStart;
deps: MlDependencies;
appMountParams: AppMountParameters;
}

const localStorage = new Storage(window.localStorage);

const App: FC<AppProps> = ({ coreStart, deps, appMountParams }) => {
setDependencyCache({
indexPatterns: deps.data.indexPatterns,
timefilter: deps.data.query.timefilter,
fieldFormats: deps.data.fieldFormats,
autocomplete: deps.data.autocomplete,
config: coreStart.uiSettings!,
chrome: coreStart.chrome!,
docLinks: coreStart.docLinks!,
toastNotifications: coreStart.notifications.toasts,
overlays: coreStart.overlays,
recentlyAccessed: coreStart.chrome!.recentlyAccessed,
basePath: coreStart.http.basePath,
savedObjectsClient: coreStart.savedObjects.client,
application: coreStart.application,
http: coreStart.http,
security: deps.security,
urlGenerators: deps.share.urlGenerators,
});

const mlLicense = setLicenseCache(deps.licensing);

appMountParams.onAppLeave(actions => {
mlLicense.unsubscribe();
clearCache();
return actions.default();
});

const App: FC<AppProps> = ({ coreStart, deps }) => {
const pageDeps = {
indexPatterns: deps.data.indexPatterns,
config: coreStart.uiSettings!,
setBreadcrumbs: coreStart.chrome!.setBreadcrumbs,
};

const services = {
appName: 'ML',
data: deps.data,
Expand All @@ -85,10 +56,34 @@ export const renderApp = (
deps: MlDependencies,
appMountParams: AppMountParameters
) => {
ReactDOM.render(
<App coreStart={coreStart} deps={deps} appMountParams={appMountParams} />,
appMountParams.element
);
setDependencyCache({
indexPatterns: deps.data.indexPatterns,
timefilter: deps.data.query.timefilter,
fieldFormats: deps.data.fieldFormats,
autocomplete: deps.data.autocomplete,
config: coreStart.uiSettings!,
chrome: coreStart.chrome!,
docLinks: coreStart.docLinks!,
toastNotifications: coreStart.notifications.toasts,
overlays: coreStart.overlays,
recentlyAccessed: coreStart.chrome!.recentlyAccessed,
basePath: coreStart.http.basePath,
savedObjectsClient: coreStart.savedObjects.client,
application: coreStart.application,
http: coreStart.http,
security: deps.security,
urlGenerators: deps.share.urlGenerators,
});

return () => ReactDOM.unmountComponentAtNode(appMountParams.element);
const mlLicense = setLicenseCache(deps.licensing);

appMountParams.onAppLeave(actions => actions.default());

ReactDOM.render(<App coreStart={coreStart} deps={deps} />, appMountParams.element);

return () => {
mlLicense.unsubscribe();
clearCache();
ReactDOM.unmountComponentAtNode(appMountParams.element);
};
};

0 comments on commit 3b559f1

Please sign in to comment.