'Alertmanager service not starting

I configured Prometheus, node-exporter and alertmanager on VM (ubuntu) following by this video: https://www.youtube.com/watch?v=7gW5pSM6dlU

Prometheus and node-exporter works fine, but I cannot start 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'.

But amtool checked my configuration file with success:

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 

My alertmanager config file looks like this:

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: [email protected]
    from: [email protected]
    smarthost: smtp.gamil.com:587
    auth_username: [email protected]
    auth_identity: [email protected]
    auth_password: 'my_password'
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match: 
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

And my service looks like this:

[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

I dont know why it shows "Permission denied", cause i starting service with sudo. Any ideas?



Solution 1:[1]

OK, I set up VM, Prometheus and Alertmanager once again and now service started without any issues.

Solution 2:[2]

Permission denied error so Try to add User and Group in altermanager.service file

[Unit]
Description=AlertManager Server Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/etc/prometheus/exporter/alertmanager/alertmanager \
 --config.file="/etc/prometheus/exporter/alertmanager/alertmanager.yml" \
 --storage.path="/etc/prometheus/exporter/alertmanager/data/" \
 --web.listen-address=0.0.0.0:9093 \
 --web.external-url="http://localhost:9093/alertmanager" \
 --log.level=debug \

Restart=always

[Install]
WantedBy=multi-user.target

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cesarz
Solution 2 sri kumar