Skip to content

Instantly share code, notes, and snippets.

@Tumar
Last active September 10, 2024 13:19
Show Gist options
  • Save Tumar/cd1ef5ecd88086d49d04d9a4205f4763 to your computer and use it in GitHub Desktop.
Save Tumar/cd1ef5ecd88086d49d04d9a4205f4763 to your computer and use it in GitHub Desktop.
Install alertmanager
# Create user
useradd --no-create-home --shell /bin/false alertmanager
# Download and unpack
wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertmanager-0.20.0.linux-amd64.tar.gz
tar -xvf alertmanager-0.20.0.linux-amd64.tar.gz
mv alertmanager-0.20.0.linux-amd64/alertmanager /usr/local/bin/
mv alertmanager-0.20.0.linux-amd64/amtool /usr/local/bin/
chown alertmanager:alertmanager /usr/local/bin/alertmanager
chown alertmanager:alertmanager /usr/local/bin/amtool
# Cleanup
rm -rf alertmanager-0.20.0*
# Create configuration file
mkdir /etc/alertmanager
nano /etc/alertmanager/alertmanager.yml
### Configuration
global:
slack_api_url: 'https://hooks.slack.com/services/x/xx/xxx'
route:
group_by: ['instance', 'alert']
group_wait: 30s
receiver: default-interval
receivers:
- name: 'default-receiver'
slack_configs:
- channel: 'alerts'
# Change ownership
chown alertmanager:alertmanager -R /etc/alertmanager
# Create systemd unit file
nano /etc/systemd/system/alertmanager.service
### Alertmanager systemd
[Unit]
Description=Alertmanager
Wants=network-online.target
After=network-online.target
[Service]
User=alertmanager
Group=alertmanager
Type=simple
WorkingDirectory=/etc/alertmanager/
ExecStart=/usr/local/bin/alertmanager --config.file=/etc/alertmanager/alertmanager.yml --web.external-url http://0.0.0.0:9093
[Install]
WantedBy=multi-user.target
# Run service
systemctl daemon-reload
systemctl restart alertmanager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment