This application generates and indexes test data for alerting framework by mimicking Beats.
jq
installed globallybrew install jq
npm
npm install
./generate {indexer}
indexers:custom-index
,metrics
,logs
Important : You can modify or add a new doc during the execution. Each indexer listens for changes in their own docs
directory! So you can turn an active alert into recovered by changing a value in a doc.
Notes:
- Elasticsearch and Kibana must be running.
- It may require you to change
generate
file's permission.
Then run:sudo chmod 755 'generate'
It has two components: Indexers and Generators.
Indexers are the modules that consume the given json files as schema under docs
directories in of each of them to generate and push data to Elasticsearch.
There are 3 indexers:
-
custom-index
- Creates an index in Elasticsearch with the given name in its config file
- Generates data by using the schemas under its docs directory. (The docs to use must be defined in its config as an array)
- Pushes generated data to the index that it has created
Generated data could be used to create an
Index Threshold
orElasticsearch Query
rule -
metrics
- Installs Metricbeat (if it's not already installed) to format Kibana (Templates, ILM, Dashboard etc.)
- Creates a Data Stream
metricbeat-{version}
- Generates data by using the schemas under its docs directory. You can add docs as many as you want but don't forget to add them to the modules config
- Pushes generated data to the Data Stream that it has created
Currently, the metricbeat version (8.1.2) is hardcoded in thegenerate
script.
Generated data could be used to create anInventory
orMetric Threshold
rule
-
logs
- Installs Filebeat (if it's not already installed) to format Kibana (Templates, ILM, Dashboard etc.)
- Creates a Data Stream
filebeat-{version}
- Generates data by using the schemas under its docs directory. You can add docs as many as you want but don't forget to add them to the modules config
- Pushes generated data to the Data Stream that it has created
Currently, the filebeat version (8.1.2) is hardcoded in thegenerate
script.
Generated data could be used to create aLog Threshold
rule
Generators are basic data generators that takes an object tah has a generatorType
and some other parameters and returns a result.
There are 7 generators:
- uuid
Input schema:Output: A random uuid e.g.{ "generatorType": "uuid" }
19e99b66-b9c6-11ec-8422-0242ac120002
- iso8601
Input schema:Output: Datetime stamp of now e.g.{ "generatorType": "iso8601" }
2022-04-11T17:56:39+00:00
- increment
Input schema:
Output:{ "generatorType": "increment", "params": { "id": "1", "start": 1, "incrementBy": 5 } }
At each execution, a new integer is returned, starting withstart
and increasing the last number held in memory byincrementBy
.id
is used to identify the latest value in memory. e.g. 1, 6, 11, 16, 21... - randomInt
Input schema:Output: A random integer between{ "generatorType": "randomInt", "params": { "min": 1, "max": 5 } }
min
andmax
e.g.2
- randomFloat
Input schema:Output: A random float between{ "generatorType": "randomFloat", "params": { "min": 1, "max": 5 } }
min
andmax
e.g.2.01
- dictionay
Input schema:Output: A random word from the given dictionary.{ "generatorType": "dictionary", "params": { "value": "word" } }
Dictionaries are stored undersrc/generators/dictionaries
directory.
There are already two dictionariesword
andnames
.
A new dictionary can be simply defined by adding a json file to the dictionay directory and using the file name in the schema. - sineWave
Input schema:
Output:{ "generatorType": "sineWave", "params": { "min": 0, "max": 8, "period": 16 } }
At each execution, a new float is returned betweenmin
andmax
e.g. 3 - 4 - 5 - 6 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 2 - 3 .....
For more info about sine wave: https://en.wikipedia.org/wiki/Sine_wave
{
"@timestamp": { "generatorType": "iso8601" },
"name": "test-doc",
"id": { "generatorType": "uuid" },
"data_number": {
"generatorType": "randomInt",
"params": { "min": 1, "max": 5 }
},
"data_float": {
"generatorType": "randomFloat",
"params": { "min": 1, "max": 5 }
},
"data_string": {
"generatorType": "dictionary",
"params": { "value": "word" }
},
"data_nested": {
"cpu": {
"usage": {
"generatorType": "randomFloat",
"params": { "min": 1, "max": 5 }
}
}
},
"data_increment": {
"generatorType": "increment",
"params": { "id": "1", "start": 1, "incrementBy": 5 }
},
"data_wave": {
"generatorType": "sineWave",
"params": {
"min": 0,
"max": 8,
"period": 16
}
}
}