From 719062e800ef64b2a95552e0ca2fd936f1b096be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 2 Nov 2023 19:29:47 +0100 Subject: [PATCH] Add a script to configure the rollover policy --- scripts/indexer-ism-init.sh | 208 ++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 scripts/indexer-ism-init.sh 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 <