CentOS
Trước khi thực hiện cài đặt agent trên các hệ điều hành mà chúng tôi hỗ trợ bên dưới, bạn cần phải tải xuống certificate theo hướng dẫn tại Khởi tạo Certificate. Thông tin hướng dẫn thiết lập agent nằm trong file readme, các script hướng dẫn cũng nằm trong tệp tin certificate được tải về. Sử dụng thông tin này với các hướng dẫn bên dưới để hoàn thành việc thiết lập Agent for Log.
Cài đặt
Xác định một loại agent mà mình muốn cài và làm theo hưỡng dẫn của agent đó dưới đây:
Nếu sử dụng script chuẩn bị sẵn trong thư mục tải về, chạy lệnh
sudo chmod +x filebeat.sh
sudo ./filebeat.sh <path-to-file-log>
Nếu cài thủ công, chạy lệnh
Tải tệp tin rpm: curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.7.1-x86_64.rpm
Install filebeat: sudo rpm -vi filebeat-8.7.1-x86_64.rpm
Tiếp theo bạn cần cấu hình agent log. Các file cấu hình dưới đều đã được chúng tôi chuẩn bị sẵn tại script khi tải certificate về, mô tả dưới đây giúp người đọc hình dung được nếu tạo manual sẽ thế nào.
Cấu hình
File
/etc/filebeat/filebeat.yml
. Cấu hình dưới đây sẽ lấy tất cả log trong file/var/log/app.log
đẩy về vMonitor Platform:
filebeat.inputs:
- type: log
paths:
- /var/log/app.log
output.kafka:
hosts: ["$BOOTSTRAP_SERVERS"]
topic: "$TOPIC"
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
ssl.certificate_authorities:
- $PATH_FILE_VNG_TRUST_PEM
ssl.certificate: "$PATH_FILE_USER_CER_PEM"
ssl.key: "$PATH_FILE_USER_KEY_PEM"
ssl.verification_mode: "none"
logging.level: info
logging.to_files: true
logging.files:
path: /var/log/filebeat
name: filebeat
keepfiles: 7
permissions: 0644
Trong đó Tại input đường dẫn tới file log
Tại output , các biến cần điền bạn lấy từ bước tải certicate ở trên:
$BOOTSTRAP_SERVERS, $TOPIC
lấy trong file info.md$PATH_FILE_VNG_TRUST_PEM, $PATH_FILE_USER_CER_PEM, $PATH_FILE_USER_KEY_PEM
là đường dẫn tới file VNG.trust.pem user.cer.pem user.key.pem
Đọc thêm cấu hình nâng cao khác tại
Configure Filebeat | Filebeat Reference [8.8] | Elastic
filebeat.inputs:
- type: log
paths:
- /var/log/app.log
output.kafka:
hosts: ["$BOOTSTRAP_SERVERS"]
topic: "$TOPIC"
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
ssl.certificate_authorities:
- $PATH_FILE_VNG_TRUST_PEM
ssl.certificate: "$PATH_FILE_USER_CER_PEM"
ssl.key: "$PATH_FILE_USER_KEY_PEM"
ssl.verification_mode: "none"
logging.level: info
logging.to_files: true
logging.files:
path: /var/log/filebeat
name: filebeat
keepfiles: 7
permissions: 0644
Quản trị
Start
systemctl start logstash
Enable
systemctl enable logstash
Stop
systemctl stop logstash
Reload
systemctl reload logstash
Restart
systemctl restart logstash
Observe
systemctl status logstash
journalctl -f --unit logstash
tail -f /var/log/logstash
Uninstall
yum remove logstash
systemctl start logstash
systemctl enable logstash
systemctl stop logstash
systemctl reload logstash
systemctl restart logstash
systemctl status logstash
journalctl -f --unit logstash
tail -f /var/log/logstash
yum remove logstash
Last updated