Sync from SUSE:SLFO:Main golang-github-prometheus-prometheus revision fd025ad47268f4b04398da2141c2c63c

This commit is contained in:
Adrian Schröter 2024-05-03 13:09:22 +02:00
commit 1e89d22201
16 changed files with 2234 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

View File

@ -0,0 +1,39 @@
From de6a642d171890fb0360fed67fd7313f13ea4b37 Mon Sep 17 00:00:00 2001
From: Jan Fajerski <jfajerski@suse.com>
Date: Fri, 8 Feb 2019 09:17:06 +0100
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.
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
Signed-off-by: Johannes Kastl <kastl@b1-systems.de>
---
.promu.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.promu.yml b/.promu.yml
index f724dc34f..ccce0d5a2 100644
--- a/.promu.yml
+++ b/.promu.yml
@@ -12,13 +12,12 @@ build:
path: ./cmd/promtool
tags:
all:
- - netgo
- builtinassets
- stringlabels
windows:
- builtinassets
- stringlabels
- flags: -a
+ flags: -mod=vendor -a
ldflags: |
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.Revision}}
--
2.40.1

View File

@ -0,0 +1,49 @@
From 06585754d2707a31fd4ab86b9b1ce82f7d55e78c Mon Sep 17 00:00:00 2001
From: Jan Fajerski <jfajerski@suse.com>
Date: Fri, 8 Feb 2019 09:28:12 +0100
Subject: [PATCH] Default settings
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
Signed-off-by: Johannes Kastl <kastl@b1-systems.de>
---
cmd/prometheus/main.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go
index 9f4c50071..f7ec14c5f 100644
--- a/cmd/prometheus/main.go
+++ b/cmd/prometheus/main.go
@@ -226,7 +226,7 @@ func main() {
a.HelpFlag.Short('h')
a.Flag("config.file", "Prometheus configuration file path.").
- Default("prometheus.yml").StringVar(&cfg.configFile)
+ Default("/etc/prometheus/prometheus.yml").StringVar(&cfg.configFile)
a.Flag("web.listen-address", "Address to listen on for UI, API, and telemetry.").
Default("0.0.0.0:9090").StringVar(&cfg.web.ListenAddress)
@@ -261,10 +261,10 @@ func main() {
Default("false").BoolVar(&cfg.web.EnableRemoteWriteReceiver)
a.Flag("web.console.templates", "Path to the console template directory, available at /consoles.").
- Default("consoles").StringVar(&cfg.web.ConsoleTemplatesPath)
+ Default("/etc/prometheus/consoles").StringVar(&cfg.web.ConsoleTemplatesPath)
a.Flag("web.console.libraries", "Path to the console library directory.").
- Default("console_libraries").StringVar(&cfg.web.ConsoleLibrariesPath)
+ Default("/etc/prometheus/console_libraries").StringVar(&cfg.web.ConsoleLibrariesPath)
a.Flag("web.page-title", "Document title of Prometheus instance.").
Default("Prometheus Time Series Collection and Processing Server").StringVar(&cfg.web.PageTitle)
@@ -273,7 +273,7 @@ func main() {
Default(".*").StringVar(&cfg.corsRegexString)
serverOnlyFlag(a, "storage.tsdb.path", "Base path for metrics storage.").
- Default("data/").StringVar(&cfg.serverStoragePath)
+ Default("/var/lib/prometheus/metrics/").StringVar(&cfg.serverStoragePath)
serverOnlyFlag(a, "storage.tsdb.min-block-duration", "Minimum duration of a data block before being persisted. For use in testing.").
Hidden().Default("2h").SetValue(&cfg.tsdb.MinBlockDuration)
--
2.39.0

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
NAME = prometheus
SPEC = golang-github-prometheus-prometheus.spec
default: clean tar
clean:
rm -f $(NAME)-*.tar $(NAME)-*.tar.gz web-ui-*.tar.gz npm_licenses.tar.bz2 vendor.tar.gz
tar:
osc service manualrun
@version=$$( awk '/^Version:/ {print $$2;exit;}' $(SPEC) ) && \
echo "Package version is $$version" && \
basename=$(NAME)-$$version && \
tar=$$basename.tar && \
web_ui=web-ui-$$version.tar && \
wd=$$(pwd) && \
tmpdir=$$(mktemp -d -p /tmp) && \
cd $$tmpdir && \
tar -zxf $$wd/$$tar.gz && \
cd $$basename && \
make assets npm_licenses assets-compress && \
tar -cf $$wd/$$web_ui web/ui/static/react && \
find web/ui/static -type f -name '*.gz' -exec tar -rf $$wd/$$web_ui "{}" \; && \
tar -rf $$wd/$$web_ui web/ui/embed.go && \
cd .. && \
echo "Creating web assets tarball" && \
mv $$basename/npm_licenses.tar.bz2 $$wd && \
cd $$wd && \
gzip -f $$web_ui && \
rm -rf $$tmpdir

15
PACKAGING_README.md Normal file
View File

@ -0,0 +1,15 @@
# Packaging prometheus
In addition to the source code in the tarball, this package also
needs the assets for the web UI. These can be generated by the
`Makefile` that is present in this package.
To do that, you need to have `make` and `npm` installed locally.
1. Change the version in the `_service` file
2. Change the version in the spec file
3. Run `make`
4. Create a changelog entry
5. Commit the changes as usual
For the OBS workflow you also need `obs-service-go_modules` as well
as `obs-service-tar_scm` and `obs-service-recompress`.

18
_service Normal file
View File

@ -0,0 +1,18 @@
<services>
<service name="tar_scm" mode="manual">
<param name="url">https://github.com/prometheus/prometheus.git</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
<param name="versionformat">@PARENT_TAG@</param>
<param name="revision">v2.47.2</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="match-tag">v2*</param>
</service>
<service name="recompress" mode="manual">
<param name="file">*.tar</param>
<param name="compression">gz</param>
</service>
<service name="go_modules" mode="manual">
<param name="archive">prometheus-2.47.2.tar.gz</param>
</service>
</services>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,176 @@
#
# spec file for package golang-github-prometheus-prometheus
#
# Copyright (c) 2023 SUSE LLC
# 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 https://bugs.opensuse.org/
#
# Compatibility with systems older than Nov 2017
# See https://en.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
%if 0%{?suse_version} < 1500
%define _sharedstatedir /var/lib
%endif
Name: golang-github-prometheus-prometheus
Version: 2.47.2
Release: 0
Summary: The Prometheus monitoring system and time series database
License: Apache-2.0
Group: System/Monitoring
URL: https://prometheus.io/
# also includes web assets generated with `make assets`
Source: prometheus-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: web-ui-%{version}.tar.gz
Source3: prometheus.service
Source4: prometheus.yml
Source5: prometheus.sysconfig
Source6: prometheus.firewall.xml
Source7: npm_licenses.tar.bz2
Source8: Makefile
Source9: PACKAGING_README.md
Patch1: 0001-Do-not-force-the-pure-Go-name-resolver.patch
# Lifted from Debian's prometheus package
Patch2: 0002-Default-settings.patch
BuildRequires: fdupes
%if 0%{?suse_version} == 1500 && 0%{?sle_version} < 150300
BuildRequires: firewall-macros
%endif
# Adding glibc-devel-static seems to be required for linking if building
# with -buildmode=pie
BuildRequires: glibc-devel-static
BuildRequires: golang-github-prometheus-promu >= 0.14.0
BuildRequires: golang-packaging
BuildRequires: golang(API) >= 1.21
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1500
Recommends: firewalld-prometheus-config
%endif
Requires(pre): user(prometheus)
Requires(pre): group(prometheus)
Requires(post): %fillup_prereq
Provides: prometheus = %{version}
ExcludeArch: s390
%systemd_ordering
%go_nostrip
%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 -a1 -n prometheus-%{version}
%autosetup -D -a2 -p1 -n prometheus-%{version}
%build
%goprep github.com/prometheus/prometheus
GOPATH=%{_builddir}/go promu build -v
%install
install -D -m0755 %{_builddir}/prometheus-%{version}/prometheus %{buildroot}/%{_bindir}/prometheus
install -D -m0755 %{_builddir}/prometheus-%{version}/promtool %{buildroot}/%{_bindir}/promtool
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/prometheus.service
install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/prometheus/prometheus.yml
install -d -m 0755 %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcprometheus
install -m 0755 -d %{buildroot}%{_datarootdir}/prometheus
cp -fr console_libraries/ consoles/ %{buildroot}%{_datarootdir}/prometheus
install -m 0755 -d %{buildroot}%{_fillupdir}
install -m 0644 %{SOURCE5} %{buildroot}%{_fillupdir}/sysconfig.prometheus
%if 0%{?suse_version} == 1500 && 0%{?sle_version} < 150300
install -m 0755 -d %{buildroot}%{_prefix}/lib/firewalld/services/
install -m 0644 %{SOURCE6} %{buildroot}%{_prefix}/lib/firewalld/services/prometheus.xml
%endif
install -Dd -m 0750 %{buildroot}%{_localstatedir}/lib/prometheus
install -Dd -m 0750 %{buildroot}%{_localstatedir}/lib/prometheus/data
install -Dd -m 0750 %{buildroot}%{_localstatedir}/lib/prometheus/metrics
install -D -m0644 %{SOURCE7} %{buildroot}/%{_defaultlicensedir}/%{name}/npm_licenses.tar.bz2
%gofilelist
%fdupes %{buildroot}/%{_prefix}
%pre
%service_add_pre prometheus.service
%post
%fillup_only -n prometheus
%service_add_post prometheus.service
%if 0%{?suse_version} == 1500 && 0%{?sle_version} < 150300
%firewalld_reload
%endif
%preun
%service_del_preun prometheus.service
%postun
%service_del_postun prometheus.service
%verifyscript
%fillup_only -n prometheus
%files
%defattr(-,root,root,-)
%doc README.md
%license LICENSE
%license %{_defaultlicensedir}/%{name}
%{_bindir}/prometheus
%{_bindir}/promtool
%{_unitdir}/prometheus.service
%{_sbindir}/rcprometheus
%{_datarootdir}/prometheus
%{_fillupdir}/sysconfig.prometheus
%dir %attr(0700,prometheus,prometheus) %{_sharedstatedir}/prometheus
%dir %attr(0700,prometheus,prometheus) %{_sharedstatedir}/prometheus/data
%dir %attr(0700,prometheus,prometheus) %{_sharedstatedir}/prometheus/metrics
%dir %{_sysconfdir}/prometheus
%config(noreplace) %{_sysconfdir}/prometheus/prometheus.yml
%if 0%{?suse_version} == 1500 && 0%{?sle_version} < 150300
%package -n firewalld-prometheus-config
Summary: Firewalld configuration file for Prometheus
Group: Productivity/Networking/Security
Version: 0.1
Release: 0
License: GPL-2.0-or-later
Requires: firewalld
%description -n firewalld-prometheus-config
This package contains configuration file for Prometheus for older versions of
Firewalld which do not provide this in own package.
%files -n firewalld-prometheus-config
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/prometheus.xml
%endif
%changelog

BIN
npm_licenses.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

BIN
prometheus-2.47.2.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

6
prometheus.firewall.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Prometheus</short>
<description>Prometheus monitoring system and time series database.</description>
<port protocol="tcp" port="9090"/>
</service>

30
prometheus.service Normal file
View File

@ -0,0 +1,30 @@
[Unit]
Description=Monitoring system and time series database
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target
[Service]
# added automatically, for details please see
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
ProtectSystem=full
ProtectHome=true
PrivateDevices=true
ProtectHostname=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictRealtime=true
# end of automatic additions
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

9
prometheus.sysconfig Normal file
View File

@ -0,0 +1,9 @@
## Path:
## Description: Prometheus monitoring server settings
## Type: string
## Default: ""
## ServiceRestart: prometheus
#
# Command line options for prometheus
#
ARGS=""

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']

BIN
vendor.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
web-ui-2.47.2.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.