Tài liệu này hướng dẫn cấu hình Alloy để thu thập Metrics của dịch vụ Object Storage

1. Chuẩn bị

1.1 Cài đặt alloy trên VM

Thực hiện cài đặt Alloy Agent trên máy chủ Linux bằng lệnh sau:

/bin/sh -c "$(curl -fsSL https://s3hn.smartcloud.vn/agent/alloy/linux/releases/v1.8.3/install-linux.sh)"

2. Cấu hình tích hợp

Tại đường dẫn /etc/alloy/config.alloy, chỉnh sửa cấu hình Alloy để tích hợp thu thập dữ liệu MinIO:

sudo vi /etc/alloy/config.alloy

Thay các trường ở file cấu hình sau, trong đó:

TrườngÝ nghĩaGiá trị mẫu
urlEndpoint của dịch vụ APM trên giao diện Consolehttps://metrics-0qcs3dsvvva.apm.vnptplatform.vn/api/v1/push
AuthorizationToken của dịch vụ APM trên giao diện Consolea5130b91-ff9b-41ef-8722-9d923a574123
namespaceNamespace triển khai MinIOapm-object-storage
__address__Các endpoint MinIOminio-vnpt-apm-sdk.vnpt.vn
bearer_tokenToken truy cập MinIOeyJhbGciOiJIUzUmMiIsInR5cCI6IkpXVCJ9.eyJleHAimjQ3fhM5NTE2MzUsImlzcyI6InByb21ldGhldXMiLCJzdWIiOikejt1pbiJ9.gExFVGW_xVn5q4CYF1s-PnFs2lmB_qscDkm5W_ofWkJNZFqwNNjn5tkJ9DRZ0TvEe9HltZkjzRl-GNDEMxTvJ4g
logging {
    level  = "warn"
    format = "logfmt"
}

prometheus.remote_write "metrics_integrations_minio" {
    endpoint {
        url = "<endpoint dịch vụ APM>"
        headers = {
            "Authorization" = "<token dịch vụ APM>",
        }
    }
    external_labels = {
        tenant = "<tên dịch vụ APM>",
        namespace = "<namespace MinIO>",
    }
}

discovery.relabel "metrics_integrations_minio" {
    targets = [{
        __address__ = "<endpoint MinIO>",
    },]
    rule {
        target_label = "instance"
        replacement  = constants.hostname
    }
}

prometheus.scrape "metrics_integrations_minio" {
    targets      = discovery.relabel.metrics_integrations_minio.output
    bearer_token = "<token MinIO>"
    forward_to   = [prometheus.remote_write.metrics_integrations_minio.receiver]

3. Cài đặt

Thực hiện lệnh sau để khởi động Alloy:

sudo systemctl status alloy 

4. Kiểm tra

4.1 Kiểm tra dịch vụ

Thực hiện lệnh sau:

sudo systemctl status alloy 

Hệ thống trả về như sau nếu thành công:

● alloy.service - Vendor-agnostic OpenTelemetry Collector distribution with programmable pipelines
    Loaded: loaded (/lib/systemd/system/alloy.service; enabled; vendor preset: enabled)
    Active: active (running) since Thu 2025-04-24 18:25:30 +07; 14h ago
      Docs: https://grafana.com/docs/alloy
   Process: 312064 ExecReload=/usr/bin/env kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
  Main PID: 4041003 (alloy)
     Tasks: 18 (limit: 9385)
    Memory: 80.3M
       CPU: 38min 6.739s
    CGroup: /system.slice/alloy.service
            └─4041003 /usr/bin/alloy run --server.http.listen-addr=0.0.0.0:30000 --storage.path=/var/lib/alloy/data /e>

Nếu không thành công, xem log Alloy:

sudo journalctl -u alloy -ex 

Sau đó chỉnh sửa cấu hình nếu cần và khởi động lại:

sudo systemctl restart alloy 

4.2 Kiểm tra tích hợp

Tham khảo hướng dẫn tích hợp dashboard , kiểm tra metric MinIO trên giao diện Dashboard:

Một số dashboard mẫu khi tích hợp thành công: