Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize Commands Index #123

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Initialize Commands Index #123

merged 2 commits into from
Oct 25, 2024

Conversation

f-galland
Copy link
Member

Description

This PR adds the .commands index and its associated template to the setup plugin's initialization logic, so that the index gets created and the template applied upon cluster initialization.

Issues Resolved

Resolves #122

@f-galland f-galland self-assigned this Oct 25, 2024
@f-galland f-galland marked this pull request as ready for review October 25, 2024 18:13
@f-galland f-galland requested a review from a team as a code owner October 25, 2024 18:13
@f-galland
Copy link
Member Author

The index and its template get created on cluster startup:

fede@tyner:~/IdeaProjects/wazuh-indexer-plugins/plugins/command-manager (122-initialize-commands-index)
$ curl http://localhost:9200/_cat/indices/.commands
green open .commands wk1RXJRZQmqWCcu4AvcpfA 1 0 0 0 208b 208b

fede@tyner:~/IdeaProjects/wazuh-indexer-plugins/plugins/command-manager (122-initialize-commands-index)
$ curl http://localhost:9200/_cat/templates
index-template-alerts          [wazuh-alerts-5.x-*]                0  
index-template-vulnerabilities [wazuh-states-vulnerabilities*]     0  
index-template-commands        [.commands*]                        0  
index-template-system          [wazuh-states-inventory-system*]    0  
index-template-packages        [wazuh-states-inventory-packages*]  0  
index-template-agent           [.agents*]                          0  
index-template-fim             [wazuh-states-fim*]                 0  
index-template-processes       [wazuh-states-inventory-processes*] 0  


fede@tyner:~/IdeaProjects/wazuh-indexer-plugins/plugins/command-manager (122-initialize-commands-index)
$ curl http://localhost:9200/_template/index-template-commands?pretty
{
  "index-template-commands" : {
    "order" : 0,
    "index_patterns" : [
      ".commands*"
    ],
    "settings" : {
      "index" : {
        "refresh_interval" : "5s",
        "hidden" : "true",
        "number_of_shards" : "1",
        "number_of_replicas" : "0",
        "query" : {
          "default_field" : [
            "command.source",
            "command.target.type",
            "command.status",
            "command.action.name"
          ]
        }
      }
    },
    "mappings" : {
      "dynamic" : "strict",
      "date_detection" : false,
      "properties" : {
        "agent" : {
          "properties" : {
            "groups" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            }
          }
        },
        "command" : {
          "properties" : {
            "result" : {
              "properties" : {
                "code" : {
                  "type" : "short"
                },
                "data" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                },
                "message" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                }
              }
            },
            "action" : {
              "properties" : {
                "args" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                },
                "name" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                },
                "version" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                }
              }
            },
            "source" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            },
            "order_id" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            },
            "request_id" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            },
            "user" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            },
            "timeout" : {
              "type" : "short"
            },
            "status" : {
              "ignore_above" : 1024,
              "type" : "keyword"
            },
            "target" : {
              "properties" : {
                "id" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                },
                "type" : {
                  "ignore_above" : 1024,
                  "type" : "keyword"
                }
              }
            }
          }
        }
      }
    },
    "aliases" : { }
  }
}

@AlexRuiz7 AlexRuiz7 merged commit 1c654b9 into master Oct 25, 2024
1 check passed
@AlexRuiz7 AlexRuiz7 deleted the 122-initialize-commands-index branch October 25, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialize Commands Index from Indexer Setup plugin
2 participants