1
0

Accepting request 878004 from home:witekbedyk:branches:server:monitoring

- Uyuni: `hostname` label is now set to FQDN instead of IP

OBS-URL: https://build.opensuse.org/request/show/878004
OBS-URL: https://build.opensuse.org/package/show/server:monitoring/golang-github-prometheus-prometheus?expand=0&rev=36
This commit is contained in:
Stefano Torresi 2021-03-16 13:14:42 +00:00 committed by Git OBS Bridge
parent 1f0866e2bd
commit a3ec3a51f9
3 changed files with 26 additions and 13 deletions

View File

@ -1,11 +1,11 @@
From 7009f54ee93f8f0a36a1a9320a56410ce6a11f44 Mon Sep 17 00:00:00 2001
From e55a27d2102a77ce3f01f3f36060843bb2b46fd2 Mon Sep 17 00:00:00 2001
From: Joao Cavalheiro <jcavalheiro@suse.de>
Date: Mon, 27 Jul 2020 17:42:33 +0200
Subject: [PATCH 3/3] Add Uyuni service discovery
---
discovery/install/install.go | 1 +
discovery/uyuni/uyuni.go | 397 ++++++++++++++++
discovery/uyuni/uyuni.go | 405 ++++++++++++++++
discovery/uyuni/uyuni_test.go | 46 ++
go.mod | 1 +
go.sum | 2 +
@ -21,7 +21,7 @@ Subject: [PATCH 3/3] Add Uyuni service discovery
vendor/github.com/kolo/xmlrpc/response.go | 42 ++
vendor/github.com/kolo/xmlrpc/test_server.rb | 25 +
vendor/modules.txt | 3 +
17 files changed, 1550 insertions(+)
17 files changed, 1558 insertions(+)
create mode 100644 discovery/uyuni/uyuni.go
create mode 100644 discovery/uyuni/uyuni_test.go
create mode 100644 vendor/github.com/kolo/xmlrpc/LICENSE
@ -49,10 +49,10 @@ index d9394f270..7af209cac 100644
)
diff --git a/discovery/uyuni/uyuni.go b/discovery/uyuni/uyuni.go
new file mode 100644
index 000000000..674fdb7d7
index 000000000..2336d2746
--- /dev/null
+++ b/discovery/uyuni/uyuni.go
@@ -0,0 +1,397 @@
@@ -0,0 +1,405 @@
+// Copyright 2019 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
@ -121,9 +121,10 @@ index 000000000..674fdb7d7
+}
+
+type networkInfo struct {
+ SystemID int `xmlrpc:"system_id"`
+ Hostname string `xmlrpc:"hostname"`
+ IP string `xmlrpc:"ip"`
+ SystemID int `xmlrpc:"system_id"`
+ Hostname string `xmlrpc:"hostname"`
+ PrimaryFQDN string `xmlrpc:"primary_fqdn"`
+ IP string `xmlrpc:"ip"`
+}
+
+type exporterConfig struct {
@ -329,18 +330,24 @@ index 000000000..674fdb7d7
+ var labelSets []model.LabelSet
+ var errors []error
+ var proxyPortNumber string
+ var hostname string
+ if combinedFormulaData.ProxyIsEnabled {
+ proxyPortNumber = fmt.Sprintf("%d", int(combinedFormulaData.ProxyPort))
+ }
+ if len(networkInfo.PrimaryFQDN) > 0 {
+ hostname = networkInfo.PrimaryFQDN
+ } else {
+ hostname = networkInfo.Hostname
+ }
+ initializeExporterTargets(&labelSets, "node", combinedFormulaData.NodeExporter, proxyPortNumber, &errors)
+ initializeExporterTargets(&labelSets, "apache", combinedFormulaData.ApacheExporter, proxyPortNumber, &errors)
+ initializeExporterTargets(&labelSets, "postgres", combinedFormulaData.PostgresExporter, proxyPortNumber, &errors)
+ managedGroupNames := getSystemGroupNames(systemGroupsIDs)
+ for _, labels := range labelSets {
+ // add hostname to the address label
+ addr := fmt.Sprintf("%s:%s", networkInfo.IP, labels[model.AddressLabel])
+ addr := fmt.Sprintf("%s:%s", hostname, labels[model.AddressLabel])
+ labels[model.AddressLabel] = model.LabelValue(addr)
+ labels["hostname"] = model.LabelValue(networkInfo.Hostname)
+ labels["hostname"] = model.LabelValue(hostname)
+ labels["groups"] = model.LabelValue(strings.Join(managedGroupNames, ","))
+ if combinedFormulaData.ProxyIsEnabled {
+ labels[model.MetricsPathLabel] = "/proxy"
@ -399,7 +406,8 @@ index 000000000..674fdb7d7
+ // Log debug information
+ if networkInfoBySystemID[systemID].IP != "" {
+ level.Debug(d.logger).Log("msg", "Found monitored system",
+ "Host", networkInfoBySystemID[systemID].Hostname,
+ "PrimaryFQDN", networkInfoBySystemID[systemID].PrimaryFQDN,
+ "Hostname", networkInfoBySystemID[systemID].Hostname,
+ "Network", fmt.Sprintf("%+v", networkInfoBySystemID[systemID]),
+ "Groups", fmt.Sprintf("%+v", systemGroupIDsBySystemID[systemID]),
+ "Formulas", fmt.Sprintf("%+v", combinedFormulaDataBySystemID[systemID]))
@ -1708,5 +1716,5 @@ index a2365b4c8..7f30086c3 100644
github.com/konsorten/go-windows-terminal-sequences
# github.com/mailru/easyjson v0.7.1
--
2.29.2
2.26.2

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Mar 9 13:28:50 UTC 2021 - Witek Bedyk <witold.bedyk@suse.com>
- Uyuni: `hostname` label is now set to FQDN instead of IP
-------------------------------------------------------------------
Mon Nov 9 10:49:39 UTC 2020 - Stefano Torresi <stefano.torresi@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package golang-github-prometheus-prometheus
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2017 Silvio Moioli <moio@suse.com>
#
# All modifications and additions to the file contributed by third parties