附:Prometheus 部署方案
Prometheus 的安装非常简单,就是一个二进制,下载启动就可以了。之所以还要单列一个章节来说明,是因为 Prometheus 要想作为时序库接收 remote write 协议的数据,即夜莺收到时序数据之后,要想转发给 Prometheus,需要 Prometheus 在启动参数里添加 --enable-feature=remote-write-receiver
,否则夜莺转发数据的时候会报 404,因为没有这个参数,Prometheus 就不会开启 /api/v1/write
接口的处理监听。
另外,Prometheus 新版本之后,这个参数的写法发生了一些变化,通过 ./prometheus --help | grep write
可以找到新的参数写法。下面是一段小脚本,用于安装 Prometheus,供参考:
# install prometheus
mkdir -p /opt/prometheus
wget https://s3-gz01.didistatic.com/n9e-pub/prome/prometheus-2.28.0.linux-amd64.tar.gz -O prometheus-2.28.0.linux-amd64.tar.gz
tar xf prometheus-2.28.0.linux-amd64.tar.gz
cp -far prometheus-2.28.0.linux-amd64/* /opt/prometheus/
# service
cat <<EOF >/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
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus
[Install]
WantedBy=multi-user.target
EOF
systemctl enable prometheus
systemctl restart prometheus
systemctl status prometheus