rollover

개발새발·2023년 1월 1일
0

elasticsearch

목록 보기
42/54

왜케 간만에 쓰는 기분이지 ? 했는데 정말 간만에 쓴다 ㅋㅋㅋ 한동안 다른일때문에 정신이 없었다. 이번주엔 회사에서 로그관련해서 키바나를 한참을 들여다봤는데 뭔가 이상한 것이다.. 자꾸 ElasticsearchSecurityException[action [indices:admin/rollover] is unauthorized for user [remote_monitoring_user] with roles [remote_monitoring_collector,remote_monitoring_agent] on indices [filebeat-7.14.2,filebeat-7.14.2-2022.07.01-000001], this action is granted by the index privileges [manage_follow_index,manage,all]] 이런 에러가 나서 파보다가 rollover에 대해 먼저 알아보기로 했다.

Rollover 이란

로그 또는 메트릭과 같이 시계열 데이터(*데이터 스트림을 통해서 시계열 데이터를 관리하는 곳이 좋다.)를 인덱싱할 때, 단일 인덱스를 무기한으로 쓸 수는 없다. 한 인덱스에 계속해서 대량의 문서가 남아있기 때문이다. 때문에 롤오버를 통해서 일부 임계값이 충족되면 새 인덱스를 만들고 그곳에 쓰기를 시작할 수 있게 해준다.

자동 Rollover 방법

rollover은 index기준이 아닌 alias 기준으로 수행된다. index는 rollover때마다 이름이 바뀌기 때문에 rollover rule를 정의해야한다.

  1. rolling policy 만들기
    키바나의 index lifecycle policies 에서 rollover 세팅을 정한다. max_primary_shard_size 가 10기가 바이트이거나 max_age 가 14일 또는 인덱스 사이즈가 50기가바이트 또는 문서수가 25개이면 index가 rolling 된다.
  1. index template 생성
    PUT _template/rolling
    {
     "order": 1,
     "version": 1,
     "index_patterns": [
       "rolling*"
     ],
     "settings": {
       "index": {
         "lifecycle": {
           "name": "rolling",
           "rollover_alias": "rolling-write-index"
         },
         "number_of_shards" : "1",
         "number_of_replicas" : "0"
       }
     }
    }

rolling 이라는 이름의 모든 인덱스에 rolling 라이프사이클을 적용하고, rollover 대상인 alias는 rolling-write-index 라는 alias이다.

  1. index와 alias 생성

    PUT rolling-test-000001
    {
     "aliases": {
       "rolling-write-index": { "is_write_index": true }
     }
    }```

참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/index-rollover.html , https://velog.io/@diane_at_work/Elasticsearch-auto-rollover-적용

profile
발새발개

0개의 댓글