15 lines
680 B
Bash
Executable File
15 lines
680 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
BASE=http://opensearch:9200
|
|
code=$(curl -sS -o /tmp/host-metrics-policy.json -w '%{http_code}' \
|
|
"$BASE/_plugins/_ism/policies/host-metrics-retention")
|
|
case "$code" in
|
|
404) curl -fsS -X PUT "$BASE/_plugins/_ism/policies/host-metrics-retention" \
|
|
-H 'Content-Type: application/json' --data-binary @/bootstrap/retention-policy.json ;;
|
|
200) echo 'Preserving existing retention policy.' ;;
|
|
*) cat /tmp/host-metrics-policy.json; exit 1 ;;
|
|
esac
|
|
curl -fsS -X PUT "$BASE/_index_template/host-metrics-v1" \
|
|
-H 'Content-Type: application/json' --data-binary @/bootstrap/index-template.json
|
|
echo 'OpenSearch template and retention ready.'
|