DevOps/ELK

[ELK] Reindex 적용

땅지원 2024. 10. 2. 13:21

새로운 데이터 스트림 생성

PUT /_data_stream/logs-errpt-infra-test

 

해당 index를 새로운 데이터 스트림에 reindex 시킴

POST _reindex?wait_for_completion=false

{

 "source": {

  "index": ".ds-logs-errpt-infra-2024.08.19-000012"

 },

 "dest": {

  "index": "logs-errpt-infra-test",

  "op_type": "create"

 }

}

동일한 데이터스트림에서 reindex 시도 시 이미 존재하고 있는 index 때문에 정상적인 수행이 안됨.

따라서 새로운 인덱스에 reindex를 임시로 수행

op_type : create 없이 진행한다고 해도 추천하는 방법이 아님

여기서 index templates가 적용이 안되는게 맞지만 보통 index templates의 index pattern이 logs-errpt-infra-*가 되기 때문에 자연스레 적용이 된다.

reindex 백그라운드 실행 내용 확인

GET _tasks/VEtuYxAoR--O-DmsVI2twQ:1597749706

 

복사본을 원래 데이터 스트림에 reindex

POST _reindex?wait_for_completion=false

{

 "source": {

  "index": ".ds-logs-errpt-infra-test-2024.09.24-000001"

 },

 "dest": {

  "index": "logs-errpt-infra",

  "op_type": "create"

 }

}


이때, 데이터 스트림에 새로운 index가 생겨나는게 아닌 마지막 인덱스에 포함되게됨.

rollover를 하게 되면 새롭게 가능

reindex 백그라운드 실행 내용 확인
GET _tasks/VEtuYxAoR--O-DmsVI2twQ:1597777995 


원본 index와 복제본 데이터 스트림 삭제
DELETE .ds-logs-errpt-infra-2024.08.19-000012

DELETE  logs-errpt-infra-test