A plugin for mocking observations (inputs) for testing and demo purposes
The mode currently mocks 2 types of observation data:
- Common key-value pairs, that are generated statically and are the same for each generated observation/input (see 'helpers/CommonGenerator.ts')
- Randomly generated integer values for predefined keys (see 'helpers/RandIntGenerator.ts')
timestamp-from
,timestamp-to
andduration
define time buckets for which to generate observations.generators
define which fields to generate for each observationscomponents
define the components for which to generate observations for. The observations generated according totimestamp-from
,timestamp-to
,duration
andgenerators
will be duplicated for each component.
N/A
The plugin's global-config
section in the manifest file determines its behaviour.
'inputs' section is ignored.
const mockObservations = MockObservations({
'timestamp-from': '2023-07-06T00:00',
'timestamp-to': '2023-07-06T00:10',
duration: 60,
components: {
'instance-type': 'A1',
},
generators: {
common: {
region: 'uk-west',
},
},
});
const result = await mockObservations.execute([]);
IF users will typically call the plugin as part of a pipeline defined in a manifest
file. In this case, instantiating the plugin is handled by ie
and does not have to be done explicitly by the user. The following is an example manifest
that calls mock-observation
:
name: mock-observation-demo
description: example invoking mock-observation plugin
tags:
initialize:
plugins:
mock-observations:
kind: plugin
method: MockObservations
path: '@grnsft/if-plugins'
global-config:
timestamp-from: 2023-07-06T00:00
timestamp-to: 2023-07-06T00:10
duration: 60
components:
- instance-type: A1
- instance-type: B1
generators:
common:
region: uk-west
common-key: common-val
randint:
cpu/utilization:
min: 1
max: 99
memory/utilization:
min: 1
max: 99
tree:
children:
child:
pipeline:
- mock-observations
inputs:
You can run this example manifest
by saving it as ./examples/manifests/test/mock-observation.yml
and executing the following command from the project root:
npm i -g @grnsft/if
npm i -g @grnsft/if-plugins
ie --manifest ./examples/manifests/test/mock-observation.yml --output ./examples/outputs/mock-observation.yml
The results will be saved to a new yaml
file in ./examples/outputs
.