Skip to content

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ẽ:

  1. Xác thực với Registry (nếu sử dụng)
  2. Chạy Agent ở foreground để test
  3. 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 debug

Linux

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 debug

Kiể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-agt

Xá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 10

Linux:

bash
# Xem trạng thái service
sudo systemctl status blackhole-agt

# Xem logs của service
sudo journalctl -u blackhole-agt -f

Kiểm tra Logs

Windows:

powershell
# Xem log files
Get-Content ".\logs\default.log" -Tail 20
Get-Content ".\logs\agent-error.log" -Tail 10

Linux:

bash
# Xem log files
tail -f /var/log/blackhole-agent/default.log
tail -f /var/log/blackhole-agent/default-error.log

Tó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 start

Linux

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

Released under the MIT License.