|
| 1 | +# ILM |
| 2 | +Architecture hot-warm-cold là gì: |
| 3 | +Các logs của ngày hôm nay đang được lập index, trong khi các logs của tuần này được mong muốn nhất (host). Nhật ký của tuần trước cũng có thể tìm kiếm được, nhưng không thường xuyên như nhật ký (warm) của tuần hiện tại. Mặt khác, nhật ký của tháng trước có thể được xem rất thường xuyên hoặc không thường xuyên (cold) |
| 4 | + |
| 5 | + |
| 6 | +# Step 1 create Index Lifecycle Policies |
| 7 | +Management → Index Lifecycle Policies → Create |
| 8 | + |
| 9 | +Add name policy |
| 10 | + |
| 11 | +Thiết lập độ ưu tiên của từng giai đoạn |
| 12 | +- Host |
| 13 | + |
| 14 | +Default được thiết lập ở 30 ngày 50Gb tùy điều kiện nào đến trước |
| 15 | +- Warm |
| 16 | + |
| 17 | +Thiết lập khoảng thời gian được lưu trữ tại warm |
| 18 | +- Cold |
| 19 | + |
| 20 | +Thiết lập khoảng thời gian được lưu trữ tại Cold |
| 21 | +- Delete |
| 22 | + |
| 23 | +Xóa index theo thời gian chỉ định |
| 24 | +- Save policy |
| 25 | +# Step 2 Create Index templates |
| 26 | +Management → Index Management →Index Templates |
| 27 | + |
| 28 | +Legacy index templates → Create Legacy Templates |
| 29 | + |
| 30 | +Logistics: |
| 31 | + |
| 32 | +- Add name index template |
| 33 | + |
| 34 | +- Index patterns ( nginx-*) |
| 35 | + |
| 36 | +Index settings : |
| 37 | +```bash |
| 38 | +{ |
| 39 | + "index": { |
| 40 | + "number_of_shards": "1", |
| 41 | + "refresh_interval": "5s" |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | +Mappings : |
| 46 | + |
| 47 | +Aliases Next ( bỏ qua ) |
| 48 | + |
| 49 | +Review ( Save ) |
| 50 | +# Step 3 add policy to index template |
| 51 | +Chọn policy cần thêm vào index template |
| 52 | + |
| 53 | +Click Show legacy index templates |
| 54 | + |
| 55 | +chọn template |
| 56 | + |
| 57 | +add alias |
| 58 | + |
| 59 | + |
| 60 | +Add policy |
| 61 | +# Step 4 configuration output logstash |
| 62 | +```bash |
| 63 | +output { |
| 64 | + if "nginx" in [type] { |
| 65 | + elasticsearch { |
| 66 | + hosts => ["localhost:9200"] |
| 67 | + index => "%{[type]}-%{+YYYY.MM.dd}-000001" |
| 68 | + manage_template => true |
| 69 | + template_name => "nginx-template" |
| 70 | + ilm_enabled => true |
| 71 | + ilm_rollover_alias => "nginx" |
| 72 | + ilm_pattern => "000001" |
| 73 | + |
| 74 | + } |
| 75 | + } |
| 76 | + if "nginx" not in [tags] { |
| 77 | + elasticsearch { |
| 78 | + hosts => ["localhost:9200"] |
| 79 | + index => "calico-%{+YYYY.MM.dd}" |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | +- name index phải khớp với pattern ^.*-\d+$, ví dụ (my-index-000001). |
| 85 | +
|
| 86 | +- template_name : name template vừa tạo trên giao diện console |
| 87 | +
|
| 88 | +- ilm_rollover_alias : đặt alias cho index |
| 89 | +
|
| 90 | +- ilm_pattern : the pattern to use for the index names là một số tăng dần |
| 91 | +
|
| 92 | +## Policy 60day |
| 93 | +Host 30d or 50GB |
| 94 | +
|
| 95 | +Warm 7d |
| 96 | +
|
| 97 | +Cold 30d |
| 98 | +
|
| 99 | +Delete 60d |
0 commit comments