build from source

This commit is contained in:
yangzhao_kl 2022-01-29 11:23:08 +08:00
parent 60989f2e5d
commit 1f67a8b6b8
5 changed files with 33 additions and 14 deletions

View File

@ -2,45 +2,42 @@
Name: alertmanager
Version: 0.21.0
Release: 3
Release: 4
Summary: Prometheus Alertmanager.
License: ASL 2.0
URL: https://github.com/prometheus/%{name}
%ifarch aarch64
%global hostarch arm64
%endif
%ifarch x86_64
%global hostarch amd64
%endif
Source0: https://github.com/prometheus/%{name}/releases/download/v%{version}/%{name}-%{version}.linux-%{hostarch}.tar.gz
Source0: https://github.com/prometheus/%{name}/archive/refs/tags/v%{version}.tar.gz
Source1: %{name}.service
Source2: %{name}.default
Source3: %{name}.yml
BuildRequires: golang
%{?systemd_requires}
Requires(pre): shadow-utils
%description
The Alertmanager handles alerts sent by client applications such as the
Prometheus server. It takes care of deduplicating, grouping, and routing them to
the correct receiver integration such as email, PagerDuty, or OpsGenie. It also
takes care of silencing and inhibition of alerts.
%prep
%setup -q -n %{name}-%{version}.linux-%{hostarch}
%setup -q -n %{name}-%{version}
%build
/bin/true
go build -mod=vendor -o %{_builddir}/%{name}-%{version}/bin/alertmanager ./cmd/alertmanager
go build -mod=vendor -o %{_builddir}/%{name}-%{version}/bin/amtool ./cmd/amtool
%install
mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus
install -D -m 644 alertmanager.yml %{buildroot}%{_sysconfdir}/prometheus/%{name}.yml
install -D -m 755 %{name} %{buildroot}%{_bindir}/%{name}
install -D -m 755 amtool %{buildroot}%{_bindir}/amtool
install -D -m 755 -vd %{buildroot}%{_bindir}
install -D -m 755 -vp %{_builddir}/%{name}-%{version}/bin/* %{buildroot}%{_bindir}
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/default/%{name}
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/prometheus/%{name}.yml
%pre
getent group prometheus >/dev/null || groupadd -r prometheus
@ -68,6 +65,9 @@ exit 0
%dir %attr(755, prometheus, prometheus)%{_sharedstatedir}/prometheus
%changelog
* Sat Jan 29 2022 yangzhao <yangzhao1@kylinos.cn> - 0.21.0-4
- Build from source code
* Thu Aug 05 2021 herengui <herengui@uniontech.com> - 0.21.0-3
- Type: bugfix
- ID: #I4431I

19
alertmanager.yml Normal file
View File

@ -0,0 +1,19 @@
global:
resolve_timeout: 5m
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://127.0.0.1:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']

BIN
v0.21.0.tar.gz Normal file

Binary file not shown.