-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Support dynamic_template mappings from object field
- Loading branch information
Showing
7 changed files
with
388 additions
and
111 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
111 changes: 99 additions & 12 deletions
111
...gins/fleet/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/mappings.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,48 @@ | ||
/* | ||
* 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 type { Field } from '../../fields/field'; | ||
|
||
const DEFAULT_SCALING_FACTOR = 1000; | ||
|
||
interface Properties { | ||
[key: string]: any; | ||
} | ||
|
||
export function getDefaultProperties(field: Field): Properties { | ||
const properties: Properties = {}; | ||
|
||
if (field.index !== undefined) { | ||
properties.index = field.index; | ||
} | ||
if (field.doc_values !== undefined) { | ||
properties.doc_values = field.doc_values; | ||
} | ||
if (field.copy_to) { | ||
properties.copy_to = field.copy_to; | ||
} | ||
|
||
return properties; | ||
} | ||
|
||
export function scaledFloat(field: Field): Properties { | ||
const fieldProps = getDefaultProperties(field); | ||
fieldProps.type = 'scaled_float'; | ||
fieldProps.scaling_factor = field.scaling_factor || DEFAULT_SCALING_FACTOR; | ||
if (field.metric_type) { | ||
fieldProps.time_series_metric = field.metric_type; | ||
} | ||
|
||
return fieldProps; | ||
} | ||
|
||
export function histogram(field: Field): Properties { | ||
const fieldProps = getDefaultProperties(field); | ||
fieldProps.type = 'histogram'; | ||
|
||
return fieldProps; | ||
} |
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.