ElasticsearchShardLimitApproaching
Что означает алерт
Алерт срабатывает, когда занято более 80% лимита шардов кластера:
active_shards / (max_shards_per_node * number_of_data_nodes) > 0.80
Риск: при достижении лимита новые индексы перестанут создаваться, запись из Camunda/Zeebe в ES может тихо деградировать.
Подключение к ES в Kubernetes
Откройте локальный доступ к ES:
kubectl -n camunda port-forward svc/camunda-elasticsearch 9200:9200
Далее все команды ниже выполняются через localhost:9200.
Проверка
- Базовое состояние кластера:
curl -s localhost:9200/_cluster/health?pretty
- Получить текущий лимит и загрузку в процентах:
MAX=$(curl -s localhost:9200/_cluster/settings?flat_settings=true\&include_defaults=true | jq -r '.persistent["cluster.max_shards_per_node"] // .transient["cluster.max_shards_per_node"] // .defaults["cluster.max_shards_per_node"] // "1000"')
DATA_NODES=$(curl -s localhost:9200/_cluster/health | jq -r '.number_of_data_nodes')
ACTIVE=$(curl -s localhost:9200/_cluster/health | jq -r '.active_shards')
LIMIT=$((MAX * DATA_NODES))
USAGE=$(awk "BEGIN { printf \"%.2f\", ($ACTIVE/$LIMIT)*100 }")
echo "max_shards_per_node=$MAX data_nodes=$DATA_NODES active_shards=$ACTIVE limit=$LIMIT usage=${USAGE}%"
- Найти индексы, которые дают больше всего шардов:
curl -s 'localhost:9200/_cat/indices?format=json&h=index,pri,rep,docs.count,store.size' \
| jq -r '.[] | [.index, .pri, .rep, ((.pri|tonumber) * ((.rep|tonumber)+1)), ."docs.count", ."store.size"] | @tsv' \
| sort -k4,4nr | head -30
- Проверить unassigned/инициализирующиеся шарды:
curl -s 'localhost:9200/_cat/shards?h=index,shard,prirep,state,node,unassigned.reason&s=state'
Как починить
- Освободить шарды (предпочтительный путь):
- удалить устаревшие индексы;
- сократить retention/ILM для высокочастотных индексов;
- временно уменьшить
number_of_replicasдля не критичных исторических индексов.
Примеры:
# Список старых индексов (проверьте шаблон и дату)
curl -s 'localhost:9200/_cat/indices/camunda*?h=health,status,index,pri,rep,store.size,creation.date.string&s=creation.date:asc'
# Удаление конкретного устаревшего индекса
curl -s -X DELETE 'localhost:9200/<index-name>?pretty'
# Временное снижение реплик на конкретном индексе
curl -s -X PUT 'localhost:9200/<index-name>/_settings' \
-H 'Content-Type: application/json' \
-d '{"index":{"number_of_replicas":0}}'
- Экстренная мера, если уперлись в лимит и запись уже ломается:
curl -s -X PUT localhost:9200/_cluster/settings \
-H 'Content-Type: application/json' \
-d '{"transient":{"cluster.max_shards_per_node":1200}}'
- Проверить, что запись восстановилась, и usage ушел ниже порога:
curl -s localhost:9200/_cluster/health?pretty
Критерий закрытия
- Доля шардов стабильно ниже 70%.
- Выстроен retention/ILM, чтобы не возвращаться к постоянному росту лимита.
- Подтверждено, что новые документы/процессы снова попадают в ES/Operate.