Skip to content

Commit e92590b

Browse files
authored
Merge branch '8.x' into backport/8.x/pr-197936
2 parents b428f1f + c832adb commit e92590b

112 files changed

Lines changed: 5893 additions & 320 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

oas_docs/output/kibana.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10848,6 +10848,42 @@ paths:
1084810848
summary: Release an isolated endpoint
1084910849
tags:
1085010850
- Security Endpoint Management API
10851+
/api/entity_store/enable:
10852+
post:
10853+
operationId: InitEntityStore
10854+
requestBody:
10855+
content:
10856+
application/json; Elastic-Api-Version=2023-10-31:
10857+
schema:
10858+
type: object
10859+
properties:
10860+
fieldHistoryLength:
10861+
default: 10
10862+
description: The number of historical values to keep for each field.
10863+
type: integer
10864+
filter:
10865+
type: string
10866+
indexPattern:
10867+
$ref: '#/components/schemas/Security_Entity_Analytics_API_IndexPattern'
10868+
description: Schema for the entity store initialization
10869+
required: true
10870+
responses:
10871+
'200':
10872+
content:
10873+
application/json; Elastic-Api-Version=2023-10-31:
10874+
schema:
10875+
type: object
10876+
properties:
10877+
engines:
10878+
items:
10879+
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineDescriptor'
10880+
type: array
10881+
succeeded:
10882+
type: boolean
10883+
description: Successful response
10884+
summary: Initialize the Entity Store
10885+
tags:
10886+
- Security Entity Analytics API
1085110887
/api/entity_store/engines:
1085210888
get:
1085310889
operationId: ListEntityEngines
@@ -11157,6 +11193,26 @@ paths:
1115711193
summary: List Entity Store Entities
1115811194
tags:
1115911195
- Security Entity Analytics API
11196+
/api/entity_store/status:
11197+
get:
11198+
operationId: GetEntityStoreStatus
11199+
responses:
11200+
'200':
11201+
content:
11202+
application/json; Elastic-Api-Version=2023-10-31:
11203+
schema:
11204+
type: object
11205+
properties:
11206+
engines:
11207+
items:
11208+
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineDescriptor'
11209+
type: array
11210+
status:
11211+
$ref: '#/components/schemas/Security_Entity_Analytics_API_StoreStatus'
11212+
description: Successful response
11213+
summary: Get the status of the Entity Store
11214+
tags:
11215+
- Security Entity Analytics API
1116011216
/api/exception_lists:
1116111217
delete:
1116211218
operationId: DeleteExceptionList
@@ -39165,6 +39221,14 @@ components:
3916539221
- index
3916639222
- description
3916739223
- category
39224+
Security_Entity_Analytics_API_StoreStatus:
39225+
enum:
39226+
- not_installed
39227+
- installing
39228+
- running
39229+
- stopped
39230+
- error
39231+
type: string
3916839232
Security_Entity_Analytics_API_TaskManagerUnavailableResponse:
3916939233
description: Task manager is unavailable
3917039234
type: object

src/plugins/unified_histogram/public/__mocks__/lens_vis.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const getLensVisMock = async ({
3232
breakdownField,
3333
dataView,
3434
allSuggestions,
35-
hasHistogramSuggestionForESQL,
35+
isTransformationalESQL,
3636
table,
3737
}: {
3838
filters: QueryParams['filters'];
@@ -44,7 +44,7 @@ export const getLensVisMock = async ({
4444
timeRange?: TimeRange | null;
4545
breakdownField: DataViewField | undefined;
4646
allSuggestions?: Suggestion[];
47-
hasHistogramSuggestionForESQL?: boolean;
47+
isTransformationalESQL?: boolean;
4848
table?: Datatable;
4949
}): Promise<{
5050
lensService: LensVisService;
@@ -60,7 +60,9 @@ export const getLensVisMock = async ({
6060
if ('query' in context && context.query === query) {
6161
return allSuggestions;
6262
}
63-
return hasHistogramSuggestionForESQL ? [histogramESQLSuggestionMock] : [];
63+
return !isTransformationalESQL && dataView.isTimeBased()
64+
? [histogramESQLSuggestionMock]
65+
: [];
6466
}
6567
: lensApi.suggestions,
6668
});

src/plugins/unified_histogram/public/chart/chart.test.tsx

Lines changed: 113 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function mountComponent({
4444
isPlainRecord,
4545
hasDashboardPermissions,
4646
isChartLoading,
47-
hasHistogramSuggestionForESQL,
47+
isTransformationalESQL,
4848
}: {
4949
customToggle?: ReactElement;
5050
noChart?: boolean;
@@ -57,7 +57,7 @@ async function mountComponent({
5757
isPlainRecord?: boolean;
5858
hasDashboardPermissions?: boolean;
5959
isChartLoading?: boolean;
60-
hasHistogramSuggestionForESQL?: boolean;
60+
isTransformationalESQL?: boolean;
6161
} = {}) {
6262
(searchSourceInstanceMock.fetch$ as jest.Mock).mockImplementation(
6363
jest.fn().mockReturnValue(of({ rawResponse: { hits: { total: noHits ? 0 : 2 } } }))
@@ -87,7 +87,9 @@ async function mountComponent({
8787

8888
const requestParams = {
8989
query: isPlainRecord
90-
? { esql: 'from logs | limit 10' }
90+
? isTransformationalESQL
91+
? { esql: 'from logs | limit 10 | stats var0 = avg(bytes) by extension' }
92+
: { esql: 'from logs | limit 10' }
9193
: {
9294
language: 'kuery',
9395
query: '',
@@ -108,7 +110,7 @@ async function mountComponent({
108110
breakdownField: undefined,
109111
columns: [],
110112
allSuggestions,
111-
hasHistogramSuggestionForESQL,
113+
isTransformationalESQL,
112114
})
113115
).lensService;
114116

@@ -211,12 +213,111 @@ describe('Chart', () => {
211213
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
212214
});
213215

214-
test('render when is text based and not timebased', async () => {
215-
const component = await mountComponent({ isPlainRecord: true, dataView: dataViewMock });
216+
test('should render when is text based, transformational and non-time-based', async () => {
217+
const component = await mountComponent({
218+
isPlainRecord: true,
219+
dataView: dataViewMock,
220+
isTransformationalESQL: true,
221+
});
216222
expect(
217223
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
218224
).toBeTruthy();
219225
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
226+
expect(
227+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
228+
).toBeTruthy();
229+
expect(
230+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
231+
).toBeTruthy();
232+
});
233+
234+
test('should not render when is text based, non-transformational and non-time-based', async () => {
235+
const component = await mountComponent({
236+
isPlainRecord: true,
237+
dataView: dataViewMock,
238+
isTransformationalESQL: false,
239+
});
240+
expect(
241+
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
242+
).toBeTruthy();
243+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeFalsy();
244+
expect(
245+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
246+
).toBeFalsy();
247+
expect(
248+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
249+
).toBeFalsy();
250+
});
251+
252+
test('should not render when is text based, non-transformational, non-time-based and suggestions are available', async () => {
253+
const component = await mountComponent({
254+
allSuggestions: allSuggestionsMock,
255+
isPlainRecord: true,
256+
dataView: dataViewMock,
257+
isTransformationalESQL: false,
258+
});
259+
expect(
260+
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
261+
).toBeTruthy();
262+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeFalsy();
263+
expect(
264+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
265+
).toBeFalsy();
266+
expect(
267+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
268+
).toBeFalsy();
269+
});
270+
271+
test('should render when is text based, non-transformational and time-based', async () => {
272+
const component = await mountComponent({
273+
isPlainRecord: true,
274+
isTransformationalESQL: false,
275+
});
276+
expect(
277+
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
278+
).toBeTruthy();
279+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
280+
expect(
281+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
282+
).toBeTruthy();
283+
expect(
284+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
285+
).toBeTruthy();
286+
});
287+
288+
test('should render when is text based, transformational and time-based', async () => {
289+
const component = await mountComponent({
290+
isPlainRecord: true,
291+
isTransformationalESQL: true,
292+
});
293+
expect(
294+
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
295+
).toBeTruthy();
296+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
297+
expect(
298+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
299+
).toBeTruthy();
300+
expect(
301+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
302+
).toBeTruthy();
303+
});
304+
305+
test('should not render when is text based, transformational and no suggestions available', async () => {
306+
const component = await mountComponent({
307+
allSuggestions: [],
308+
isPlainRecord: true,
309+
isTransformationalESQL: true,
310+
});
311+
expect(
312+
component.find('[data-test-subj="unifiedHistogramToggleChartButton"]').exists()
313+
).toBeTruthy();
314+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeFalsy();
315+
expect(
316+
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
317+
).toBeFalsy();
318+
expect(
319+
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
320+
).toBeFalsy();
220321
});
221322

222323
test('render progress bar when text based and request is loading', async () => {
@@ -267,42 +368,25 @@ describe('Chart', () => {
267368
expect(component.find(BreakdownFieldSelector).exists()).toBeFalsy();
268369
});
269370

270-
it('should render the edit on the fly button when chart is visible and suggestions exist', async () => {
271-
const component = await mountComponent({
272-
allSuggestions: allSuggestionsMock,
273-
isPlainRecord: true,
274-
});
275-
expect(
276-
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
277-
).toBeTruthy();
278-
});
279-
280-
it('should not render the edit on the fly button when chart is visible and suggestions dont exist', async () => {
371+
it('should not render the save button when text-based and the dashboard save by value permissions are false', async () => {
281372
const component = await mountComponent({
282373
allSuggestions: [],
283-
hasHistogramSuggestionForESQL: false,
284-
isPlainRecord: true,
285-
});
286-
expect(
287-
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
288-
).toBeFalsy();
289-
});
290-
291-
it('should render the save button when chart is visible and suggestions exist', async () => {
292-
const component = await mountComponent({
293-
allSuggestions: allSuggestionsMock,
374+
isTransformationalESQL: false,
294375
isPlainRecord: true,
376+
hasDashboardPermissions: false,
295377
});
378+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
296379
expect(
297380
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
298-
).toBeTruthy();
381+
).toBeFalsy();
299382
});
300383

301384
it('should not render the save button when the dashboard save by value permissions are false', async () => {
302385
const component = await mountComponent({
303386
allSuggestions: allSuggestionsMock,
304387
hasDashboardPermissions: false,
305388
});
389+
expect(component.find('[data-test-subj="unifiedHistogramChart"]').exists()).toBeTruthy();
306390
expect(
307391
component.find('[data-test-subj="unifiedHistogramSaveVisualization"]').exists()
308392
).toBeFalsy();

src/plugins/unified_histogram/public/layout/helpers.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/plugins/unified_histogram/public/services/lens_vis_service.attributes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ describe('LensVisService attributes', () => {
765765
columns: [],
766766
isPlainRecord: true,
767767
allSuggestions: [], // none available
768-
hasHistogramSuggestionForESQL: true,
768+
isTransformationalESQL: false,
769769
});
770770
expect(lensVis.visContext?.attributes.state.query).toStrictEqual(histogramQuery);
771771
});

0 commit comments

Comments
 (0)