SIEM/Log Management [SIEM/Log Managenment] Mô hình All-in-one OpenSearch

I. Công cụ

- OpenSearch: Công cụ tìm kiếm và phân tích dữ liệu gồm hai thành phần chính là: Open Search và OpenSearch Dashboards
- Fluentd: Chuyên thu thập, xử lý và phân phối log trong hệ thống (log collector & log forwarder)

II. Mô hình All-in-one:

Mô hình all-in-one là tất cả các thành phần của hệ thống (OpenSearch + OpenSearch Dashboarchs + Fluentd) được triển khai trên một máy chủ.

1756959360235.png


Thành phần trong mô hình:

1. Nguồn log (Data Sources):

- Hệ điều hành (Syslog, dmesg, auditd).
- Ứng dụng (Web server, App server, Database logs).
- Middleware (Nginx, Apache, HAProxy).
- Container logs (Docker, Kubernetes).

2. Log Collector (Fluentd):
- Input plugins: nhận log từ file, syslog, docker, forward.
- Filter plugins: parse log, thêm metadata (host, app, env).
- Output plugin: gửi log vào OpenSearch (fluent-plugin-opensearch).

3. OpenSearch (Core Engine):
- Indexing: nhận log từ Fluentd và ghi vào index.
- Storage: lưu trữ log dưới dạng JSON document.
- Query Engine: cho phép tìm kiếm, phân tích, aggregation.
- Plugin services: alerting, anomaly detection, index management.

4. OpenSearch Dashboards:
- Giao diện web để tìm kiếm, visualize, dashboard.
- Cho phép tạo alert rule, monitor log, vẽ biểu đồ.

Ưu và nhược điểm của mô hình:
Ưu điểm: dễ triển khai, cấu hình đơn giản, chỉ cần một server để chạy.
Nhược điểm: không scale tốt, không có high availability (nếu máy down là toàn hệ thống ngừng).

III. Triển khai mô hình

1. Cấu trúc thư mục:

opensearch-fluentd/
├── docker-compose.yml
└── fluentd/
└── fluent.conf
└── Dockerfile.fluentd

2. Triển khai:

2.1. Cấu hình:

File docker-compose.yml

version: '3.8'

services:
opensearch:
image: opensearchproject/opensearch:2.15.0
container_name: opensearch
environment:
- discovery.type=single-node
- DISABLE_SECURITY_PLUGIN=true # chỉ dùng trong lab
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- os-data:/usr/share/opensearch/data
ports:
- "9200:9200"

dashboards:
image: opensearchproject/opensearch-dashboards:2.15.0
container_name: dashboards
environment:
- OPENSEARCH_HOSTS=http://opensearch:9200
- DISABLE_SECURITY_DASHBOARDS_PLUGIN=true
depends_on:
- opensearch
ports:
- "5601:5601"

fluentd:
build:
context: .
dockerfile: Dockerfile.fluentd
volumes:
- ./fluentd/fluent.conf:/fluentd/etc/fluent.conf
ports:
- "24224:24224"
- "24224:24224/udp"
depends_on:
- opensearch

volumes:
os-data:

File fluentd/fluent.conf

<source>
@type tail
path /fluentd/log/syslog
pos_file /fluentd/log/syslog.pos
tag syslog
format syslog
</source>

<source>
@type forward
port 24224
bind 0.0.0.0
</source>

<match **>
@type opensearch
host opensearch
port 9200
scheme http
logstash_format true
flush_interval 5s
</match>

File fluentd/Dockerfile.fluentd

FROM fluent/fluentd:v1.17-debian-1

USER root
RUN gem install fluent-plugin-opensearch --no-document
USER fluent


2.2. Triển khai:

Chạy docker: docker compose up -d

Test mô hình với câu lệnh:
echo '{"message":"Hello from Fluentd"}' | docker exec -i opensearch-fluentd-fluentd-1 fluent-cat test

Tạo index: logstash* với field: @timestamp
Kết quả nhận được:
1756959443660.png
 
Back
Top