-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process processors in kibana as yaml
- Loading branch information
Showing
2 changed files
with
63 additions
and
11 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
46 changes: 46 additions & 0 deletions
46
...ynthetics/server/synthetics_service/formatters/private_formatters/processors_formatter.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,46 @@ | ||
/* | ||
* 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 { ProcessorFields } from './format_synthetics_policy'; | ||
import { MonitorFields } from '../../../../common/runtime_types'; | ||
|
||
type Fields = Record<string, string | boolean>; | ||
|
||
interface FieldProcessor { | ||
add_fields: { | ||
target: string; | ||
fields: Fields; | ||
}; | ||
} | ||
|
||
export const processorsFormatter = (config: Partial<MonitorFields & ProcessorFields>) => { | ||
const fields: Fields = { | ||
'monitor.fleet_managed': true, | ||
}; | ||
if (config.test_run_id) { | ||
fields.test_run_id = config.test_run_id; | ||
} | ||
if (config['monitor.project.name']) { | ||
fields['monitor.project.name'] = config['monitor.project.name']; | ||
} | ||
if (config['monitor.project.id']) { | ||
fields['monitor.project.id'] = config['monitor.project.id']; | ||
} | ||
if (config['monitor.id']) { | ||
fields['monitor.id'] = config['monitor.id']; | ||
} | ||
const processors: FieldProcessor[] = [ | ||
{ | ||
add_fields: { | ||
fields, | ||
target: '', | ||
}, | ||
}, | ||
]; | ||
|
||
return JSON.stringify(processors); | ||
}; |