diff --git a/salt/elasticsearch/defaults.yaml b/salt/elasticsearch/defaults.yaml index 5336eb2ed..618d778ea 100644 --- a/salt/elasticsearch/defaults.yaml +++ b/salt/elasticsearch/defaults.yaml @@ -111,15 +111,23 @@ elasticsearch: match_mapping_type: string settings: index: + lifecycle: + name: so-case-logs mapping: total_fields: limit: 1500 number_of_replicas: 0 + auto_expand_replicas: 0-2 number_of_shards: 1 refresh_interval: 30s sort: field: '@timestamp' order: desc + policy: + phases: + hot: + actions: {} + min_age: 0ms so-common: close: 30 delete: 365 @@ -258,15 +266,23 @@ elasticsearch: match_mapping_type: string settings: index: + lifecycle: + name: so-detection-logs mapping: total_fields: limit: 1500 number_of_replicas: 0 + auto_expand_replicas: 0-2 number_of_shards: 1 refresh_interval: 30s sort: field: '@timestamp' order: desc + policy: + phases: + hot: + actions: {} + min_age: 0ms so-endgame: index_sorting: false index_template: diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index 2c91430e7..8ade9e5b9 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -520,7 +520,7 @@ post_to_2.4.110() { } post_to_2.4.120() { - echo "Nothing to apply" + update_elasticsearch_index_settings POSTVERSION=2.4.120 } @@ -718,7 +718,7 @@ up_to_2.4.120() { add_hydra_pillars # this is needed for the new versionlock state - mkdir /opt/so/saltstack/local/pillar/versionlock + mkdir -p /opt/so/saltstack/local/pillar/versionlock touch /opt/so/saltstack/local/pillar/versionlock/adv_versionlock.sls /opt/so/saltstack/local/pillar/versionlock/soc_versionlock.sls # New Grid Integration added this release @@ -960,6 +960,30 @@ update_airgap_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 + ilm_name=$idx + if [ "$idx" = "so-detectionhistory" ]; then + ilm_name="so-detection" + elif [ "$idx" = "so-casehistory" ]; then + ilm_name="so-case" + fi + JSON_STRING=$( jq -n --arg ILM_NAME "$ilm_name" '{"settings": {"index.auto_expand_replicas":"0-2","index.lifecycle.name":($ILM_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" + curl -K /opt/so/conf/elasticsearch/curl.config -s -k -L -H "Content-Type: application/json" "https://localhost:9200/$idx/_settings" -d "$JSON_STRING" -XPUT + echo -e "\n" + else + echo -e "Skipping $idx... index does not exist\n" + fi + done +} + update_salt_mine() { echo "Populating the mine with mine_functions for each host." set +e