-2

我在 VM (ubuntu) 上配置了 Prometheus、node-exporter 和 alertmanager 以下视频:https ://www.youtube.com/watch?v=7gW5pSM6dlU

Prometheus 和 node-exporter 工作正常,但我无法启动 alertmanager。

user1@ubuntu1:/usr/local/bin/alertmanager$ sudo service alertmanager start
user1@ubuntu1:/usr/local/bin/alertmanager$ sudo service alertmanager status
● alertmanager.service - Prometheus Alert Manager
    Loaded: loaded (/etc/systemd/system/alertmanager.service; disabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Tue 2022-01-04 18:48:11 CET; 4s ago
   Process: 4205 ExecStart=/usr/local/bin/alertmanager --config.file=/usr/local/bin/alertmanager/alertmanager.yml (code=exited, status=203/EXEC)
  Main PID: 4205 (cde=exited, status=203/EXEC)

sty 04 18:48:11 ubuntu1 systemd[1]: Started Prometheus Alert Manager.
sty 04 18:48:11 ubuntu1 systemd[4205]: alertmanager.service: Failed to execute command: Permission denied
sty 04 18:48:11 ubuntu1 systemd[4205]: alertmanager.service: Failed at step EXEC spawning /usr/local/bin/alertmanager: Permission denied
sty 04 18:48:11 ubuntu1 systemd[1]: alertmanager.service: Main process exited, code=exited, status=203/EXEC
sty 04 18:48:11 ubuntu1 systemd[1]: alertmanager.service: Failed with result 'exit-code'.

但是 amtool 成功检查了我的配置文件:

user1@ubuntu1:/usr/local/bin/alertmanager$ ./amtool check-config ./alertmanager.yml
Checking './alertmanager.yml'  SUCCESS
Found:
 - global config
 - route
 - 1 inhibit rules
 - 1 receivers
 - 0 templates 

我的 alertmanager 配置文件如下所示:

global:
  resolve_timeout: 5m

route:
  group_by: [Alertname]
  group_interval: 30s
  repeat_interval: 30s
  # Send all notifications to me.
  receiver: email-me
receivers:
- name: email-me
  email_configs:
  - send_resolved: true
    to: my_real_email@gmail.com
    from: my_real_email@gmail.com
    smarthost: smtp.gamil.com:587
    auth_username: my_real_email@gmail.com
    auth_identity: my_real_email@gmail.com
    auth_password: 'my_password'
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match: 
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

我的服务看起来像这样:

[Unit]
Description=Prometheus Alert Manager
After=network.targer

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

[Install]
WantedBy=multi-user.target

我不知道为什么它显示“权限被拒绝”,因为我用 sudo 开始服务。有任何想法吗?

4

1 回答 1

0

好的,我再次设置了 VM、Prometheus 和 Alertmanager,现在服务启动没有任何问题。

于 2022-01-08T20:47:16.697 回答