跳至主要内容
五折优惠 全部方案,限时优惠。起价 $2.48/mo
Prometheus

Prometheus

Prometheus 是时序监控的行业标准。支持拉取式指标采集、PromQL 查询、告警规则,以及 Kubernetes 原生服务发现。已通过 CNCF 毕业认证,最初由 SoundCloud 创建,现被 DigitalOcean 及 80% 的 Kubernetes 部署广泛采用。

快速概览

64.7k

GitHub star 数

32

页面浏览量

许可 Apache-2.0 版本 3.13.2 OS Ubuntu Server 24.04 LTS Min RAM 1 GB IP IPV4,IPV6

访问

  • 打开 https://<SERVER_IP>:9090 在您的浏览器中。
  • 证书为自签名证书,因此浏览器会显示证书警告。
  • Prometheus 的 targets 页面位于 https://<SERVER_IP>:9090/targets.
  • 指标位于 https://<SERVER_IP>:9090/metrics.

登录

Prometheus 受 HTTP Basic 认证保护。

  • 用户名: admin
  • 密码:存储在 /root/.prometheus-credentials

同一认证同时保护 Web UI、API 以及以下端点: /metrics 。

重要文件与目录

  • Prometheus 配置: /etc/prometheus/prometheus.yml
  • Web/TLS/认证配置: /etc/prometheus/web-config.yml
  • TLS 证书: /etc/prometheus/tls/
  • Prometheus 数据: /var/lib/prometheus
  • Node Exporter Textfile Collector: /var/lib/node_exporter/textfile_collector
  • 凭据: /root/.prometheus-credentials
  • Prometheus 二进制文件: /usr/local/bin/prometheus
  • Promtool: /usr/local/bin/promtool
  • Node Exporter 二进制文件: /usr/local/bin/node_exporter
  • Prometheus 服务: /etc/systemd/system/prometheus.service
  • Node Exporter 服务: /etc/systemd/system/node_exporter.service

服务管理

检查 Prometheus:

systemctl status prometheus

重启 Prometheus:

systemctl restart prometheus

查看 Prometheus 日志:

journalctl -u prometheus -f

检查 Node Exporter:

systemctl status node_exporter

重启 Node Exporter:

systemctl restart node_exporter

查看 Node Exporter 日志:

journalctl -u node_exporter -f

添加 targets

编辑 /etc/prometheus/prometheus.yml:

vim /etc/prometheus/prometheus.yml

验证配置:

promtool check config /etc/prometheus/prometheus.yml

重新加载 Prometheus:

curl -sS --cacert /etc/prometheus/tls/prometheus.crt \
  -u admin:<PASSWORD> \
  -X POST https://localhost:9090/-/reload

保留

Prometheus 的配置如下:

  • 保留时间: 30d
  • 最大存储大小: 10GB

以先达到的限制为准。

注意事项

  • 未安装 Grafana 和 Alertmanager。可以单独添加并连接到此 Prometheus 实例。
  • 指标最多保留 30 天或 10 GB,以先达到的限制为准。
  • 自定义主机指标可以作为 .prom 文件添加到以下目录: /var/lib/node_exporter/textfile_collector

更多监控内容

相关应用。

立即部署 Prometheus。 起价 $2.48/月。