Redis

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ị

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

Tại đường dẫn alloy/config/example.alloy, chỉnh sửa cấu hình Alloy để tích hợp Redis:

Thay các trường ở file cấu hình trên, 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
redis_addr IP VM Redis10.168.17.30
redis_user user truy cập redisadmin
redis_password password  truy cập redisAW35YfYKg9iCoMPS38839H045zO626ur
      logging {
          level  = "debug"
          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 các lệnh sau:

cd alloy/ 
helm -n <namespace> install alloy-<tên dịch vụ Redis> . 

VD: Cài đặt Alloy cho dịch vụ Redis tên là redis-cloud trên namespace vnptcloud:

cd alloy/
helm -n vnptcloud install alloy-redis-cloud . 

4. Kiểm tra

4.1 Kiểm tra dịch vụ

Kiểm tra pod Alloy running:

kubectl -n <namespace> get pod 

VD: Pod Alloy cho dịch vụ Redis trên namespace vnptcloud:

kubectl -n vnptcloud get pod 

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: