Redis
Cập nhật lần cuối: 27/01/2026 17:00
Tài liệu này hướng dẫn cấu hình Alloy để thu thập Metrics của dịch vụ Redis
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 Redis:
sudo vi /etc/alloy/config.alloyThay các trường ở file cấu hình trên, trong đó:
| Trường | Ý nghĩa | Giá trị mẫu |
| url | Endpoint của dịch vụ APM trên giao diện Console | https://metrics-0qcs3dsvvva.apm.vnptplatform.vn/api/v1/push |
| Authorization | Token của dịch vụ APM trên giao diện Console | a5130b91-ff9b-41ef-8722-9d923a574123 |
| redis_addr | IP VM Redis | 10.168.17.30 |
| redis_user | user truy cập redis | admin |
| redis_password | password truy cập redis | AW35YfYKg9iCoMPS38839H045zO626ur |
logging {
level = "warn"
format = "logfmt"
}
prometheus.remote_write "integrations_redis_exporter" {
endpoint {
url = "<endpoint dịch vụ APM>"
headers = {
"Authorization" = "<token dịch vụ APM>",
}
}
}
prometheus.exporter.redis "integrations_redis_exporter" {
redis_addr = "<endpoint Redis>:6379"
redis_user = "<username Redis>"
redis_password = "<password Redis>"
is_cluster = true
}
discovery.relabel "integrations_redis_exporter" {
targets = prometheus.exporter.redis.integrations_redis_exporter.targets
rule {
source_labels = ["instance"]
regex = "([^:]+)(?::[0-9]+)?"
target_label = "instance"
replacement = "$1"
}
rule {
target_label = "job"
replacement = "integrations/redis_exporter"
}
}
prometheus.scrape "integrations_redis_exporter" {
targets = discovery.relabel.integrations_redis_exporter.output
forward_to = [prometheus.relabel.integrations_redis_exporter.receiver]
job_name = "integrations/redis_exporter"
}
prometheus.relabel "integrations_redis_exporter" {
forward_to = [prometheus.remote_write.integrations_redis_exporter.receiver]
rule {
source_labels = ["__name__"]
regex = "up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up|redis_memory_fragmentation_ratio|redis_master_last_io_seconds_ago"
action = "keep"
}
}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 Redis trên giao diện Dashboard:
Một số dashboard mẫu khi tích hợp thành công:



