Skip to content

Commit

Permalink
Make agents and commands indexes visible (#653)
Browse files Browse the repository at this point in the history
* Make agents and commands indexes visible

Rename commands and agents indexes templates to wazuh-agents and wazuh-commands accordingly

Update ECS documents

Update .commands and .agents references

* Fix command ECS definitions not being applied

* Add revision note after changes on the commands index

---------

Co-authored-by: Álex Ruiz <[email protected]>
  • Loading branch information
QU3B1M and AlexRuiz7 authored Jan 24, 2025
1 parent bdc2b0b commit 75a45e8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ecs/agent/event-generator/event_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GENERATED_DATA_FILE = 'generatedData.json'
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
# Default values
INDEX_NAME = ".agents"
INDEX_NAME = "wazuh-agents"
USERNAME = "admin"
PASSWORD = "admin"
IP = "127.0.0.1"
Expand Down
5 changes: 2 additions & 3 deletions ecs/agent/fields/template-settings-legacy.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"index_patterns": [
".agents*"
"wazuh-agents*"
],
"order": 1,
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand All @@ -20,4 +19,4 @@
]
}
}
}
}
5 changes: 2 additions & 3 deletions ecs/agent/fields/template-settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"index_patterns": [
".agents*"
"wazuh-agents*"
],
"priority": 1,
"template": {
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand All @@ -22,4 +21,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion ecs/command/event-generator/event_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
GENERATED_DATA_FILE = 'generatedData.json'
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
# Default values
INDEX_NAME = ".commands"
INDEX_NAME = "wazuh-commands"
USERNAME = "admin"
PASSWORD = "admin"
IP = "127.0.0.1"
Expand Down
7 changes: 2 additions & 5 deletions ecs/command/fields/template-settings-legacy.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"index_patterns": [
".commands*"
],
"index_patterns": ["wazuh-commands*"],
"order": 1,
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand All @@ -17,4 +14,4 @@
]
}
}
}
}
5 changes: 2 additions & 3 deletions ecs/command/fields/template-settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"index_patterns": [
".commands*"
"wazuh-commands*"
],
"priority": 1,
"template": {
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand All @@ -19,4 +18,4 @@
}
}
}
}
}
3 changes: 1 addition & 2 deletions ecs/docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ fields:
```json
{
"index_patterns": [".agents*"],
"index_patterns": ["wazuh-agents*"],
"priority": 1,
"template": {
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand Down
6 changes: 3 additions & 3 deletions ecs/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
> rev 0.2 - September 30th, 2024: Change type of `request_id`, `order_id` and `id` to keyword.
> rev 0.3 - October 3rd, 2024: Change descriptions for `command.type`, `command.action.type`, `command.request_id`, `command.order_id`.
> rev 0.4 - October 9th, 2024: Apply changes described in https://github.com/wazuh/wazuh-indexer-plugins/issues/96#issue-2576028654.
> rev 0.5 - December 3rd, 2024: Added `@timestamp` and `delivery_timestamp` date fields.
> rev 0.5 - December 3rd, 2024: Added `@timestamp` and `delivery_timestamp` date fields.
> rev 0.6 - January 24th, 2025: Rename index to `wazuh-commands`. The index is now visible to users.
### Fields summary

Expand Down Expand Up @@ -146,12 +147,11 @@ fields:
```json
{
"index_patterns": [".commands*"],
"index_patterns": ["wazuh-commands*"],
"priority": 1,
"template": {
"settings": {
"index": {
"hidden": true,
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "5s",
Expand Down
2 changes: 1 addition & 1 deletion ecs/scripts/generate-pr-to-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ detect_modified_modules() {
module_to_file=(
[agent]="index-template-agent.json"
[alerts]="index-template-alerts.json"
[commands]="index-template-commands.json"
[command]="index-template-commands.json"
[states-fim]="index-template-fim.json"
[states-inventory-hardware]="index-template-hardware.json"
[states-inventory-hotfixes]="index-template-hotfixes.json"
Expand Down
6 changes: 3 additions & 3 deletions test-tools/scripts/07_validate_command_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ while [[ "$#" -gt 0 ]]; do
shift
done

COMMANDS_INDEX=".commands"
COMMANDS_INDEX="wazuh-commands"
SRC="Engine"
USR="TestUser"
TRG_ID="TestTarget"
Expand Down Expand Up @@ -81,7 +81,7 @@ curl -s -k -u "$USERNAME:$PASSWORD" -X POST "https://$CLUSTER_IP:9200/_forcemerg
sleep 2

# Fetch the indices
echo "Validating .commands index is created..."
echo "Validating $COMMANDS_INDEX index is created..."
INDICES_RESPONSE=$(curl -s -k -u "$USERNAME:$PASSWORD" "https://$CLUSTER_IP:9200/_cat/indices/.*?v")
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
Expand All @@ -98,7 +98,7 @@ fi
sleep 5
echo "Validate the command is created"
# Validate the command was created
SEARCH_RESPONSE=$(curl -s -k -u "$USERNAME:$PASSWORD" "https://$CLUSTER_IP:9200/.commands/_search")
SEARCH_RESPONSE=$(curl -s -k -u "$USERNAME:$PASSWORD" "https://$CLUSTER_IP:9200/$COMMANDS_INDEX/_search")
# Check if the request was successful
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 75a45e8

Please sign in to comment.