Skip to content

Commit eae121a

Browse files
authored
Create Lifecycle_index_policy.md
1 parent 2b41b56 commit eae121a

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

ELK/Lifecycle_index_policy.md

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
![image](https://github.com/HuyPham01/docs/assets/96679595/e2a94606-650b-414b-8841-0eb10622fee8)
5+
6+
# Step 1 create Index Lifecycle Policies
7+
Management → Index Lifecycle Policies → Create
8+
![image](https://github.com/HuyPham01/docs/assets/96679595/09197427-9ea6-469e-8dd9-6158bef1a3dc)
9+
Add name policy
10+
![image](https://github.com/HuyPham01/docs/assets/96679595/f1fe29e8-e6f8-4451-95ca-d6dd2452b087)
11+
Thiết lập độ ưu tiên của từng giai đoạn
12+
- Host
13+
![image](https://github.com/HuyPham01/docs/assets/96679595/0defd110-7b9b-4ded-86d5-204bf8a036ab)
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+
![image](https://github.com/HuyPham01/docs/assets/96679595/4f2c643d-8c5a-4a34-bdef-74d9c0e33f48)
17+
Thiết lập khoảng thời gian được lưu trữ tại warm
18+
- Cold
19+
![image](https://github.com/HuyPham01/docs/assets/96679595/f78b9847-d9ce-42f5-afbb-a96a6d027844)
20+
Thiết lập khoảng thời gian được lưu trữ tại Cold
21+
- Delete
22+
![image](https://github.com/HuyPham01/docs/assets/96679595/93c8e413-32d4-457a-ab19-fb8ab01dfa98)
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+
![image](https://github.com/HuyPham01/docs/assets/96679595/739dca1f-019b-42da-a667-72d5f33159df)
28+
Legacy index templates → Create Legacy Templates
29+
![image](https://github.com/HuyPham01/docs/assets/96679595/3793437b-b6b9-4618-a863-144a120a9a14)
30+
Logistics:
31+
32+
- Add name index template
33+
34+
- Index patterns ( nginx-*)
35+
![image](https://github.com/HuyPham01/docs/assets/96679595/54453b9e-fcaf-459a-a858-07b559074b5f)
36+
Index settings :
37+
```bash
38+
{
39+
"index": {
40+
"number_of_shards": "1",
41+
"refresh_interval": "5s"
42+
}
43+
}
44+
```
45+
Mappings :
46+
![image](https://github.com/HuyPham01/docs/assets/96679595/831cb73f-9c5c-4cdb-9a0e-e62e2cf01cb2)
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+
![image](https://github.com/HuyPham01/docs/assets/96679595/d64de610-e40b-48d3-92b0-cac823fa5c3f)
53+
Click Show legacy index templates
54+
55+
chọn template
56+
57+
add alias
58+
![image](https://github.com/HuyPham01/docs/assets/96679595/c6197e6a-4d75-47be-a787-85a4254c1966)
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

Comments
 (0)