-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into siem-explore-148973
- Loading branch information
Showing
129 changed files
with
378 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# @kbn/ml-query-utils | ||
|
||
Query utilities. | ||
Query utilities to be used in UIs maintained by the @elastic/ml-ui team. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
x-pack/packages/ml/query_utils/src/build_base_filter_criteria.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { buildBaseFilterCriteria } from './build_base_filter_criteria'; | ||
|
||
describe('buildBaseFilterCriteria', () => { | ||
const earliestMs = 1483228800000; // 1 Jan 2017 00:00:00 | ||
const latestMs = 1485907199000; // 31 Jan 2017 23:59:59 | ||
const query = { | ||
query_string: { | ||
query: 'region:sa-east-1', | ||
analyze_wildcard: true, | ||
default_field: '*', | ||
}, | ||
}; | ||
|
||
test('returns correct criteria for time range', () => { | ||
expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs)).toEqual([ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: earliestMs, | ||
lte: latestMs, | ||
format: 'epoch_millis', | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
test('returns correct criteria for time range and query', () => { | ||
expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs, query)).toEqual([ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: earliestMs, | ||
lte: latestMs, | ||
format: 'epoch_millis', | ||
}, | ||
}, | ||
}, | ||
query, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
x-pack/packages/ml/query_utils/src/get_safe_aggregation_name.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getSafeAggregationName } from './get_safe_aggregation_name'; | ||
|
||
describe('getSafeAggregationName', () => { | ||
test('"foo" should be "foo"', () => { | ||
expect(getSafeAggregationName('foo', 0)).toBe('foo'); | ||
}); | ||
test('"foo.bar" should be "foo.bar"', () => { | ||
expect(getSafeAggregationName('foo.bar', 0)).toBe('foo.bar'); | ||
}); | ||
test('"foo&bar" should be "field_0"', () => { | ||
expect(getSafeAggregationName('foo&bar', 0)).toBe('field_0'); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
x-pack/packages/ml/query_utils/src/get_safe_aggregation_name.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/** | ||
* Returns a name which is safe to use in elasticsearch aggregations for the supplied | ||
* field name. Aggregation names must be alpha-numeric and can only contain '_' and '-' characters, | ||
* so if the supplied field names contains disallowed characters, the provided index | ||
* identifier is used to return a safe 'dummy' name in the format 'field_index' e.g. field_0, field_1 | ||
* | ||
* @param fieldName - the field name to check | ||
* @param index - the index number to be used for the safe aggregation name | ||
* @returns safe aggregation name | ||
*/ | ||
export function getSafeAggregationName(fieldName: string, index: number): string { | ||
return fieldName.match(/^[a-zA-Z0-9-_.]+$/) ? fieldName : `field_${index}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ | |
], | ||
"kbn_references": [ | ||
"@kbn/ml-is-populated-object", | ||
"@kbn/es-query", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.