forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Refactor NetworkDns to use Search Strategy (elast…
- Loading branch information
1 parent
2bdeb7c
commit ccf48e9
Showing
13 changed files
with
600 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...k/plugins/security_solution/common/search_strategy/security_solution/network/dns/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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 { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; | ||
import { CursorType, Inspect, Maybe, PageInfoPaginated, SortField } from '../../../common'; | ||
import { RequestOptionsPaginated } from '../..'; | ||
|
||
export enum NetworkDnsFields { | ||
dnsName = 'dnsName', | ||
queryCount = 'queryCount', | ||
uniqueDomains = 'uniqueDomains', | ||
dnsBytesIn = 'dnsBytesIn', | ||
dnsBytesOut = 'dnsBytesOut', | ||
} | ||
|
||
export interface NetworkDnsRequestOptions extends RequestOptionsPaginated { | ||
isPtrIncluded: boolean; | ||
sort: SortField<NetworkDnsFields>; | ||
stackByField?: Maybe<string>; | ||
} | ||
|
||
export interface NetworkDnsStrategyResponse extends IEsSearchResponse { | ||
edges: NetworkDnsEdges[]; | ||
totalCount: number; | ||
pageInfo: PageInfoPaginated; | ||
inspect?: Maybe<Inspect>; | ||
histogram?: Maybe<MatrixOverOrdinalHistogramData[]>; | ||
} | ||
|
||
export interface NetworkDnsEdges { | ||
node: NetworkDnsItem; | ||
cursor: CursorType; | ||
} | ||
|
||
export interface NetworkDnsItem { | ||
_id?: Maybe<string>; | ||
dnsBytesIn?: Maybe<number>; | ||
dnsBytesOut?: Maybe<number>; | ||
dnsName?: Maybe<string>; | ||
queryCount?: Maybe<number>; | ||
uniqueDomains?: Maybe<number>; | ||
} | ||
|
||
export interface MatrixOverOrdinalHistogramData { | ||
x: string; | ||
y: number; | ||
g: string; | ||
} | ||
|
||
export interface NetworkDnsBuckets { | ||
key: string; | ||
doc_count: number; | ||
unique_domains: { | ||
value: number; | ||
}; | ||
dns_bytes_in: { | ||
value: number; | ||
}; | ||
dns_bytes_out: { | ||
value: number; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/security_solution/public/network/containers/network_dns/histogram.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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 { connect } from 'react-redux'; | ||
import { compose } from 'redux'; | ||
import { DocumentNode } from 'graphql'; | ||
import { ScaleType } from '@elastic/charts'; | ||
|
||
import { MatrixHistogram } from '../../../common/components/matrix_histogram'; | ||
import { | ||
MatrixHistogramOption, | ||
GetSubTitle, | ||
} from '../../../common/components/matrix_histogram/types'; | ||
import { UpdateDateRange } from '../../../common/components/charts/common'; | ||
import { GlobalTimeArgs } from '../../../common/containers/use_global_time'; | ||
import { withKibana } from '../../../common/lib/kibana'; | ||
import { QueryTemplatePaginatedProps } from '../../../common/containers/query_template_paginated'; | ||
import { DEFAULT_TABLE_ACTIVE_PAGE, DEFAULT_TABLE_LIMIT } from '../../../common/store/constants'; | ||
import { networkModel, networkSelectors } from '../../store'; | ||
import { State, inputsSelectors } from '../../../common/store'; | ||
|
||
export const HISTOGRAM_ID = 'networkDnsHistogramQuery'; | ||
|
||
interface DnsHistogramOwnProps extends QueryTemplatePaginatedProps { | ||
dataKey: string | string[]; | ||
defaultStackByOption: MatrixHistogramOption; | ||
errorMessage: string; | ||
isDnsHistogram?: boolean; | ||
query: DocumentNode; | ||
scaleType: ScaleType; | ||
setQuery: GlobalTimeArgs['setQuery']; | ||
showLegend?: boolean; | ||
stackByOptions: MatrixHistogramOption[]; | ||
subtitle?: string | GetSubTitle; | ||
title: string; | ||
type: networkModel.NetworkType; | ||
updateDateRange: UpdateDateRange; | ||
yTickFormatter?: (value: number) => string; | ||
} | ||
|
||
const makeMapHistogramStateToProps = () => { | ||
const getNetworkDnsSelector = networkSelectors.dnsSelector(); | ||
const getQuery = inputsSelectors.globalQueryByIdSelector(); | ||
const mapStateToProps = (state: State, { id = HISTOGRAM_ID }: DnsHistogramOwnProps) => { | ||
const { isInspected } = getQuery(state, id); | ||
return { | ||
...getNetworkDnsSelector(state), | ||
activePage: DEFAULT_TABLE_ACTIVE_PAGE, | ||
limit: DEFAULT_TABLE_LIMIT, | ||
isInspected, | ||
id, | ||
}; | ||
}; | ||
|
||
return mapStateToProps; | ||
}; | ||
|
||
export const NetworkDnsHistogramQuery = compose<React.ComponentClass<DnsHistogramOwnProps>>( | ||
connect(makeMapHistogramStateToProps), | ||
withKibana | ||
)(MatrixHistogram); |
Oops, something went wrong.