Skip to content

Commit 38cf5b0

Browse files
AlexRuiz7Jorgesnchz
authored andcommitted
Update documentation of the ECS tooling (#67)
1 parent e34e482 commit 38cf5b0

File tree

1 file changed

+59
-23
lines changed

1 file changed

+59
-23
lines changed

ecs/README.md

+59-23
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,72 @@ This script generates the ECS mappings for the Wazuh indices.
55
### Requirements
66

77
- ECS repository clone. The script is meant to be launched from the root level of that repository.
8-
- Python 3.6 or higher
9-
- jq
8+
- `Python` 3.6 or higher + `venv` module
9+
- `jq`
1010

11-
### Folder structrue
11+
### Folder structure
1212

1313
There is a folder for each module. Inside each folder, there is a `fields` folder with the required
1414
files to generate the mappings. These are the inputs for the ECS generator.
1515

1616
### Usage
1717

18-
**Copy the `generate.sh` script to the root level of the ECS repository.**
18+
1. Get a copy of the ECS repository at the same level as the `wazuh-indexer` repo:
1919

20-
Use the `generate.sh` script to generate the mappings for a module. The script takes 3 arguments,
21-
plus 2 optional arguments to upload the mappings to the Wazuh indexer (using **composable** indexes).
20+
```console
21+
git clone [email protected]:elastic/ecs.git
22+
```
2223

23-
```plaintext
24-
Usage: ./generate.sh <ECS_VERSION> <INDEXER_SRC> <MODULE> [--upload <URL>]
25-
* ECS_VERSION: ECS version to generate mappings for
26-
* INDEXER_SRC: Path to the wazuh-indexer repository
27-
* MODULE: Module to generate mappings for
28-
* --upload <URL>: Upload generated index template to the OpenSearch cluster. Defaults to https://localhost:9200
29-
Example: ./generate.sh v8.10.0 ~/wazuh-indexer vulnerability-detector --upload https://indexer:9200
30-
```
24+
2. Install the dependencies:
3125

32-
For example, to generate the mappings for the `vulnerability-detector` module using the
33-
ECS version `v8.10.0` and the Wazuh indexer in path `~/wazuh/wazuh-indexer`:
26+
```console
27+
cd ecs
28+
python3 -m venv env
29+
source env/bin/activate
30+
pip install -r scripts/requirements.txt
31+
```
3432

35-
```bash
36-
./generate.sh v8.10.0 ~/wazuh/wazuh-indexer vulnerability-detector
37-
```
33+
2. Copy the `generate.sh` script to the root level of the ECS repository.
34+
35+
```console
36+
cp generate.sh ../../ecs
37+
cd ../../ecs
38+
bash generate.sh
39+
```
40+
41+
Expected output:
42+
```
43+
Usage: generate.sh <ECS_VERSION> <INDEXER_SRC> <MODULE> [--upload <URL>]
44+
* ECS_VERSION: ECS version to generate mappings for
45+
* INDEXER_SRC: Path to the wazuh-indexer repository
46+
* MODULE: Module to generate mappings for
47+
* --upload <URL>: Upload generated index template to the OpenSearch cluster. Defaults to https://localhost:9200
48+
Example: generate.sh v8.10.0 ~/wazuh-indexer vulnerability-detector --upload https://indexer:9200
49+
```
50+
51+
3. Use the `generate.sh` script to generate the mappings for a module. The script takes 3 arguments,
52+
plus 2 optional arguments to upload the mappings to the `wazuh-indexer`. Both, composable and legacy mappings
53+
are generated. For example, to generate the mappings for the `vulnerability-detector` module using the
54+
ECS version `v8.10.0` and assuming that path of this repository is `~/wazuh/wazuh-indexer`:
55+
56+
```bash
57+
./generate.sh v8.10.0 ~/wazuh/wazuh-indexer vulnerability-detector
58+
```
59+
60+
The tool will output the folder where they have been generated.
61+
62+
```console
63+
Loading schemas from git ref v8.10.0
64+
Running generator. ECS version 8.10.0
65+
Replacing "match_only_text" type with "text"
66+
Mappings saved to ~/wazuh/wazuh-indexer/ecs/vulnerability-detector/mappings/v8.10.0
67+
```
68+
69+
4. When you are done. Exit the virtual environment.
70+
71+
```console
72+
deactivate
73+
```
3874

3975
### Output
4076

@@ -48,8 +84,8 @@ For our use case, the most important files are under `mappings/<ECS_VERSION>/gen
4884
The original output is `template.json`, which is not compatible with OpenSearch by default. In order
4985
to make this template compatible with OpenSearch, the following changes are made:
5086

51-
- the `order` property is renamed to `priority`.
52-
- the `mappings` and `settings` properties are nested under the `template` property.
87+
- The `order` property is renamed to `priority`.
88+
- The `mappings` and `settings` properties are nested under the `template` property.
5389

5490
The script takes care of these changes automatically, generating the `opensearch-template.json` file as a result.
5591

@@ -62,7 +98,7 @@ curl -u admin:admin -k -X PUT "https://indexer:9200/_index_template/wazuh-vulner
6298
```
6399

64100
Notes:
65-
- PUT and POST are interchangable.
101+
- PUT and POST are interchangeable.
66102
- The name of the index template does not matter. Any name can be used.
67103
- Adjust credentials and URL accordingly.
68104

@@ -95,7 +131,7 @@ The script will generate a JSON file with the events, and will also ask whether
95131
indexer. If the upload option is selected, the script will ask for the indexer URL and port, credentials,
96132
and index name.
97133

98-
The script uses log file. Check it out for debugging or additonal information.
134+
The script uses log file. Check it out for debugging or additional information.
99135

100136
#### References
101137

0 commit comments

Comments
 (0)