Skip to content

Commit 6f79a42

Browse files
author
oatkiller
committed
Merge branch 'resolver-simulator' of github.com:oatkiller/kibana into resolver-simulator
2 parents 9602cc5 + 2ca8d4b commit 6f79a42

File tree

30 files changed

+342
-229
lines changed

30 files changed

+342
-229
lines changed

x-pack/plugins/infra/common/http_api/snapshot_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const SnapshotRequestRT = rt.intersection([
107107
region: rt.string,
108108
filterQuery: rt.union([rt.string, rt.null]),
109109
includeTimeseries: rt.boolean,
110+
overrideCompositeSize: rt.number,
110111
}),
111112
]);
112113

x-pack/plugins/infra/public/metrics_overview_fetchers.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ describe('Metrics UI Observability Homepage Functions', () => {
7575
groupBy: [],
7676
nodeType: 'host',
7777
includeTimeseries: true,
78+
overrideCompositeSize: 5,
7879
timerange: {
7980
from: startTime.valueOf(),
8081
to: endTime.valueOf(),

x-pack/plugins/infra/public/metrics_overview_fetchers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const createMetricsFetchData = (
8787
groupBy: [],
8888
nodeType: 'host',
8989
includeTimeseries: true,
90+
overrideCompositeSize: 5,
9091
timerange: {
9192
from: start,
9293
to: end,

x-pack/plugins/infra/server/lib/snapshot/snapshot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const requestGroupedNodes = async (
8686
aggregations: {
8787
nodes: {
8888
composite: {
89-
size: SNAPSHOT_COMPOSITE_REQUEST_SIZE,
89+
size: options.overrideCompositeSize || SNAPSHOT_COMPOSITE_REQUEST_SIZE,
9090
sources: getGroupedNodesSources(options),
9191
},
9292
aggs: {
@@ -142,7 +142,7 @@ const requestNodeMetrics = async (
142142
aggregations: {
143143
nodes: {
144144
composite: {
145-
size: SNAPSHOT_COMPOSITE_REQUEST_SIZE,
145+
size: options.overrideCompositeSize || SNAPSHOT_COMPOSITE_REQUEST_SIZE,
146146
sources: getMetricsSources(options),
147147
},
148148
aggregations: {

x-pack/plugins/infra/server/routes/snapshot/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const initSnapshotRoute = (libs: InfraBackendLibs) => {
4040
accountId,
4141
region,
4242
includeTimeseries,
43+
overrideCompositeSize,
4344
} = pipe(
4445
SnapshotRequestRT.decode(request.body),
4546
fold(throwErrors(Boom.badRequest), identity)
@@ -59,6 +60,7 @@ export const initSnapshotRoute = (libs: InfraBackendLibs) => {
5960
metrics,
6061
timerange,
6162
includeTimeseries,
63+
overrideCompositeSize,
6264
};
6365

6466
const searchES = <Hit = {}, Aggregation = undefined>(

x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ export const risk_score_mapping_value = t.string;
222222
export const risk_score_mapping_item = t.exact(
223223
t.type({
224224
field: risk_score_mapping_field,
225-
operator,
226225
value: risk_score_mapping_value,
226+
operator,
227+
risk_score: riskScoreOrUndefined,
227228
})
228229
);
229230

x-pack/plugins/security_solution/public/common/components/events_viewer/events_viewer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ const EventsViewerComponent: React.FC<Props> = ({
222222
sourceId="default"
223223
startDate={start}
224224
endDate={end}
225+
queryDeduplication="events_viewer"
225226
>
226227
{({
227228
events,

x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
6969
}) => {
7070
const [
7171
{ docValueFields, browserFields, indexPatterns, isLoading: isLoadingIndexPattern },
72-
] = useFetchIndexPatterns(defaultIndices ?? useUiSetting<string[]>(DEFAULT_INDEX_KEY));
72+
] = useFetchIndexPatterns(
73+
defaultIndices ?? useUiSetting<string[]>(DEFAULT_INDEX_KEY),
74+
'events_viewer'
75+
);
7376

7477
useEffect(() => {
7578
if (createTimeline != null) {

x-pack/plugins/security_solution/public/common/components/events_viewer/mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const mockEventViewerResponse = [
4040
{ field: 'event.end', format: 'date_time' },
4141
],
4242
inspect: false,
43+
queryDeduplication: 'events_viewer',
4344
},
4445
},
4546
result: {

x-pack/plugins/security_solution/public/common/containers/source/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ interface UseWithSourceState {
122122
export const useWithSource = (
123123
sourceId = 'default',
124124
indexToAdd?: string[] | null,
125-
onlyCheckIndexToAdd?: boolean
125+
onlyCheckIndexToAdd?: boolean,
126+
// Fun fact: When using this hook multiple times within a component (e.g. add_exception_modal & edit_exception_modal),
127+
// the apolloClient will perform queryDeduplication and prevent the first query from executing. A deep compare is not
128+
// performed on `indices`, so another field must be passed to circumvent this.
129+
// For details, see https://github.com/apollographql/react-apollo/issues/2202
130+
queryDeduplication = 'default'
126131
) => {
127132
const [configIndex] = useUiSetting$<string[]>(DEFAULT_INDEX_KEY);
128133
const defaultIndex = useMemo<string[]>(() => {
@@ -154,12 +159,16 @@ export const useWithSource = (
154159
setState((prevState) => ({ ...prevState, loading: true }));
155160

156161
try {
157-
const result = await apolloClient.query<SourceQuery.Query, SourceQuery.Variables>({
162+
const result = await apolloClient.query<
163+
SourceQuery.Query,
164+
SourceQuery.Variables & { queryDeduplication: string }
165+
>({
158166
query: sourceQuery,
159-
fetchPolicy: 'network-only',
167+
fetchPolicy: 'cache-first',
160168
variables: {
161169
sourceId,
162170
defaultIndex,
171+
queryDeduplication,
163172
},
164173
context: {
165174
fetchOptions: {
@@ -206,7 +215,7 @@ export const useWithSource = (
206215
isSubscribed = false;
207216
return abortCtrl.abort();
208217
};
209-
}, [apolloClient, sourceId, defaultIndex]);
218+
}, [apolloClient, sourceId, defaultIndex, queryDeduplication]);
210219

211220
return state;
212221
};

0 commit comments

Comments
 (0)