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
This commit is contained in:
Lars Vogdt 2017-05-17 22:07:04 +00:00 committed by Git OBS Bridge
commit 213acb88c1
10 changed files with 295 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,30 @@
From 2d3ffcec3eca92e678077b64afc14b45b6e33643 Mon Sep 17 00:00:00 2001
From: Silvio Moioli <smoioli@suse.de>
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

View File

@ -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(

16
_service Normal file
View File

@ -0,0 +1,16 @@
<services>
<service name="tar_scm" mode="disabled">
<param name="url">https://github.com/prometheus/prometheus.git</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
<param name="versionformat">1.5.2</param>
<param name="revision">v1.5.2</param>
</service>
<service name="recompress" mode="disabled">
<param name="file">prometheus-*.tar</param>
<param name="compression">xz</param>
</service>
<service name="set_version" mode="disabled">
<param name="basename">prometheus</param>
</service>
</services>

View File

@ -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

View File

@ -0,0 +1,114 @@
#
# spec file for package golang-github-prometheus-prometheus
#
# Copyright (c) 2017 Silvio Moioli <moio@suse.com>
#
# 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

3
prometheus-1.5.2.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d66277db0bcb0d4507f7944eaaa2b37e194d15ef3716403318251637428fa3d2
size 3213792

15
prometheus.service Normal file
View File

@ -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

38
prometheus.yml Normal file
View File

@ -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=<job_name>` 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']