update soup; check for index before applying new index setting

Signed-off-by: reyesj2 <94730068+reyesj2@users.noreply.github.com>
This commit is contained in:
reyesj2
2024-11-11 22:40:06 -06:00
parent ce9bd18947
commit aaf9f53695

View File

@@ -520,16 +520,7 @@ post_to_2.4.110() {
} }
post_to_2.4.120() { post_to_2.4.120() {
for idx in "so-detection" "so-detectionhistory" "so-case" "so-casehistory"; do update_elasticsearch_index_settings
JSON_STRING=$( jq -n \
--arg INDEX_NAME "$idx" \
'{"settings": {"index.auto_expand_replicas":"0-2","index.lifecycle.name":($INDEX_NAME + "-logs")}}'
)
echo "Updating $idx index settings"
retry 5 15 "so-elasticsearch-query $idx/_settings -d "$JSON_STRING" -XPUT| grep '{\"acknowledged\":true}'"
echo ""
done
POSTVERSION=2.4.120 POSTVERSION=2.4.120
} }
@@ -947,6 +938,23 @@ update_airgap_repo() {
createrepo /nsm/repo createrepo /nsm/repo
} }
update_elasticsearch_index_settings() {
# Update managed indices to reflect latest index template
for idx in "so-detection" "so-detectionhistory" "so-case" "so-casehistory"; do
JSON_STRING=$( jq -n --arg INDEX_NAME "$idx" '{"settings": {"index.auto_expand_replicas":"0-2","index.lifecycle.name":($INDEX_NAME + "-logs")}}')
echo "Checking if index \"$idx\" exists"
exists=$(curl -K /opt/so/conf/elasticsearch/curl.config -s -o /dev/null -w "%{http_code}" -k -L -H "Content-Type: application/json" "https://localhost:9200/$idx")
if [ $exists -eq 200 ]; then
echo "$idx index found..."
echo "Updating $idx index settings"
so-elasticsearch-query $idx/_settings -d "$JSON_STRING" -XPUT
echo -e "\n"
else
echo -e "Skipping $idx... index does not exist\n"
fi
done
}
update_salt_mine() { update_salt_mine() {
echo "Populating the mine with mine_functions for each host." echo "Populating the mine with mine_functions for each host."
set +e set +e