From 6788676faa96d4e2c5d6e72257b49e395b3c4564 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Thu, 16 Feb 2023 21:37:11 +0900 Subject: [PATCH] Deploy `/etc/vector/alertmanager.toml`. --- cookbooks/prometheus/alertmanager_setup.rb | 13 +++++++++++++ .../systemd/system/vector-alertmanager.service | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 cookbooks/prometheus/files/etc/systemd/system/vector-alertmanager.service diff --git a/cookbooks/prometheus/alertmanager_setup.rb b/cookbooks/prometheus/alertmanager_setup.rb index 31c0774..253f780 100644 --- a/cookbooks/prometheus/alertmanager_setup.rb +++ b/cookbooks/prometheus/alertmanager_setup.rb @@ -61,6 +61,19 @@ remote_file '/etc/logrotate.d/alertmanager' do mode '644' end +# Deploy `vector` config for `alertmanager`: +remote_file '/etc/vector/alertmanager.toml' do + owner 'root' + group 'root' + mode '644' + + notifies :restart, 'service[vector-alertmanager]' +end + +service 'vector-alertmanager' do + action [:enable, :start] +end + # Firewall settings here: %w( 9093/tcp ).each do |p| execute "ufw allow #{p}" do diff --git a/cookbooks/prometheus/files/etc/systemd/system/vector-alertmanager.service b/cookbooks/prometheus/files/etc/systemd/system/vector-alertmanager.service new file mode 100644 index 0000000..5a0cba8 --- /dev/null +++ b/cookbooks/prometheus/files/etc/systemd/system/vector-alertmanager.service @@ -0,0 +1,16 @@ +[Unit] +Description=Vector +Documentation=https://vector.dev +After=network-online.target +Requires=network-online.target + +[Service] +ExecStart=/usr/bin/vector --config /etc/vector/alertmanager.toml +ExecReload=/bin/kill -HUP $MAINPID +Restart=always +StandardOutput=journal +StandardError=journal +SyslogIdentifier=vector + +[Install] +WantedBy=multi-user.target