项目场景:

安装完成Prometheus和Grafana后,安装alertmanager时遇到的问题


问题描述

当直接cd到local文件夹下面使用./alertmanager命令可以成功运行alertmanager,但是设置开启自启动后,查看状态显示失败。

[root@Prometheus alertmanager]# vim /etc/systemd/system/alertmanager.service
[root@Prometheus alertmanager]# systemctl daemon-reload
[root@Prometheus alertmanager]# systemctl start alertmanager.service
[root@Prometheus alertmanager]# systemctl status alertmanager.service
● alertmanager.service - Prometheus Alertmanager
   Loaded: loaded (/etc/systemd/system/alertmanager.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2023-08-10 15:01:54 CST; 3min 20s ago
  Process: 41469 ExecStart=/usr/local/alertmanager/alertmanager --config.file="/usr/local/alertmanager/alertmanager.yml" (code=exited, status=1/FAILURE)
 Main PID: 41469 (code=exited, status=1/FAILURE)

原因分析:

原因发现config.file="/usr/local/alertmanager/alertmanager.yml",中带有双引号,需要把双引号删除,即进行如下操作,找到loaded文件,上述日志提醒中有文件位置:

vim /etc/systemd/system/alertmanager.service

 修改配置文件如下

[Unit]
Description=Prometheus Alertmanager
After=network.target

[Service]
ExecStart=/usr/local/alertmanager/alertmanager --config.file=/usr/local/alertmanager/alertmanager.yml

[Install]
WantedBy=multi-user.target

 再次start

[root@Prometheus alertmanager]# systemctl daemon-reload
[root@Prometheus alertmanager]# systemctl start alertmanager.service
[root@Prometheus alertmanager]# systemctl status alertmanager.service
● alertmanager.service - Prometheus Alertmanager
   Loaded: loaded (/etc/systemd/system/alertmanager.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2023-08-10 15:07:54 CST; 11s ago
 Main PID: 41513 (alertmanager)
   CGroup: /system.slice/alertmanager.service
           └─41513 /usr/local/alertmanager/alertmanager --config.file=/usr/local/alertmanager/alertmanager.yml

 访问ip+9093成功显示

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐