Skip to content

Commit

Permalink
Account for scaling_factor property from ECS
Browse files Browse the repository at this point in the history
This is a required field for e.g. scaled_float fields, so we need to
reflect its value in our field map.
  • Loading branch information
rylnd committed Jan 14, 2022
1 parent 1009642 commit ba8b93d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@ export const ecsFieldMap = {
type: 'scaled_float',
array: false,
required: false,
scaling_factor: 1000,
},
'host.disk.read.bytes': {
type: 'long',
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/rule_registry/common/field_map/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export interface FieldMap {
required?: boolean;
array?: boolean;
path?: string;
scaling_factor?: number;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ async function generate() {
const flatYaml = await yaml.safeLoad(await readFile(ecsYamlFilename));

const fields = mapValues(flatYaml, (description) => {
return {
const field = {
type: description.type,
array: description.normalize.includes('array'),
required: !!description.required,
};

if (description.scaling_factor) {
field.scaling_factor = description.scaling_factor;
}

return field;
});

await Promise.all([
Expand Down

0 comments on commit ba8b93d

Please sign in to comment.