diff --git a/scripts/indexer-ism-init.sh b/scripts/indexer-ism-init.sh new file mode 100644 index 0000000000000..5b77addc44e16 --- /dev/null +++ b/scripts/indexer-ism-init.sh @@ -0,0 +1,208 @@ +#!/bin/bash +# Wazuh Copyright (C) 2023 Wazuh Inc. (License GPLv2) +# Wazuh - Indexer set rollover policy and templates + +# Policy settings +MIN_SHARD_SIZE=${MIN_SHARD_SIZE:-25} +MIN_INDEX_AGE=${MIN_INDEX_AGE:-"7d"} +MIN_DOC_COUNT=${MIN_DOC_COUNT:-200000000} +ISM_INDEX_PATTERNS=${ISM_INDEX_PATTERNS:-'["wazuh-alerts-*", "wazuh-archives-*", "-wazuh-alerts-4.x-sample*"]'} +ISM_PRIORITY=${ISM_PRIORITY:-50} + +POLICY_NAME="rollover_policy" + +INDEXER_URL="https://localhost:9200" + +# curl settings shortcuts +C_AUTH="-u admin:admin" + +######################################################################### +# Creates the rollover_policy ISM policy. +# Globals: +# MIN_SHARD_SIZE: The minimum shard size in GB. +# MIN_INDEX_AGE: The minimum index age. +# MIN_DOC_COUNT: The minimum document count. +# ISM_INDEX_PATTERNS: The index patterns to apply the policy. +# ISM_PRIORITY: The policy priority. +# Arguments: +# None. +# Returns: +# The rollover policy as a JSON string +######################################################################### +function generate_rollover_policy() { + cat <