Skip to content

Commit

Permalink
Merge branch 'main' into lens/speed_up_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra authored Nov 12, 2024
2 parents 5f8c0b6 + abf6a1d commit 404a8a7
Show file tree
Hide file tree
Showing 316 changed files with 6,313 additions and 5,437 deletions.
26 changes: 25 additions & 1 deletion docs/user/dashboard/lens.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,37 @@ All columns that belong to the same layer pane group are sorted in the table.

* *Text alignment* — Aligns the values in the cell to the *Left*, *Center*, or *Right*.

* *Color by value* — Applies color to the cell or text values. To change the color, click the *Edit colors* icon.

* *Hide column* — Hides the column for the field.

* *Directly filter on click* — Turns column values into clickable links that allow you to filter or drill down into the data.

* *Summary row* — Adds a row that displays the summary value. When specified, allows you to enter a *Summary label*.

* *Color by value* — Applies color to the cell or text values. To change the color, click *Edit*.
[float]
[[assign-colors-to-terms]]
===== Assign colors to terms

preview::[]

For term-based metrics, assign a color to each term with color mapping.

. Create a custom table.

. In the layer pane, select a *Rows* or *Metrics* field.

. In the *Color by value* option, select *Cell* or *Text*.

. Click the *Edit colors* icon.

. Toggle the button to use the Color Mapping feature.

. Select a color palette and mode.

. Click *Add assignment* to assign a color to a specific term, or click *Add all unassigned terms* to assign colors to all terms. Assigning colors to dates is unsupported.

. Configure color assignments. You can also select whether unassigned terms should be mapped to the selected color palette or a single color.

[float]
[[drag-and-drop-keyboard-navigation]]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "^1.1.1",
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.15.0",
"@elastic/elasticsearch": "^8.15.1",
"@elastic/ems-client": "8.5.3",
"@elastic/eui": "97.3.0",
"@elastic/eui": "97.3.1",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "^1.2.3",
"@elastic/numeral": "^2.5.1",
Expand Down Expand Up @@ -1498,7 +1498,7 @@
"@octokit/rest": "^17.11.2",
"@parcel/watcher": "^2.1.0",
"@playwright/test": "=1.46.0",
"@redocly/cli": "^1.25.10",
"@redocly/cli": "^1.25.11",
"@statoscope/webpack-plugin": "^5.28.2",
"@storybook/addon-a11y": "^6.5.16",
"@storybook/addon-actions": "^6.5.16",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,25 @@ describe('catchRetryableEsClientErrors', () => {
type: 'retryable_es_client_error',
});
});
it('ResponseError with retryable status code', async () => {
const statusCodes = [503, 401, 403, 408, 410, 429];
return Promise.all(
statusCodes.map(async (status) => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
statusCode: status,
body: { error: { type: 'reason' } },
})
);
expect(
((await Promise.reject(error).catch(catchRetryableEsClientErrors)) as any).left
).toMatchObject({
message: 'reason',
type: 'retryable_es_client_error',
});
})
);
});
it.each([503, 401, 403, 408, 410, 429])(
'ResponseError with retryable status code (%d)',
async (status) => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
statusCode: status,
body: { error: { type: 'reason' } },
})
);
expect(
((await Promise.reject(error).catch(catchRetryableEsClientErrors)) as any).left
).toMatchObject({
message:
status === 410
? 'This API is unavailable in the version of Elasticsearch you are using.'
: 'reason',
type: 'retryable_es_client_error',
});
}
);
});
});
1 change: 1 addition & 0 deletions packages/deeplinks/search/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export const SEARCH_ELASTICSEARCH = 'enterpriseSearchElasticsearch';
export const SEARCH_VECTOR_SEARCH = 'enterpriseSearchVectorSearch';
export const SEARCH_SEMANTIC_SEARCH = 'enterpriseSearchSemanticSearch';
export const SEARCH_AI_SEARCH = 'enterpriseSearchAISearch';
export const SEARCH_INDICES_CREATE_INDEX = 'createIndex';
6 changes: 5 additions & 1 deletion packages/deeplinks/search/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SEARCH_HOMEPAGE,
SEARCH_INDICES_START,
SEARCH_INDICES,
SEARCH_INDICES_CREATE_INDEX,
SEARCH_ELASTICSEARCH,
SEARCH_VECTOR_SEARCH,
SEARCH_SEMANTIC_SEARCH,
Expand Down Expand Up @@ -55,6 +56,8 @@ export type AppsearchLinkId = 'engines';

export type RelevanceLinkId = 'inferenceEndpoints';

export type SearchIndicesLinkId = typeof SEARCH_INDICES_CREATE_INDEX;

export type DeepLinkId =
| EnterpriseSearchApp
| EnterpriseSearchContentApp
Expand All @@ -77,4 +80,5 @@ export type DeepLinkId =
| SearchElasticsearch
| SearchVectorSearch
| SearchSemanticSearch
| SearchAISearch;
| SearchAISearch
| `${SearchIndices}:${SearchIndicesLinkId}`;
1 change: 0 additions & 1 deletion packages/kbn-apm-synthtrace/src/lib/shared/base_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class SynthtraceEsClient<TFields extends Fields> {
await this.client.indices.resolveIndex({
name: this.indices.join(','),
expand_wildcards: ['open', 'hidden'],
// @ts-expect-error ignore_unavailable is not in the type definition, but it is accepted by es
ignore_unavailable: true,
})
).indices.map((index: { name: string }) => index.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ describe('single line query', () => {
});
});

describe('SHOW', () => {
/** @todo Enable once show command args are parsed as columns. */
test.skip('info page', () => {
const { text } = reprint('SHOW info');

expect(text).toBe('SHOW info');
});
});

describe('STATS', () => {
test('with aggregates assignment', () => {
const { text } = reprint('FROM a | STATS var = agg(123, fn(true))');
Expand All @@ -100,6 +91,30 @@ describe('single line query', () => {
expect(text).toBe('FROM a | STATS A(1), B(2) BY asdf');
});
});

describe('GROK', () => {
test('two basic arguments', () => {
const { text } = reprint('FROM search-movies | GROK Awards "text"');

expect(text).toBe('FROM search-movies | GROK Awards "text"');
});
});

describe('DISSECT', () => {
test('two basic arguments', () => {
const { text } = reprint('FROM index | DISSECT input "pattern"');

expect(text).toBe('FROM index | DISSECT input "pattern"');
});

test('with APPEND_SEPARATOR option', () => {
const { text } = reprint(
'FROM index | DISSECT input "pattern" APPEND_SEPARATOR="<separator>"'
);

expect(text).toBe('FROM index | DISSECT input "pattern" APPEND_SEPARATOR = "<separator>"');
});
});
});

describe('expressions', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,83 @@ const reprint = (src: string, opts?: WrappingPrettyPrinterOptions) => {
return { text };
};

describe('commands', () => {
describe('GROK', () => {
test('two basic arguments', () => {
const { text } = reprint('FROM search-movies | GROK Awards "text"');

expect(text).toBe('FROM search-movies | GROK Awards "text"');
});

test('two long arguments', () => {
const { text } = reprint(
'FROM search-movies | GROK AwardsAwardsAwardsAwardsAwardsAwardsAwardsAwards "texttexttexttexttexttexttexttexttexttexttexttexttexttexttext"'
);

expect('\n' + text).toBe(`
FROM search-movies
| GROK
AwardsAwardsAwardsAwardsAwardsAwardsAwardsAwards
"texttexttexttexttexttexttexttexttexttexttexttexttexttexttext"`);
});
});

describe('DISSECT', () => {
test('two basic arguments', () => {
const { text } = reprint('FROM index | DISSECT input "pattern"');

expect(text).toBe('FROM index | DISSECT input "pattern"');
});

test('two long arguments', () => {
const { text } = reprint(
'FROM index | DISSECT InputInputInputInputInputInputInputInputInputInputInputInputInputInput "PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern"'
);

expect('\n' + text).toBe(`
FROM index
| DISSECT
InputInputInputInputInputInputInputInputInputInputInputInputInputInput
"PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern"`);
});

test('with APPEND_SEPARATOR option', () => {
const { text } = reprint(
'FROM index | DISSECT input "pattern" APPEND_SEPARATOR="<separator>"'
);

expect(text).toBe('FROM index | DISSECT input "pattern" APPEND_SEPARATOR = "<separator>"');
});

test('two long arguments with short APPEND_SEPARATOR option', () => {
const { text } = reprint(
'FROM index | DISSECT InputInputInputInputInputInputInputInputInputInputInputInputInputInput "PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern" APPEND_SEPARATOR="sep"'
);

expect('\n' + text).toBe(`
FROM index
| DISSECT
InputInputInputInputInputInputInputInputInputInputInputInputInputInput
"PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern"
APPEND_SEPARATOR = "sep"`);
});

test('two long arguments with long APPEND_SEPARATOR option', () => {
const { text } = reprint(
'FROM index | DISSECT InputInputInputInputInputInputInputInputInputInputInputInputInputInput "PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern" APPEND_SEPARATOR="<SeparatorSeparatorSeparatorSeparatorSeparatorSeparatorSeparatorSeparator>"'
);

expect('\n' + text).toBe(`
FROM index
| DISSECT
InputInputInputInputInputInputInputInputInputInputInputInputInputInput
"PatternPatternPatternPatternPatternPatternPatternPatternPatternPattern"
APPEND_SEPARATOR =
"<SeparatorSeparatorSeparatorSeparatorSeparatorSeparatorSeparatorSeparator>"`);
});
});
});

describe('casing', () => {
test('can chose command name casing', () => {
const query = 'FROM index | WHERE a == 123';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { ESQLAstBaseItem, ESQLAstCommand, ESQLAstQueryExpression } from '../types';
import { ESQLAstExpressionNode, Visitor } from '../visitor';
import { resolveItem } from '../visitor/utils';
import { commandOptionsWithEqualsSeparator, commandsWithNoCommaArgSeparator } from './constants';
import { LeafPrinter } from './leaf_printer';

export interface BasicPrettyPrinterOptions {
Expand Down Expand Up @@ -378,7 +379,8 @@ export class BasicPrettyPrinter {
args += (args ? ', ' : '') + arg;
}

const argsFormatted = args ? ` ${args}` : '';
const separator = commandOptionsWithEqualsSeparator.has(ctx.node.name) ? ' = ' : ' ';
const argsFormatted = args ? `${separator}${args}` : '';
const optionFormatted = `${option}${argsFormatted}`;

return optionFormatted;
Expand All @@ -392,7 +394,10 @@ export class BasicPrettyPrinter {
let options = '';

for (const source of ctx.visitArguments()) {
args += (args ? ', ' : '') + source;
const needsSeparator = !!args;
const needsComma = !commandsWithNoCommaArgSeparator.has(ctx.node.name);
const separator = needsSeparator ? (needsComma ? ',' : '') + ' ' : '';
args += separator + source;
}

for (const option of ctx.visitOptions()) {
Expand Down
52 changes: 52 additions & 0 deletions packages/kbn-esql-ast/src/pretty_print/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

/**
* This set tracks commands that don't use commas to separate their
* arguments.
*
* Normally ES|QL command arguments are separated by commas.
*
* ```
* COMMAND arg1, arg2, arg3
* ```
*
* But there are some commands (namely `grok` and `dissect`) which don't
* use commas to separate their arguments.
*
* ```
* GROK input "pattern"
* DISSECT input "pattern"
* ```
*/
export const commandsWithNoCommaArgSeparator = new Set(['grok', 'dissect']);

/**
* This set tracks command options which use an equals sign to separate
* the option label from the option value.
*
* Most ES|QL commands use a space to separate the option label from the
* option value.
*
* ```
* COMMAND arg1, arg2, arg3 OPTION option
* FROM index METADATA _id
* ```
*
* However, the `APPEND_SEPARATOR` in the `DISSECT` command uses an equals
* sign to separate the option label from the option value.
*
* ```
* DISSECT input "pattern" APPEND_SEPARATOR = "separator"
* |
* |
* equals sign
* ```
*/
export const commandOptionsWithEqualsSeparator = new Set(['append_separator']);
Loading

0 comments on commit 404a8a7

Please sign in to comment.