Tổng quan
Hướng dẫn này sẽ giúp bạn nhanh chóng thiết lập và chạy G-BlackHole Agent trong vài phút. Chúng ta sẽ:
- Xác thực với Registry (nếu sử dụng)
- Chạy Agent ở foreground để test
- Cài đặt Agent như service
Bước 1: Xác thực với Registry (tùy chọn. Forwarder có thể tự động xác thực thay cho Agent)
Nếu bạn sử dụng Registry server, hãy xác thực trước:
Windows
powershell
# Xác thực với Registry
.\blackhole-agt.exe auth --key "your-api-key-here"Linux
bash
# Xác thực với Registry
./blackhole-agt auth --key "your-api-key-here"Bước 2: Chạy Agent ở Foreground
Test Agent bằng cách chạy ở foreground để xem logs trực tiếp:
Windows
powershell
# Chạy Agent ở foreground với verbose logging
.\blackhole-agt.exe start --config config.yml --verbose
# Hoặc với log level debug
.\blackhole-agt.exe start --config config.yml --log-level debugLinux
bash
# Chạy Agent ở foreground với verbose logging
./blackhole-agt start --config config.yml --verbose
# Hoặc với log level debug
./blackhole-agt start --config config.yml --log-level debugKiểm tra hoạt động:
- Xem logs trên console để đảm bảo Agent đang thu thập dữ liệu
- Kiểm tra các collector đang chạy (APM, File, Windows Events)
- Xác nhận dữ liệu được gửi đến sink (Registry nếu đã cấu hình)
Dừng Agent:
- Nhấn
Ctrl+Cđể dừng Agent
Bước 3: Cài đặt Agent như Service
Sau khi test thành công, cài đặt Agent như service để chạy tự động:
Windows
powershell
# Cài đặt Windows Service
.\blackhole-agt.exe service install --config config.yml
# Khởi động service
.\blackhole-agt.exe service start
# Kiểm tra trạng thái service
Get-Service -Name "blackhole-agt"Linux
bash
# Cài đặt systemd service
sudo ./blackhole-agt service install --config config.yml
# Khởi động service
sudo ./blackhole-agt service start
# Kiểm tra trạng thái service
sudo systemctl status blackhole-agtXác minh cài đặt
Kiểm tra Service Status
Windows:
powershell
# Xem trạng thái service
Get-Service -Name "blackhole-agt"
# Xem logs của service
Get-EventLog -LogName Application -Source "blackhole-agt" -Newest 10Linux:
bash
# Xem trạng thái service
sudo systemctl status blackhole-agt
# Xem logs của service
sudo journalctl -u blackhole-agt -fKiểm tra Logs
Windows:
powershell
# Xem log files
Get-Content ".\logs\default.log" -Tail 20
Get-Content ".\logs\agent-error.log" -Tail 10Linux:
bash
# Xem log files
tail -f /var/log/blackhole-agent/default.log
tail -f /var/log/blackhole-agent/default-error.logTóm tắt lệnh
Windows
powershell
# Quick Start Commands
.\blackhole-agt.exe auth --key "your-api-key-here" # Nếu dùng Registry
.\blackhole-agt.exe start --config config.yml --verbose # Test
.\blackhole-agt.exe service install --config config.yml
.\blackhole-agt.exe service startLinux
bash
# Quick Start Commands
./blackhole-agt auth --key "your-api-key-here" # Nếu dùng Registry
./blackhole-agt start --config config.yml --verbose # Test
sudo ./blackhole-agt service install --config config.yml
sudo ./blackhole-agt service start