SIEM/Log Management Triển khai Opensearch services phân tầng hot warm cold, phân quyền user và tenants

Mục lục
I. Giới thiệu
1. Opensearch
2. Cấu trúc hot warm cold
3. Mục đích triển khai
II. Các bước triển khai
III. Cấu hình thêm (Optional)
IV. Kết luận

I. Giới thiệu
1. Opensearch
1773404973362.png

OpenSearch là một nền tảng mã nguồn mở dùng để lưu trữ, tìm kiếm và phân tích dữ liệu lớn theo thời gian thực. Nó được phát triển bởi Amazon Web Services và cộng đồng, dựa trên phiên bản mã nguồn mở của Elasticsearch và Kibana.
OpenSearch thường được dùng để:
  • Thu thập và phân tích log hệ thống
  • Giám sát và phân tích dữ liệu (observability)
  • Xây dựng SIEM / SOC
  • Tạo dashboard và trực quan hóa dữ liệu
Một hệ thống OpenSearch thường gồm:
  • OpenSearch Engine: lưu trữ và tìm kiếm dữ liệu
  • OpenSearch Dashboards: giao diện web để truy vấn và hiển thị dữ liệu
Nó có khả năng mở rộng theo cụm (cluster), tìm kiếm rất nhanh và xử lý dữ liệu lớn hiệu quả

2. Cấu trúc hot warm cold
1773405058849.png

Hot – Warm – Cold là mô hình phân tầng lưu trữ dữ liệu log thường được sử dụng trong các hệ thống SIEM triển khai trên OpenSearch hoặc Elasticsearch nhằm tối ưu hiệu năng truy vấn và chi phí lưu trữ. Dữ liệu log sẽ được lưu trữ theo nhiều tầng khác nhau dựa trên thời gian và tần suất truy cập.
Hot tier: lưu trữ các log mới nhất (thường vài ngày gần nhất), chạy trên server có hiệu năng cao như SSD và RAM lớn để phục vụ việc tìm kiếm, phân tích và phát hiện sự kiện bảo mật theo thời gian thực. Đây là tầng được truy cập nhiều nhất trong hệ thống SIEM.
Warm tier: lưu trữ các log trung hạn (ví dụ vài tuần), sử dụng phần cứng có cấu hình trung bình hơn. Dữ liệu ở tầng này vẫn có thể truy vấn bình thường nhưng tần suất truy cập thấp hơn so với hot tier.
Cold tier: lưu trữ các log lâu dài (vài tháng hoặc hơn) trên các hệ thống lưu trữ chi phí thấp như HDD. Tầng này chủ yếu dùng khi cần điều tra sự cố bảo mật, kiểm toán (audit) hoặc phân tích lịch sử.
Trong quá trình vận hành, dữ liệu log sẽ tự động di chuyển theo vòng đời Hot → Warm → Cold thông qua cơ chế quản lý vòng đời index (Index State Management) của OpenSearch, giúp hệ thống SIEM duy trì hiệu năng cao cho dữ liệu mới đồng thời giảm chi phí lưu trữ cho dữ liệu cũ
3. Mục tiêu triển khai
Triển khai hệ thống OpenSearch trên một server duy nhất nhưng vẫn áp dụng kiến trúc phân tầng lưu trữ Hot – Warm – Cold nhằm mô phỏng mô hình lưu trữ dữ liệu thường dùng trong các hệ thống SIEM. Mục tiêu của việc triển khai này là tổ chức dữ liệu log theo từng tầng dựa trên thời gian và tần suất truy cập, từ đó tối ưu hiệu năng truy vấn và quản lý vòng đời dữ liệu.
Trong mô hình này, hệ thống sẽ được cấu hình với ba node logic trên cùng một máy chủ, mỗi node đảm nhiệm một vai trò lưu trữ khác nhau gồm Hot, Warm và Cold. Dữ liệu log mới sẽ được ghi vào Hot tier để phục vụ việc tìm kiếm và phân tích thời gian thực. Sau một khoảng thời gian nhất định, dữ liệu sẽ được chuyển sang Warm tier để lưu trữ trung hạn với tần suất truy cập thấp hơn. Cuối cùng, dữ liệu cũ sẽ được chuyển sang Cold tier để lưu trữ dài hạn với chi phí tài nguyên thấp hơn.
Việc di chuyển dữ liệu giữa các tầng sẽ được quản lý tự động thông qua cơ chế Index State Management (ISM) của OpenSearch, cho phép định nghĩa chính sách vòng đời của index và tự động chuyển dữ liệu từ Hot → Warm → Cold theo các điều kiện thời gian hoặc dung lượng. Mô hình này giúp hệ thống vừa đảm bảo khả năng phân tích nhanh đối với dữ liệu mới, vừa tối ưu tài nguyên lưu trữ cho dữ liệu cũ trong môi trường triển khai thử nghiệm hoặc quy mô nhỏ
II. Các bước triển khai
Tiến hành cài đặt opensearch theo hướng dẫn từ trang chính thức của opensearch
Sau khi đã update tiến hành cài đặt opensearch phiên bản 3.5.0
sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=<custom-admin-password> apt-get install opensearch=3.5.0

Sau khi cài đặt tiến hành phân vùng cho các lớp hot warm và cold
Tùy theo nhu cầu xài sẽ lượng tài nguyên cho mỗi vùng khác nhau. Ở đây ta thiết kế phân vùng hot sẽ 100GB, hot và cold đều 200GB
1773635253519.png

Tiến hành tạo các thư mục để lưu trữ dữ liệu
mkdir -p /data/opensearch/hot
mkdir -p /data/opensearch/warm
mkdir -p /data/opensearch/cold
Sau đó mount các ổ đĩa đã chuẩn bị cho từng thư mục
mount /dev/sdb1 /data/opensearch/hot
mount /dev/sdb2 /data/opensearch/warm
mount /dev/sdb3 /data/opensearch/cold
1773423508309.png

Sơ đồ triển khai các services
1773425740030.png


Sau khi cài đặt tiến hành tạo certs để các node trong từng services có thể kết nối lẫn nhau
Đầu tiên tiến hành tạo CA
openssl genrsa -out root-ca-key.pem 4096
openssl req -new -x509 \
-days 3650 \
-key root-ca-key.pem \
-out root-ca.pem
Sau đó tiến hành tạo certs cho từng node
hot node

openssl genrsa -out hot-key.pem 2048

openssl req -new \
-key hot-key.pem \
-out hot.csr

openssl x509 -req \
-in hot.csr \
-CA root-ca.pem \
-CAkey root-ca-key.pem \
-CAcreateserial \
-out hot.pem \
-days 365


Tương tự cho node warm và cold
Sau đó tiến hành tạo các thư mục để chứa các cấu hình cho từng node

sudo mkdir -p /etc/opensearch-hot
sudo mkdir -p /etc/opensearch-warm
sudo mkdir -p /etc/opensearch-cold
Sau đó copy các file cấu hình từ opensearch chính sang các thư mục đã tạo
sudo cp /etc/opensearch/opensearch.yml /etc/opensearch-hot/
sudo cp /etc/opensearch/opensearch.yml /etc/opensearch-warm/
sudo cp /etc/opensearch/opensearch.yml /etc/opensearch-cold/
Tiến hành sửa cấu hình trong opensearch.yml như sau

cluster.name: soc-cluster

node.name: hot-node
node.roles: [cluster_manager, data]
node.attr.temp: hot

path.data: /data/opensearch/hot

path.logs: /var/log/opensearch-hot

network.host: 0.0.0.0

http.port: 9200
transport.port: 9300

discovery.seed_hosts:
- 127.0.0.1:9300
- 127.0.0.1:9301
- 127.0.0.1:9302
- 127.0.0.1:9303

# WARNING: revise all the lines below before you go into production
plugins.security.ssl.transport.pemcert_filepath: certs/node-hot.pem
plugins.security.ssl.transport.pemkey_filepath: certs/node-hot-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: certs/root-ca.pem
transport.ssl.enforce_hostname_verification: false
plugins.security.ssl.http.enabled: true
plugins.security.ssl.http.pemcert_filepath: certs/node-hot.pem
plugins.security.ssl.http.pemkey_filepath: certs/node-hot-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: certs/root-ca.pem
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
- "CN=admin,OU=SIEM,O=Poptech,L=HCMC,ST=HCM,C=VN"
plugins.security.audit.type: internal_opensearch
plugins.security.nodes_dn:
- "CN=hotnode,OU=SIEM,O=Poptech,L=HCMC,ST=HCM,C=VN"
- "CN=coldnode,OU=SIEM,O=Poptech,L=HCMC,ST=HCM,C=VN"
- "CN=warmnode,OU=SIEM,O=Poptech,L=HCMC,ST=HCM,C=VN"
- "CN=replica,OU=SIEM,O=Poptech,L=HCMC,ST=HCM,C=VN"
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: [all_access, security_rest_api_access]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [.plugins-ml-agent, .plugins-ml-config, .plugins-ml-connector,
.plugins-ml-controller, .plugins-ml-model-group, .plugins-ml-model, .plugins-ml-task,
.plugins-ml-conversation-meta, .plugins-ml-conversation-interactions, .plugins-ml-memory-meta,
.plugins-ml-memory-message, .plugins-ml-stop-words, .opendistro-alerting-config,
.opendistro-alerting-alert*, .opendistro-anomaly-results*, .opendistro-anomaly-detector*,
.opendistro-anomaly-checkpoints, .opendistro-anomaly-detection-state, .opendistro-reports-*,
.opensearch-notifications-*, .opensearch-notebooks, .opensearch-observability, .ql-datasources,
.opendistro-asynchronous-search-response*, .replication-metadata-store, .opensearch-knn-models,
.geospatial-ip2geo-data*, .plugins-flow-framework-config, .plugins-flow-framework-templates,
.plugins-flow-framework-state, .plugins-search-relevance-experiment, .plugins-search-relevance-judgment-cache]
node.max_local_storage_nodes: 3
Đây là mẫu config cho node hot
Lưu ý: thay đổi transport.port và http.port cho từng node để tránh trung lặp port dẫn đến không hoạt động

Sau đó tiến hành tạo services cho từng node
sudo nano /etc/systemd/system/opensearch-hot.service

[Unit]
Description=OpenSearch Hot Node
After=network.target

[Service]
Type=simple
User=opensearch
Group=opensearch

Environment=OPENSEARCH_PATH_CONF=/etc/opensearch/hot

ExecStart=/usr/share/opensearch/bin/opensearch

Restart=always
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
Tương tự cho warm và cold
Sau đó dùng lệnh sudo systemctl daemon-reload để reload lại các service
Sau đó tiến hành start các services và đợi 1 lúc sau đó kiểm tra xem các node đã vào chưa
1773645047874.png


Triển khai cert cho Opensearch Dashboard
Cấu hình cho dashboard.cnf
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
req_extensions = v3_req

[ dn ]
C = VN
ST = HCM
L = HCMC
O = Poptech
OU = SIEM
CN = dashboard

[ v3_req ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = dashboard
IP.1 = 10.120.100.9

Sau đó tiến hành chạy các lệnh để tạo các cert
openssl genrsa -out dashboards-key.pem 2048
openssl req -new -key dashboards-key.pem -out dashboards.csr -config dashboards.cnf

openssl x509 -req -in dashboards.csr \
-CA root-ca.pem \
-CAkey root-ca-key.pem \
-CAcreateserial \
-out dashboards.pem \
-days 365 \
-extensions v3_req \
-extfile dashboards.cnf

Sau đó copy các file dashboards.pem và dashboards-key.pem root-ca.pem vào /etc/opensearch-dashboards/certs/
Sau đó tiến hành cài đặt opensearch-dashboards.yml
server.port: 5601

server.host: "0.0.0.0"

server.ssl.enabled: true
server.ssl.certificate: /etc/opensearch-dashboards/certs/dashboards.pem
server.ssl.key: /etc/opensearch-dashboards/certs/dashboards-key.pem

opensearch.ssl.certificateAuthorities: [ "/etc/opensearch-dashboards/certs/root-ca.pem" ]
opensearch.ssl.verificationMode: full

opensearch.hosts: ["https://hotnode:9200"]
#opensearch.ssl.verificationMode: none
opensearch.username: admin
opensearch.password: Poptech@123
opensearch.requestHeadersWhitelist: [authorization, securitytenant]

opensearch_security.multitenancy.enabled: true
opensearch_security.multitenancy.tenants.preferred: [Private, Global]
opensearch_security.readonly_mode.roles: [kibana_read_only]
# Use this setting if you are running opensearch-dashboards without https
opensearch_security.cookie.secure: true
Sau đó tiến hành truy cập https://10.120.100.9:5601 để truy cập vào opensearch
Phân quyền user cho Opensearch
Tiến hành tạo roles
1774602281561.png

Đây là một số roles mẫu và có thể tạo thêm roles tùy theo nhu cầu
Phân quyền cho cluster hoặc index
1774602630157.png

Phân quyền cho tenant
1774602347033.png

Sau đó tiến hành tạo user và mapping roles đã tạo
1774602855003.png

Phân tenants cho từng loại dashboard
1775209390573.png

1775209379018.png

1775187296186.png

1775187235490.png
 
Sửa lần cuối:
Back
Top