prometheus
  • Introduction
  • (一)快速开始
    • 安装Prometheus
    • 使用NodeExporter采集数据
    • AlertManager进行告警
    • Grafana数据可视化
  • (二)探索PromQL
    • 理解时间序列
    • Metrics类型
    • 初识PromQL
    • PromQL操作符
    • PromQL内置函数
    • PromQL聚合函数
  • (三)Prometheus告警处理
    • 自定义告警规则
    • 示例 - 对主机进行监控告警
    • 部署AlertManager
    • 告警的路由与分组
    • 使用Receiver接收告警信息
      • 集成邮件系统
    • 屏蔽告警通知
    • 扩展阅读
      • AlertManager的API
      • Prometheus发送告警机制
      • 实践:接收Prometheus的告警
      • 实践:AlertManager
  • Prometheus
    • PromQL
      • 内置函数
        • avg
        • rate与irate
      • 常见指标的PromQL
        • 主机CPU
    • 配置
      • 告警规则
Powered by GitBook
On this page

Was this helpful?

  1. (一)快速开始

安装Prometheus

官网给出了很多种安装方法(https://prometheus.io/docs/prometheus/latest/installation/),最常用的就是二进制与docker镜像,这里我们使用已经编译好的二进制进行安装。

从官网(https://prometheus.io/download/) 下载最新版本(2.15.2)的二进制包,解压,然后查看prometheus版本信息

$ wget https://github.com/prometheus/prometheus/releases/download/v2.15.2/prometheus-2.15.2.linux-amd64.tar.gz
$ tar xzvf prometheus-2.15.2.linux-amd64.tar.gz
$ cd prometheus-2.15.2.linux-amd64
$ ./prometheus --version

当使用二进制进行安装时,最好用systemd来管理。我们把整个prometheus-2.15.2.linux-amd64文件夹移动到/usr/local/目录下,并重命名为prometheus

$ mv ./prometheus-2.15.2.linux-amd64 /usr/local/prometheus

然后创建文件/usr/lib/systemd/system/prometheus.service,内容如下

[Unit]
Description=prometheus
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus
Restart=on-failure

[Install]
WantedBy=multi-user.target

关于启动参数可以使用命令/usr/local/prometheus/prometheus --help查看。这里我们把数据的存储目录指定到/var/lib/prometheus

然后启动prometheus,并查看prometheus是否启动成功

$ systemctl daemon-reload && systemctl enable prometheus
$ systemctl start prometheus && systemctl status prometheus

如果启动失败,则可以通过journalctl -xeu prometheus --no-pager查看错误日志(因为systemd管理的service的stdout日志都由journald接管)。如果成功,此时我们可以通过http://ip:9090访问prometheus自带的UI

Previous(一)快速开始Next使用NodeExporter采集数据

Last updated 4 years ago

Was this helpful?