Skip to content

Commit 283fb56

Browse files
Merge branch 'master' into adding-additional-runtime-mapping-checks
2 parents ece974f + c0f9bfc commit 283fb56

56 files changed

Lines changed: 715 additions & 433 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.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[role="xpack"]
2+
[[banners-settings-kb]]
3+
=== Banner settings in {kib}
4+
++++
5+
<titleabbrev>Banners settings</titleabbrev>
6+
++++
7+
8+
Banners are disabled by default. You need to manually configure them in order to use the feature.
9+
10+
You can configure the `xpack.banners` settings in your `kibana.yml` file.
11+
12+
[[general-banners-settings-kb]]
13+
==== General banner settings
14+
15+
[cols="2*<"]
16+
|===
17+
18+
| `xpack.banners.placement`
19+
| Set to `header` to enable the header banner. Defaults to `disabled`.
20+
21+
| `xpack.banners.textContent`
22+
| The text to display inside the banner, either plain text or Markdown.
23+
24+
| `xpack.banners.textColor`
25+
| The color for the banner text. Defaults to `#8A6A0A`.
26+
27+
| `xpack.banners.backgroundColor`
28+
| The color of the banner background. Defaults to `#FFF9E8`.
29+
30+
|===
31+
32+
[NOTE]
33+
====
34+
The `banners` plugin is a https://www.elastic.co/subscriptions[subscription feature]
35+
====

docs/settings/settings-xkb.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For more {kib} configuration settings, see <<settings>>.
1212

1313
include::alert-action-settings.asciidoc[]
1414
include::apm-settings.asciidoc[]
15+
include::banners-settings.asciidoc[]
1516
include::dev-settings.asciidoc[]
1617
include::graph-settings.asciidoc[]
1718
include::infrastructure-ui-settings.asciidoc[]

docs/setup/settings.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ Valid locales are: `en`, `zh-CN`, `ja-JP`. *Default: `en`*
685685

686686
include::{kib-repo-dir}/settings/alert-action-settings.asciidoc[]
687687
include::{kib-repo-dir}/settings/apm-settings.asciidoc[]
688+
include::{kib-repo-dir}/settings/banners-settings.asciidoc[]
688689
include::{kib-repo-dir}/settings/dev-settings.asciidoc[]
689690
include::{kib-repo-dir}/settings/graph-settings.asciidoc[]
690691
include::{kib-repo-dir}/settings/fleet-settings.asciidoc[]

test/functional/apps/discover/_data_grid_doc_table.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
5858
await PageObjects.timePicker.setDefaultAbsoluteRange();
5959
});
6060

61-
it('should show popover with expanded cell content by click on expand button', async () => {
61+
// flaky https://github.com/elastic/kibana/issues/94889
62+
it.skip('should show popover with expanded cell content by click on expand button', async () => {
6263
log.debug('open popover with expanded cell content to get json from the editor');
6364
const documentCell = await dataGrid.getCellElement(1, 3);
6465
await documentCell.click();

x-pack/plugins/file_upload/common/types.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,73 @@
55
* 2.0.
66
*/
77

8+
import { ES_FIELD_TYPES } from '../../../../src/plugins/data/common';
9+
10+
export interface InputOverrides {
11+
[key: string]: string | undefined;
12+
}
13+
14+
export type FormattedOverrides = InputOverrides & {
15+
column_names: string[];
16+
has_header_row: boolean;
17+
should_trim_fields: boolean;
18+
};
19+
20+
export interface AnalysisResult {
21+
results: FindFileStructureResponse;
22+
overrides?: FormattedOverrides;
23+
}
24+
25+
export interface FindFileStructureResponse {
26+
charset: string;
27+
has_header_row: boolean;
28+
has_byte_order_marker: boolean;
29+
format: string;
30+
field_stats: {
31+
[fieldName: string]: {
32+
count: number;
33+
cardinality: number;
34+
top_hits: Array<{ count: number; value: any }>;
35+
mean_value?: number;
36+
median_value?: number;
37+
max_value?: number;
38+
min_value?: number;
39+
earliest?: string;
40+
latest?: string;
41+
};
42+
};
43+
sample_start: string;
44+
num_messages_analyzed: number;
45+
mappings: {
46+
properties: {
47+
[fieldName: string]: {
48+
// including all possible Elasticsearch types
49+
// since find_file_structure API can be enhanced to include new fields in the future
50+
type: Exclude<
51+
ES_FIELD_TYPES,
52+
ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE
53+
>;
54+
format?: string;
55+
};
56+
};
57+
};
58+
quote: string;
59+
delimiter: string;
60+
need_client_timezone: boolean;
61+
num_lines_analyzed: number;
62+
column_names?: string[];
63+
explanation?: string[];
64+
grok_pattern?: string;
65+
multiline_start_pattern?: string;
66+
exclude_lines_pattern?: string;
67+
java_timestamp_formats?: string[];
68+
joda_timestamp_formats?: string[];
69+
timestamp_field?: string;
70+
should_trim_fields?: boolean;
71+
}
72+
73+
export type InputData = any[];
74+
875
export interface ImportResponse {
976
success: boolean;
1077
id: string;

x-pack/plugins/ml/server/models/file_data_visualizer/file_data_visualizer.ts renamed to x-pack/plugins/file_upload/server/analyze_file.tsx

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,38 @@ import { IScopedClusterClient } from 'kibana/server';
99
import {
1010
AnalysisResult,
1111
FormattedOverrides,
12+
InputData,
1213
InputOverrides,
1314
FindFileStructureResponse,
14-
} from '../../../common/types/file_datavisualizer';
15-
16-
export type InputData = any[];
17-
18-
export function fileDataVisualizerProvider(client: IScopedClusterClient) {
19-
async function analyzeFile(data: InputData, overrides: InputOverrides): Promise<AnalysisResult> {
20-
overrides.explain = overrides.explain === undefined ? 'true' : overrides.explain;
21-
const {
22-
body,
23-
} = await client.asInternalUser.textStructure.findStructure<FindFileStructureResponse>({
24-
body: data,
25-
...overrides,
26-
});
27-
28-
const { hasOverrides, reducedOverrides } = formatOverrides(overrides);
29-
30-
return {
31-
...(hasOverrides && { overrides: reducedOverrides }),
32-
results: body,
33-
};
34-
}
15+
} from '../common';
16+
17+
export async function analyzeFile(
18+
client: IScopedClusterClient,
19+
data: InputData,
20+
overrides: InputOverrides
21+
): Promise<AnalysisResult> {
22+
overrides.explain = overrides.explain === undefined ? 'true' : overrides.explain;
23+
const {
24+
body,
25+
} = await client.asInternalUser.textStructure.findStructure<FindFileStructureResponse>({
26+
body: data,
27+
...overrides,
28+
});
29+
30+
const { hasOverrides, reducedOverrides } = formatOverrides(overrides);
3531

3632
return {
37-
analyzeFile,
33+
...(hasOverrides && { overrides: reducedOverrides }),
34+
results: body,
3835
};
3936
}
4037

4138
function formatOverrides(overrides: InputOverrides) {
4239
let hasOverrides = false;
4340

4441
const reducedOverrides: FormattedOverrides = Object.keys(overrides).reduce((acc, overrideKey) => {
45-
const overrideValue: string = overrides[overrideKey];
46-
if (overrideValue !== '') {
42+
const overrideValue: string | undefined = overrides[overrideKey];
43+
if (overrideValue !== undefined && overrideValue !== '') {
4744
if (overrideKey === 'column_names') {
4845
acc.column_names = overrideValue.split(',');
4946
} else if (overrideKey === 'has_header_row') {

x-pack/plugins/file_upload/server/import_data.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import { INDEX_META_DATA_CREATED_BY } from '../common/constants';
1010
import {
1111
ImportResponse,
1212
ImportFailure,
13+
InputData,
1314
Settings,
1415
Mappings,
1516
IngestPipelineWrapper,
1617
} from '../common';
1718

18-
export type InputData = any[];
19-
2019
export function importDataProvider({ asCurrentUser }: IScopedClusterClient) {
2120
async function importData(
2221
id: string | undefined,

x-pack/plugins/file_upload/server/routes.ts

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
* 2.0.
66
*/
77

8+
import { schema } from '@kbn/config-schema';
89
import { IRouter, IScopedClusterClient } from 'kibana/server';
9-
import { MAX_FILE_SIZE_BYTES, IngestPipelineWrapper, Mappings, Settings } from '../common';
10+
import {
11+
MAX_FILE_SIZE_BYTES,
12+
IngestPipelineWrapper,
13+
InputData,
14+
Mappings,
15+
Settings,
16+
} from '../common';
1017
import { wrapError } from './error_wrapper';
11-
import { InputData, importDataProvider } from './import_data';
18+
import { analyzeFile } from './analyze_file';
19+
import { importDataProvider } from './import_data';
1220

1321
import { updateTelemetry } from './telemetry';
14-
import { importFileBodySchema, importFileQuerySchema } from './schemas';
22+
import { analyzeFileQuerySchema, importFileBodySchema, importFileQuerySchema } from './schemas';
1523

1624
function importData(
1725
client: IScopedClusterClient,
@@ -30,6 +38,44 @@ function importData(
3038
* Routes for the file upload.
3139
*/
3240
export function fileUploadRoutes(router: IRouter) {
41+
/**
42+
* @apiGroup FileDataVisualizer
43+
*
44+
* @api {post} /api/file_upload/analyze_file Analyze file data
45+
* @apiName AnalyzeFile
46+
* @apiDescription Performs analysis of the file data.
47+
*
48+
* @apiSchema (query) analyzeFileQuerySchema
49+
*/
50+
router.post(
51+
{
52+
path: '/api/file_upload/analyze_file',
53+
validate: {
54+
body: schema.any(),
55+
query: analyzeFileQuerySchema,
56+
},
57+
options: {
58+
body: {
59+
accepts: ['text/*', 'application/json'],
60+
maxBytes: MAX_FILE_SIZE_BYTES,
61+
},
62+
tags: ['access:fileUpload:analyzeFile'],
63+
},
64+
},
65+
async (context, request, response) => {
66+
try {
67+
const result = await analyzeFile(
68+
context.core.elasticsearch.client,
69+
request.body,
70+
request.query
71+
);
72+
return response.ok({ body: result });
73+
} catch (e) {
74+
return response.customError(wrapError(e));
75+
}
76+
}
77+
);
78+
3379
/**
3480
* @apiGroup FileDataVisualizer
3581
*

x-pack/plugins/file_upload/server/schemas.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77

88
import { schema } from '@kbn/config-schema';
99

10+
export const analyzeFileQuerySchema = schema.object({
11+
charset: schema.maybe(schema.string()),
12+
column_names: schema.maybe(schema.string()),
13+
delimiter: schema.maybe(schema.string()),
14+
explain: schema.maybe(schema.string()),
15+
format: schema.maybe(schema.string()),
16+
grok_pattern: schema.maybe(schema.string()),
17+
has_header_row: schema.maybe(schema.string()),
18+
line_merge_size_limit: schema.maybe(schema.string()),
19+
lines_to_sample: schema.maybe(schema.string()),
20+
quote: schema.maybe(schema.string()),
21+
should_trim_fields: schema.maybe(schema.string()),
22+
timeout: schema.maybe(schema.string()),
23+
timestamp_field: schema.maybe(schema.string()),
24+
timestamp_format: schema.maybe(schema.string()),
25+
});
26+
1027
export const importFileQuerySchema = schema.object({
1128
id: schema.maybe(schema.string()),
1229
});

x-pack/plugins/ml/common/types/capabilities.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ export function getPluginPrivileges() {
102102
return {
103103
admin: {
104104
...privilege,
105-
api: ['fileUpload:import', ...allMlCapabilitiesKeys.map((k) => `ml:${k}`)],
105+
api: [
106+
'fileUpload:import',
107+
'fileUpload:analyzeFile',
108+
...allMlCapabilitiesKeys.map((k) => `ml:${k}`),
109+
],
106110
catalogue: [PLUGIN_ID, `${PLUGIN_ID}_file_data_visualizer`],
107111
ui: allMlCapabilitiesKeys,
108112
savedObject: {
@@ -116,7 +120,7 @@ export function getPluginPrivileges() {
116120
},
117121
user: {
118122
...privilege,
119-
api: userMlCapabilitiesKeys.map((k) => `ml:${k}`),
123+
api: ['fileUpload:analyzeFile', ...userMlCapabilitiesKeys.map((k) => `ml:${k}`)],
120124
catalogue: [PLUGIN_ID],
121125
management: { insightsAndAlerting: [] },
122126
ui: userMlCapabilitiesKeys,

0 commit comments

Comments
 (0)