From 213acb88c128106714ee1c9b1df3a7604ad82e46af4bd3272a876e1ee8a52898 Mon Sep 17 00:00:00 2001 From: Lars Vogdt Date: Wed, 17 May 2017 22:07:04 +0000 Subject: [PATCH] Accepting request 493648 from home:tserong Added systemd unit and default config on top of moio's package OBS-URL: https://build.opensuse.org/request/show/493648 OBS-URL: https://build.opensuse.org/package/show/server:monitoring/golang-github-prometheus-prometheus?expand=0&rev=1 --- .gitattributes | 23 ++++ .gitignore | 1 + ...-not-force-the-pure-Go-name-resolver.patch | 30 +++++ 0002-Default-settings.patch | 38 ++++++ _service | 16 +++ golang-github-prometheus-prometheus.changes | 17 +++ golang-github-prometheus-prometheus.spec | 114 ++++++++++++++++++ prometheus-1.5.2.tar.xz | 3 + prometheus.service | 15 +++ prometheus.yml | 38 ++++++ 10 files changed, 295 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 0001-Do-not-force-the-pure-Go-name-resolver.patch create mode 100644 0002-Default-settings.patch create mode 100644 _service create mode 100644 golang-github-prometheus-prometheus.changes create mode 100644 golang-github-prometheus-prometheus.spec create mode 100644 prometheus-1.5.2.tar.xz create mode 100644 prometheus.service create mode 100644 prometheus.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/0001-Do-not-force-the-pure-Go-name-resolver.patch b/0001-Do-not-force-the-pure-Go-name-resolver.patch new file mode 100644 index 0000000..8d8967b --- /dev/null +++ b/0001-Do-not-force-the-pure-Go-name-resolver.patch @@ -0,0 +1,30 @@ +From 2d3ffcec3eca92e678077b64afc14b45b6e33643 Mon Sep 17 00:00:00 2001 +From: Silvio Moioli +Date: Tue, 28 Mar 2017 14:08:03 +0200 +Subject: [PATCH] Do not force the pure Go name resolver + +Revert to Go's default mechanism that will decide between the `netgo` +pure-Go implementation and the `netcgo` cgo-based implementation depending +on OS and environment variables. + +This allows, among other things, to use Prometheus to scrape mDNS targets. +--- + .promu.yml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.promu.yml b/.promu.yml +index 27aa3aa..6ad3011 100644 +--- a/.promu.yml ++++ b/.promu.yml +@@ -6,7 +6,7 @@ build: + path: ./cmd/prometheus + - name: promtool + path: ./cmd/promtool +- flags: -a -tags netgo ++ flags: -a + ldflags: | + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} +-- +2.7.4 + diff --git a/0002-Default-settings.patch b/0002-Default-settings.patch new file mode 100644 index 0000000..71d2ed1 --- /dev/null +++ b/0002-Default-settings.patch @@ -0,0 +1,38 @@ +Index: prometheus-1.5.2/cmd/prometheus/config.go +=================================================================== +--- prometheus-1.5.2.orig/cmd/prometheus/config.go ++++ prometheus-1.5.2/cmd/prometheus/config.go +@@ -73,7 +73,8 @@ func init() { + "Print version information.", + ) + cfg.fs.StringVar( +- &cfg.configFile, "config.file", "prometheus.yml", ++ &cfg.configFile, "config.file", ++ "/etc/prometheus/prometheus.yml", + "Prometheus configuration file name.", + ) + +@@ -111,17 +112,20 @@ func init() { + "Enable remote service shutdown.", + ) + cfg.fs.StringVar( +- &cfg.web.ConsoleTemplatesPath, "web.console.templates", "consoles", ++ &cfg.web.ConsoleTemplatesPath, "web.console.templates", ++ "/etc/prometheus/consoles", + "Path to the console template directory, available at /consoles.", + ) + cfg.fs.StringVar( +- &cfg.web.ConsoleLibrariesPath, "web.console.libraries", "console_libraries", ++ &cfg.web.ConsoleLibrariesPath, "web.console.libraries", ++ "/etc/prometheus/console_libraries", + "Path to the console library directory.", + ) + + // Storage. + cfg.fs.StringVar( +- &cfg.storage.PersistenceStoragePath, "storage.local.path", "data", ++ &cfg.storage.PersistenceStoragePath, "storage.local.path", ++ "/var/lib/prometheus/metrics", + "Base path for metrics storage.", + ) + cfg.fs.IntVar( diff --git a/_service b/_service new file mode 100644 index 0000000..69e46c6 --- /dev/null +++ b/_service @@ -0,0 +1,16 @@ + + + https://github.com/prometheus/prometheus.git + git + .git + 1.5.2 + v1.5.2 + + + prometheus-*.tar + xz + + + prometheus + + diff --git a/golang-github-prometheus-prometheus.changes b/golang-github-prometheus-prometheus.changes new file mode 100644 index 0000000..13cb1ee --- /dev/null +++ b/golang-github-prometheus-prometheus.changes @@ -0,0 +1,17 @@ +------------------------------------------------------------------- +Tue May 9 05:32:44 UTC 2017 - tserong@suse.com + +- Add systemd unit file and default config (/etc/prometheus/prometheus.yml) +- Run as unprivileged "prometheus" user +- Default to /etc/prometheus for config and /var/lib/prometheus for metrics + + Added 0002-Default-settings.patch + +------------------------------------------------------------------- +Wed Apr 26 09:07:42 UTC 2017 - tserong@suse.com + +- Add BuildRequires: glibc-devel-static to fix aarch64 build + +------------------------------------------------------------------- +Wed Mar 29 09:50:28 UTC 2017 - moio@suse.com + +- Initial version diff --git a/golang-github-prometheus-prometheus.spec b/golang-github-prometheus-prometheus.spec new file mode 100644 index 0000000..321f06b --- /dev/null +++ b/golang-github-prometheus-prometheus.spec @@ -0,0 +1,114 @@ +# +# spec file for package golang-github-prometheus-prometheus +# +# Copyright (c) 2017 Silvio Moioli +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +%{go_nostrip} + +Name: golang-github-prometheus-prometheus +Version: 1.5.2 +Release: 0 +License: Apache-2.0 +Summary: The Prometheus monitoring system and time series database +Url: https://prometheus.io/ +Group: System/Management +Source: prometheus-%{version}.tar.xz +Source1: prometheus.service +Source2: prometheus.yml +Patch1: 0001-Do-not-force-the-pure-Go-name-resolver.patch +# Lifted from Debian's prometheus package +Patch2: 0002-Default-settings.patch +%ifarch aarch64 +# For some reason the aarch64 build fails with: +# + promu build +# > prometheus +# # github.com/prometheus/prometheus/cmd/prometheus +# /usr/lib64/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1 +# /usr/lib64/gcc/aarch64-suse-linux/4.8/../../../../aarch64-suse-linux/bin/ld: cannot find -lpthread +# /usr/lib64/gcc/aarch64-suse-linux/4.8/../../../../aarch64-suse-linux/bin/ld: cannot find -lc +# collect2: error: ld returned 1 exit status +# Adding glibc-devel-static fixes it, but it's odd that this isn't +# also a problem on x86_64. +BuildRequires: glibc-devel-static +%endif +BuildRequires: fdupes +BuildRequires: golang-github-prometheus-promu +BuildRequires: golang-packaging +BuildRequires: xz +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%{?systemd_requires} +Requires(pre): shadow +%{go_provides} + +%description +Prometheus's main features are: + - a multi-dimensional data model (time series identified by metric name and key/value pairs) + - a flexible query language to leverage this dimensionality + - no reliance on distributed storage; single server nodes are autonomous + - time series collection happens via a pull model over HTTP + - pushing time series is supported via an intermediary gateway + - targets are discovered via service discovery or static configuration + - multiple modes of graphing and dashboarding support + +%prep +%setup -q -n prometheus-%{version} +%patch1 -p 1 +%patch2 -p 1 + +%build +%goprep github.com/prometheus/prometheus +GOPATH=%{_builddir}/go promu build + +%install +%goinstall +install -D -m0755 %{_builddir}/prometheus-%{version}/prometheus %{buildroot}/%{_bindir}/prometheus +install -D -m0755 %{_builddir}/prometheus-%{version}/prometheus %{buildroot}/%{_bindir}/promtool +%gosrc +install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/prometheus.service +install -Dd -m 0755 %{buildroot}%{_sbindir} +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcprometheus +install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/prometheus/prometheus.yml +install -Dd -m 0750 %{buildroot}%{_localstatedir}/lib/prometheus +install -Dd -m 0750 %{buildroot}%{_localstatedir}/lib/prometheus/metrics +%gofilelist +%fdupes %{buildroot} + +%pre +%service_add_pre prometheus.service +getent group prometheus >/dev/null || %{_sbindir}/groupadd -r prometheus +getent passwd prometheus >/dev/null || %{_sbindir}/useradd -r -g prometheus -d %{_localstatedir}/lib/prometheus -s /sbin/nologin prometheus + +%post +%service_add_post prometheus.service + +%preun +%service_del_preun prometheus.service + +%postun +%service_del_postun prometheus.service + +%files -f file.lst +%defattr(-,root,root,-) +%doc README.md LICENSE +%{_bindir}/prometheus +%{_bindir}/promtool +%{_unitdir}/prometheus.service +%{_sbindir}/rcprometheus +%dir %attr(0750, prometheus, prometheus) %{_localstatedir}/lib/prometheus +%dir %attr(0750, prometheus, prometheus) %{_localstatedir}/lib/prometheus/metrics +%dir %{_sysconfdir}/prometheus +%config(noreplace) %{_sysconfdir}/prometheus/prometheus.yml + +%changelog diff --git a/prometheus-1.5.2.tar.xz b/prometheus-1.5.2.tar.xz new file mode 100644 index 0000000..d5e7a34 --- /dev/null +++ b/prometheus-1.5.2.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d66277db0bcb0d4507f7944eaaa2b37e194d15ef3716403318251637428fa3d2 +size 3213792 diff --git a/prometheus.service b/prometheus.service new file mode 100644 index 0000000..9ea54c2 --- /dev/null +++ b/prometheus.service @@ -0,0 +1,15 @@ +[Unit] +Description=Monitoring system and time series database +Documentation=https://prometheus.io/docs/introduction/overview/ + +[Service] +Restart=always +User=prometheus +EnvironmentFile=-/etc/sysconfig/prometheus +ExecStart=/usr/bin/prometheus $ARGS +ExecReload=/bin/kill -HUP $MAINPID +TimeoutStopSec=20s +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..3be3860 --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,38 @@ +# Sample config for Prometheus. + +global: + scrape_interval: 15s # By default, scrape targets every 15 seconds. + evaluation_interval: 15s # By default, scrape targets every 15 seconds. + # scrape_timeout is set to the global default (10s). + + # Attach these labels to any time series or alerts when communicating with + # external systems (federation, remote storage, Alertmanager). + external_labels: + monitor: 'example' + +# Load and evaluate rules in this file every 'evaluation_interval' seconds. +rule_files: + # - "first.rules" + # - "second.rules" + +# A scrape configuration containing exactly one endpoint to scrape: +# Here it's Prometheus itself. +scrape_configs: + # The job name is added as a label `job=` to any timeseries scraped from this config. + - job_name: 'prometheus' + + # Override the global default and scrape targets from this job every 5 seconds. + scrape_interval: 5s + scrape_timeout: 5s + + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + + static_configs: + - targets: ['localhost:9090'] + + - job_name: node + # If prometheus-node-exporter is installed, grab stats about the local + # machine by default. + static_configs: + - targets: ['localhost:9100']