-
Notifications
You must be signed in to change notification settings - Fork 4
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 wazuh-indexer-setup
plugin
#3
Comments
wazuh-indexer-setup-plugin
wazuh-indexer-setup
plugin
Installed the plugin in a production environment
|
Test scenarioDuring the testing of the rollover + alias feature that was planned for 4.8.0, we saw that it was possible to index data before the initialization process was completed. As a result, indices were created without mappings or settings, completely messing up Wazuh's indexing workflow. See wazuh/wazuh#18999. We through we could solve this race condition using plugins. The plugin will hook into the Indexer's initialization process to create all the index templates required by Wazuh, naturally blocking any indexing request during the process. Test resultsUsing a test environment with OpenSearch 2.14.0, I built and installed the PoC plugin from #4. The test consists of trying to index anything to the #!/bin/bash
USERNAME="admin"
PASSWORD="SecretPassword.1234"
# If OpenSearch is running, remove the wazuh-indexer-setup-plugin index and restart the service
curl -X DELETE https://192.168.56.10:9200/wazuh-indexer-setup-plugin -k -u $USERNAME:$PASSWORD
systemctl restart opensearch
while true; do
echo "Injecting..."
curl -X POST https://192.168.56.10:9200/wazuh-indexer-setup-plugin/_doc -k -u $USERNAME:$PASSWORD -H 'Content-Type: application/json' -d '{"type":"test"}'
sleep 50e-3 # 50 ms
done The test has been executed several times, returning the same results: [vagrant@rhel9 ~]$ sudo bash injector.sh
{"acknowledged":true}Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
OpenSearch Security not initialized.Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"PD6OdJABKFzsAk5STmRx","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"PT6OdJABKFzsAk5STmT-","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"Pj6OdJABKFzsAk5ST2SV","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":2,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"Pz6OdJABKFzsAk5SUGQn","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":3,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"QD6OdJABKFzsAk5SUGS7","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":4,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"QT6OdJABKFzsAk5SUWRP","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":5,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"Qj6OdJABKFzsAk5SUWTY","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":6,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"Qz6OdJABKFzsAk5SUmRl","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":7,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"RD6OdJABKFzsAk5SUmT8","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":8,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"RT6OdJABKFzsAk5SU2SS","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":9,"_primary_term":1}Injecting...
{"_index":"wazuh-indexer-setup-plugin","_id":"Rj6OdJABKFzsAk5SVGQr","_version":1,"result":"created","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":10,"_primary_term":1}Injecting... As we can see, the script first prepares the test scenario by removing the target index and restart OpenSearch. On start, the plugin will create the index template. At the same time, the script tries to index a document every 50ms. All the indexing requests are ignored until the initialization process is completed. The index is created correctly, using the mappings and settings defined by the plugin. |
Description
Create the basic folder structure and source code for the Wazuh Indexer initialization plugin.
The plugin must be able to use OpenSearch's lifecycle to initialize a set of index templates (see wazuh/wazuh-indexer#270).
The text was updated successfully, but these errors were encountered: