-
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.
Browse files
Browse the repository at this point in the history
…#137929) (cherry picked from commit 76c55a2) Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
- Loading branch information
1 parent
7e2cdf4
commit 91337f4
Showing
9 changed files
with
456 additions
and
119 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
100 changes: 83 additions & 17 deletions
100
...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.
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
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.