MeterRegistry là gì?

Micrometer registryPrometheusMeterRegistry Actuator & Observability

Trung tâm của Micrometer: nơi tạo và giữ các meter (`Counter`, `Timer`, `Gauge`, `DistributionSummary`) theo tên và tag. Mỗi backend (Prometheus, OTLP, Datadog...) có một cài đặt registry riêng; Spring Boot auto-configure và cho inject sẵn.

EN: The core of Micrometer: it creates and holds meters (`Counter`, `Timer`, `Gauge`, `DistributionSummary`) by name and tags. Each backend (Prometheus, OTLP, Datadog...) has its own registry implementation; Spring Boot auto-configures one for injection.

Thử một câu hỏi phỏng vấn

Câu 1 Dễ Một đáp án

Cần cho Prometheus scrape metrics. Đã thêm micrometer-registry-prometheus. Cấu hình nào đủ và an toàn nhất?

  1. A
    management.endpoints.web.exposure.include=*
    
    Có prometheus nhưng expose luôn mọi endpoint nhạy cảm như env, heapdump.
  2. B
    management.endpoints.web.exposure.include=health,prometheus
    
    Chỉ expose đúng những gì cần: health cho probe và prometheus cho scrape.
  3. C
    management.metrics.export.prometheus=true
    
    Property này không làm endpoint prometheus được expose qua web.
  4. D
    Không cần gì, /actuator/prometheus tự có khi thêm registry Registry tạo endpoint nhưng endpoint vẫn chưa được expose qua HTTP.
Xem đáp án và giải thích

Thêm micrometer-registry-prometheus thì Boot tạo PrometheusMeterRegistry và endpoint prometheus, nhưng endpoint vẫn phải được expose. Sau đó Prometheus scrape GET /actuator/prometheus theo định dạng text exposition. Thực tế nên chạy actuator ở management.server.port riêng để chỉ mạng nội bộ truy cập được.

8 câu hỏi dùng thuật ngữ MeterRegistry
Luyện hết trong ứng dụng, có chấm điểm và lưu câu sai.

Đăng ký và luyện

Thuật ngữ cùng chủ đề

Nhớ lâu hơn bằng cách luyện

Đọc định nghĩa thì dễ quên, trả lời câu hỏi thì nhớ lâu. Thử ngay, miễn phí.

Đăng ký miễn phí