Skip to content

Commit 02ce3f3

Browse files
XavierMstephmilovicpatrykkopycinski
committed
[Security Solution] Options to select index patterns (elastic#77192)
* init commit * lots of cleanup * starting on tests... problems * Ready for review * remove sample data * remove comment and fix type * pr changes * fix type * scratchy * sourcerer in timeline * sourcerer in timeline * wip * moving to redux * working on types * fixed * more adjustments, tests fixed * FF off * pr ready * renaming * url state working, hoc not working * url state working for timeline and default scope * script to build fields for beat doc * refactor sourcerer * refactor host to useSourcerer * refactor network to useSourcerer * refactor overview to useSourcerer * refactor detections to useSourcerer * wip for timelines to remove all useSource * wip indexes timeline * do component tests * start container tests * start container tests * update selection widget of index patterns + remove last useWithSource * add indexeNames in network kpi * fix type errors * fix type * missing merge master * get existing index from config file * fixing broken tests * add saving button to avoid to many queries to be aborted * reducer timeline tests broke * need to rewind * much better * timeline saving index names + clean up url state to only manage default * more test fixing * more test changes * remove all the useWithSource + deprecated the graphql until we delete it in a new PR + delete all the beat doc * default timeline to all index when creation + filter index patterns to make sure you do not add one who we do not know * fix types * test for stateful timeline render * we should not have change that * no chnages + snapshot * fix test + bugs from review * fix uncommon processes indexNames * review III * change design for main page of the sourcerer from design * bug fixes when opening old timeline + implementation of new design * fix circular deps * remove unused attributes for event details * design cleanup * fix api integration test with the new search strategy * add reset + manage accordion state * fix bugs + types issues * cleanup * update docs * review -> remove tooltip when popover is open * cypress fixing * fix for ml_condition_links and url_state cypress tests * add cy wait for race condition in pagination tests * missing plumbing kpi host Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
1 parent 0d01637 commit 02ce3f3

File tree

272 files changed

+41559
-52569
lines changed

Some content is hidden

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

272 files changed

+41559
-52569
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-public.indexpatternsservice.md) &gt; [getIdsWithTitle](./kibana-plugin-plugins-data-public.indexpatternsservice.getidswithtitle.md)
4+
5+
## IndexPatternsService.getIdsWithTitle property
6+
7+
Get list of index pattern ids with titles
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
getIdsWithTitle: (refresh?: boolean) => Promise<Array<{
13+
id: string;
14+
title: string;
15+
}>>;
16+
```

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternsservice.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export declare class IndexPatternsService
2929
| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md) | | <code>(indexPattern: IndexPattern &#124; IndexPatternSpec, options?: GetFieldsOptions) =&gt; Promise&lt;any&gt;</code> | Get field list by providing an index patttern (or spec) |
3030
| [getFieldsForWildcard](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md) | | <code>(options?: GetFieldsOptions) =&gt; Promise&lt;any&gt;</code> | Get field list by providing { pattern } |
3131
| [getIds](./kibana-plugin-plugins-data-public.indexpatternsservice.getids.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;string[]&gt;</code> | Get list of index pattern ids |
32+
| [getIdsWithTitle](./kibana-plugin-plugins-data-public.indexpatternsservice.getidswithtitle.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;Array&lt;{</code><br/><code> id: string;</code><br/><code> title: string;</code><br/><code> }&gt;&gt;</code> | Get list of index pattern ids with titles |
3233
| [getTitles](./kibana-plugin-plugins-data-public.indexpatternsservice.gettitles.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;string[]&gt;</code> | Get list of index pattern titles |
3334
| [refreshFields](./kibana-plugin-plugins-data-public.indexpatternsservice.refreshfields.md) | | <code>(indexPattern: IndexPattern) =&gt; Promise&lt;void&gt;</code> | Refresh field list for a given index pattern |
3435
| [savedObjectToSpec](./kibana-plugin-plugins-data-public.indexpatternsservice.savedobjecttospec.md) | | <code>(savedObject: SavedObject&lt;IndexPatternAttributes&gt;) =&gt; IndexPatternSpec</code> | Converts index pattern saved object to index pattern spec |

src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts

+19
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ export class IndexPatternsService {
138138
return this.savedObjectsCache.map((obj) => obj?.attributes?.title);
139139
};
140140

141+
/**
142+
* Get list of index pattern ids with titles
143+
* @param refresh Force refresh of index pattern list
144+
*/
145+
getIdsWithTitle = async (
146+
refresh: boolean = false
147+
): Promise<Array<{ id: string; title: string }>> => {
148+
if (!this.savedObjectsCache || refresh) {
149+
await this.refreshSavedObjectsCache();
150+
}
151+
if (!this.savedObjectsCache) {
152+
return [];
153+
}
154+
return this.savedObjectsCache.map((obj) => ({
155+
id: obj?.id,
156+
title: obj?.attributes?.title,
157+
}));
158+
};
159+
141160
/**
142161
* Clear index pattern list cache
143162
* @param id optionally clear a single id

src/plugins/data/public/public.api.md

+4
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,10 @@ export class IndexPatternsService {
13871387
// Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
13881388
getFieldsForWildcard: (options?: GetFieldsOptions) => Promise<any>;
13891389
getIds: (refresh?: boolean) => Promise<string[]>;
1390+
getIdsWithTitle: (refresh?: boolean) => Promise<Array<{
1391+
id: string;
1392+
title: string;
1393+
}>>;
13901394
getTitles: (refresh?: boolean) => Promise<string[]>;
13911395
// (undocumented)
13921396
migrate(indexPattern: IndexPattern, newTitle: string): Promise<this>;

x-pack/plugins/security_solution/common/constants.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const APP_ICON = 'securityAnalyticsApp';
1111
export const APP_ICON_SOLUTION = 'logoSecurity';
1212
export const APP_PATH = `/app/security`;
1313
export const ADD_DATA_PATH = `/app/home#/tutorial_directory/security`;
14-
export const ADD_INDEX_PATH = `/app/management/kibana/indexPatterns/create`;
1514
export const DEFAULT_BYTES_FORMAT = 'format:bytes:defaultPattern';
1615
export const DEFAULT_DATE_FORMAT = 'dateFormat';
1716
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz';
@@ -58,6 +57,8 @@ export const APP_TIMELINES_PATH = `${APP_PATH}/timelines`;
5857
export const APP_CASES_PATH = `${APP_PATH}/cases`;
5958
export const APP_MANAGEMENT_PATH = `${APP_PATH}/administration`;
6059

60+
export const DETECTIONS_SUB_PLUGIN_ID = `${APP_ID}:${SecurityPageName.detections}`;
61+
6162
/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events */
6263
export const DEFAULT_INDEX_PATTERN = [
6364
'apm-*-transaction*',

x-pack/plugins/security_solution/common/search_strategy/common/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface PaginationInputPaginated {
7171

7272
export interface DocValueFields {
7373
field: string;
74-
format: string;
74+
format?: string | null;
7575
}
7676

7777
export interface Explanation {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import { IIndexPattern } from 'src/plugins/data/public';
7+
import {
8+
IEsSearchRequest,
9+
IEsSearchResponse,
10+
IFieldSubType,
11+
} from '../../../../../../src/plugins/data/common';
12+
import { DocValueFields, Maybe } from '../common';
13+
14+
export type BeatFieldsFactoryQueryType = 'beatFields';
15+
16+
interface FieldInfo {
17+
category: string;
18+
description?: string;
19+
example?: string | number;
20+
format?: string;
21+
name: string;
22+
type?: string;
23+
}
24+
25+
export interface IndexField {
26+
/** Where the field belong */
27+
category: string;
28+
/** Example of field's value */
29+
example?: Maybe<string | number>;
30+
/** whether the field's belong to an alias index */
31+
indexes: Array<Maybe<string>>;
32+
/** The name of the field */
33+
name: string;
34+
/** The type of the field's values as recognized by Kibana */
35+
type: string;
36+
/** Whether the field's values can be efficiently searched for */
37+
searchable: boolean;
38+
/** Whether the field's values can be aggregated */
39+
aggregatable: boolean;
40+
/** Description of the field */
41+
description?: Maybe<string>;
42+
format?: Maybe<string>;
43+
/** the elastic type as mapped in the index */
44+
esTypes?: string[];
45+
subType?: IFieldSubType;
46+
readFromDocValues: boolean;
47+
}
48+
49+
export type BeatFields = Record<string, FieldInfo>;
50+
51+
export interface IndexFieldsStrategyRequest extends IEsSearchRequest {
52+
indices: string[];
53+
onlyCheckIfIndicesExist: boolean;
54+
}
55+
56+
export interface IndexFieldsStrategyResponse extends IEsSearchResponse {
57+
indexFields: IndexField[];
58+
indicesExist: string[];
59+
}
60+
61+
export interface BrowserField {
62+
aggregatable: boolean;
63+
category: string;
64+
description: string | null;
65+
example: string | number | null;
66+
fields: Readonly<Record<string, Partial<BrowserField>>>;
67+
format: string;
68+
indexes: string[];
69+
name: string;
70+
searchable: boolean;
71+
type: string;
72+
}
73+
74+
export type BrowserFields = Readonly<Record<string, Partial<BrowserField>>>;
75+
76+
export const EMPTY_BROWSER_FIELDS = {};
77+
export const EMPTY_DOCVALUE_FIELD: DocValueFields[] = [];
78+
export const EMPTY_INDEX_PATTERN: IIndexPattern = {
79+
fields: [],
80+
title: '',
81+
};

x-pack/plugins/security_solution/common/search_strategy/timeline/events/details/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface TimelineEventsDetailsStrategyResponse extends IEsSearchResponse
2222

2323
export interface TimelineEventsDetailsRequestOptions
2424
extends Partial<TimelineRequestOptionsPaginated> {
25-
defaultIndex: string[];
2625
indexName: string;
2726
eventId: string;
2827
}

x-pack/plugins/security_solution/common/types/timeline/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export const SavedTimelineRuntimeType = runtimeTypes.partial({
239239
excludedRowRendererIds: unionWithNullType(runtimeTypes.array(RowRendererIdRuntimeType)),
240240
favorite: unionWithNullType(runtimeTypes.array(SavedFavoriteRuntimeType)),
241241
filters: unionWithNullType(runtimeTypes.array(SavedFilterRuntimeType)),
242+
indexNames: unionWithNullType(runtimeTypes.array(runtimeTypes.string)),
242243
kqlMode: unionWithNullType(runtimeTypes.string),
243244
kqlQuery: unionWithNullType(SavedFilterQueryQueryRuntimeType),
244245
title: unionWithNullType(runtimeTypes.string),
@@ -398,3 +399,5 @@ export const importTimelineResultSchema = runtimeTypes.exact(
398399
);
399400

400401
export type ImportTimelineResultSchema = runtimeTypes.TypeOf<typeof importTimelineResultSchema>;
402+
403+
export type TimelineEventsType = 'all' | 'raw' | 'alert' | 'signal' | 'custom';

0 commit comments

Comments
 (0)