Truy cập
- Mở
https://<SERVER_IP>:9090trong trình duyệt của bạn. - Chứng chỉ là tự ký, nên trình duyệt của bạn sẽ hiển thị cảnh báo chứng chỉ.
- Trang targets của Prometheus có tại
https://<SERVER_IP>:9090/targets. - Các metric có tại
https://<SERVER_IP>:9090/metrics.
Đăng nhập
Prometheus được bảo vệ bằng xác thực HTTP Basic.
- Tên người dùng:
admin - Mật khẩu: được lưu trữ trong
/root/.prometheus-credentials
Cùng cơ chế xác thực này bảo vệ giao diện web, API và endpoint /metrics .
File và thư mục quan trọng
- Cấu hình Prometheus:
/etc/prometheus/prometheus.yml - Cấu hình web/TLS/auth:
/etc/prometheus/web-config.yml - Chứng chỉ TLS:
/etc/prometheus/tls/ - Dữ liệu Prometheus:
/var/lib/prometheus - Textfile Collector của Node Exporter:
/var/lib/node_exporter/textfile_collector - Thông tin đăng nhập:
/root/.prometheus-credentials - Tệp nhị phân Prometheus:
/usr/local/bin/prometheus - Promtool:
/usr/local/bin/promtool - Tệp nhị phân Node Exporter:
/usr/local/bin/node_exporter - Dịch vụ Prometheus:
/etc/systemd/system/prometheus.service - Dịch vụ Node Exporter:
/etc/systemd/system/node_exporter.service
Quản lý dịch vụ
Kiểm tra Prometheus:
systemctl status prometheus
Khởi động lại Prometheus:
systemctl restart prometheus
Xem log Prometheus:
journalctl -u prometheus -f
Kiểm tra Node Exporter:
systemctl status node_exporter
Khởi động lại Node Exporter:
systemctl restart node_exporter
Xem log Node Exporter:
journalctl -u node_exporter -f
Thêm targets
Chỉnh sửa /etc/prometheus/prometheus.yml:
vim /etc/prometheus/prometheus.yml
Xác thực cấu hình:
promtool check config /etc/prometheus/prometheus.yml
Tải lại Prometheus:
curl -sS --cacert /etc/prometheus/tls/prometheus.crt \
-u admin:<PASSWORD> \
-X POST https://localhost:9090/-/reload
Thời gian lưu giữ
Prometheus được cấu hình với:
- Thời gian lưu giữ:
30d - Dung lượng lưu trữ tối đa:
10GB
Giới hạn nào đạt trước sẽ được áp dụng.
Ghi chú
- Grafana và Alertmanager không được cài đặt. Bạn có thể thêm riêng và kết nối chúng với phiên bản Prometheus này.
- Các metric được lưu giữ tối đa 30 ngày hoặc 10 GB, tùy giới hạn nào đạt trước.
- Có thể thêm metric máy chủ tùy chỉnh dưới dạng tệp
.promtại:/var/lib/node_exporter/textfile_collector