监控系统部署prometheus基本功能

wget -c https://github.com/prometheus/prometheus/releases/downloa d/v2.37.1/prometheus-2.37.1.linux-amd64.tar.gz下载必要的组件。
监控系统部署prometheus基本功能_第1张图片
mkdir -p /opt/prometheus创建目录。
在这里插入图片描述
tar zxf prometheus-2.37.1.linux-amd64.tar.gz压缩文件解压至当前目录下,cp -far prometheus-2.37.1.linux-amd64/* /opt/prometheus/把解压出来的文件移动到/opt/prometheus/里边。

在这里插入图片描述

cat </etc/systemd/system/prometheus.service把下边的内容都写进去,每敲一行按一下回车键:

[Unit]
Description="prometheus"
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple

ExecStart=/opt/prometheus/prometheus  --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data --web.enable-lifecycle --enable-feature=remote-write-receiver --query.lookback-delta=2m --web.enable-admin-api

Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus



[Install]
WantedBy=multi-user.target

监控系统部署prometheus基本功能_第2张图片

EOF是分界符,不会记录到文件中。

启动参数的解释:

--config.file=/opt/prometheus/prometheus.yml
指定 Prometheus 的配置文件路径

--storage.tsdb.path=/opt/prometheus/data
指定 Prometheus 时序数据的硬盘存储路径

--web.enable-lifecycle
启用生命周期管理相关的 API,比如调用 /-/reload 接口就需要启用该项

--enable-feature=remote-write-receiver
启用 remote write 接收数据的接口,启用该项之后,categraf、grafana-agent 等 agent 就可以通过 /api/v1/write 接口推送数据给 Prometheus

--query.lookback-delta=2m
即时查询在查询当前最新值的时候,只要发现这个参数指定的时间段内有数据,就取最新的那个点返回,这个时间段内没数据,就不返回了

--web.enable-admin-api
启用管理性 API,比如删除时间序列数据的 /api/v1/admin/tsdb/delete_series 接口

systemctl enable prometheus设置成开机启动服务,systemctl start prometheus开启服务,systemctl status prometheus可以看到服务状态是active (running)
监控系统部署prometheus基本功能_第3张图片

在浏览器里边输入ip:端口然后按下回车键。
监控系统部署prometheus基本功能_第4张图片

最后就到了下边的页面:
监控系统部署prometheus基本功能_第5张图片

在页面特定位置搜索框里边输入{instance="localhost:9090",__name__=~"go_gc_.*"},然后按下Execute。
监控系统部署prometheus基本功能_第6张图片

此文章为9月Day 8学习笔记,内容来源于极客时间《运维监控系统实战笔记》。

你可能感兴趣的:(运维监控系统实战笔记,linux,运维)