Prometheus là gì? Monitoring và alerting cho infrastructure

Prometheus là gì? Monitoring và alerting cho infrastructure

Hệ thống phân tán hiện đại cần giám sát liên tục: CPU, memory, latency, error rate, traffic. Prometheus là công cụ monitoring và alerting mã nguồn mở, tiêu chuẩn CNCF, được dùng rộng rãi trong Kubernetes và cloud-native.

Terminal hiển thị lệnh Prometheus scrape metrics từ target, hiển thị cấu hình prometheus.yml và đầu ra tsdb

Kiến trúc Prometheus:
Prometheus Server: Thu thập (scrape) metrics theo mô hình pull từ các target endpoint /metrics. Lưu trữ trong time-series database (TSDB) nội bộ.
Service Discovery: Tự động phát hiện target qua Kubernetes, Consul, file config.
PromQL: Ngôn ngữ truy vấn mạnh mẽ cho time-series data.
Alertmanager: Xử lý cảnh báo: deduplication, grouping, inhibition, routing đến receiver (email, Slack, webhook).

Các khái niệm cốt lõi:
Metric: Điểm dữ liệu có tên, nhãn (labels), giá trị, timestamp. Ví dụ: http_requests_total{method="GET",status="200"}
Labels: Cặp key-value phân biệt chuỗi time-series. Cho phép filter, aggregate linh hoạt.
Exporter: Sidecar xuất metrics của ứng dụng thứ 3 (node_exporter, postgres_exporter, redis_exporter).
Pushgateway: Cho phép job ngắn hạn (batch, cron) đẩy metrics khi Prometheus không pull kịp.

Grafana dashboard hiển thị biểu đồ CPU, memory, request latency từ datasource Prometheus, biểu đồ gauge và heatmap

Prometheus vs Grafana:
– Prometheus: thu thập, lưu trữ, query, alert
– Grafana: trực quan hóa (dashboard, graph), dùng Prometheus làm datasource
– Hai công cụ bổ sung nhau, không thay thế

Ứng dụng thực tế:
– Giám sát cluster Kubernetes (kube-state-metrics, cAdvisor)
– Infrastructure monitoring: node_exporter cho Linux, Windows
– Application metrics: latency, throughput, error rate
– Business metrics: số đơn hàng, user active, conversion rate

So sánh với các công cụ khác:

Đặc điểm Prometheus Datadog New Relic
Licensing Mã nguồn mở SaaS trả phí SaaS trả phí
Data model Time-series multi-dim Metrics + logs + traces Metrics + logs + traces
Chi phí Vận hành tự quản Theo host/metric Theo host/metric
Scalability Federation, Thanos, Cortex Managed Managed

Prometheus phù hợp cho team muốn kiểm soát dữ liệu, chi phí thấp, tích hợp sâu Kubernetes. Kết hợp với Grafana tạo stack monitoring hoàn chỉnh.

Tôi là một lập trình viên IOS. Code chính là IOS nhưng thỉnnh thoảng vẫn đá sang Android hoặc web. Mặc dù không quá thông thạo nhưng tôi sẽ chia sẻ những kiến thức mà mình đã tìm hiểu, áp dụng qua.

Bài viết liên quan

AV1 codec là gì? Hướng dẫn codec video thế hệ mới thay thế H.265 miễn phí

AV1 codec là gì? Hướng dẫn codec video thế hệ mới thay thế H.265 miễn phí AV1 codec là gì? Hướng dẫn codec video thế hệ mới thay thế H.265…

Xem thêm

Edge Computing là gì? Kiến trúc xử lý dữ liệu ở rìa mạng

Edge computing là mô hình tính toán phân tán đưa khả năng xử lý dữ liệu và lưu trữ gần hơn với nguồn sinh ra dữ liệu, giúp giảm độ…

Xem thêm

Home Assistant là gì? Nền tảng smart home mã nguồn mở tự chủ

Home Assistant là gì? Nền tảng smart home mã nguồn mở tự chủ Home Assistant là nền tảng tự động hóa nhà thông minh mã nguồn mở, cho phép bạn…

Xem thêm
0 0 đánh giá
Article Rating
Theo dõi
Thông báo của
guest
0 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất