mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Add support for fields of type aggregate_metric_double (#154920)
## Summary Add support for fields of type `aggregate_metric_double` in EPM. Change in package spec introduced in https://github.com/elastic/package-spec/pull/500. Fixes https://github.com/elastic/kibana/issues/154867 Closes https://github.com/elastic/package-spec/issues/457 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios. ### How to test * Modify a package to include a field with type `aggregate_metric_double`, for example like this: ``` - name: some_metric type: aggregate_metric_double metrics: [ "min", "max", "sum", "value_count" ] default_metric: "max" ``` * Install elastic package with this branch of the package-spec included: https://github.com/elastic/package-spec/pull/500, for this, from an elastic-package working directory: * `go mod edit -replace github.com/elastic/package-spec/v2=github.com/elastic/package-spec@main` * `go mod tidy` * `make install` * Build the package with `elastic-package build -v`. * Install the package with `elastic-package install -v`. * Check that the template contains the expected field. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ddd2e7e317
commit
65a116fed7
3 changed files with 34 additions and 0 deletions
|
@ -1034,6 +1034,28 @@ describe('EPM template', () => {
|
|||
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(metaFieldMapping));
|
||||
});
|
||||
|
||||
it('tests processing field of aggregate_metric_double type', () => {
|
||||
const fieldLiteralYaml = `
|
||||
- name: aggregate_metric
|
||||
type: aggregate_metric_double
|
||||
metrics: ["min", "max", "sum", "value_count"]
|
||||
default_metric: "max"
|
||||
`;
|
||||
const fieldMapping = {
|
||||
properties: {
|
||||
aggregate_metric: {
|
||||
metrics: ['min', 'max', 'sum', 'value_count'],
|
||||
default_metric: 'max',
|
||||
type: 'aggregate_metric_double',
|
||||
},
|
||||
},
|
||||
};
|
||||
const fields: Field[] = safeLoad(fieldLiteralYaml);
|
||||
const processedFields = processFields(fields);
|
||||
const mappings = generateMappings(processedFields);
|
||||
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(fieldMapping));
|
||||
});
|
||||
|
||||
it('tests priority and index pattern for data stream without dataset_is_prefix', () => {
|
||||
const dataStreamDatasetIsPrefixUnset = {
|
||||
type: 'metrics',
|
||||
|
|
|
@ -326,6 +326,14 @@ function _generateMappings(
|
|||
const dateMappings = generateDateMapping(field);
|
||||
fieldProps = { ...fieldProps, ...dateMappings, type: 'date' };
|
||||
break;
|
||||
case 'aggregate_metric_double':
|
||||
fieldProps = {
|
||||
...fieldProps,
|
||||
metrics: field.metrics,
|
||||
default_metric: field.default_metric,
|
||||
type: 'aggregate_metric_double',
|
||||
};
|
||||
break;
|
||||
default:
|
||||
fieldProps.type = type;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,10 @@ export interface Field {
|
|||
dimension?: boolean;
|
||||
default_field?: boolean;
|
||||
|
||||
// Fields specific of the aggregate_metric_double type
|
||||
metrics?: string[];
|
||||
default_metric?: string;
|
||||
|
||||
// Meta fields
|
||||
metric_type?: string;
|
||||
unit?: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue