From 87a4a6e8d05b766b29db2b593350ba79186b72c9 Mon Sep 17 00:00:00 2001 From: Alexander Chuprov Date: Wed, 26 Jun 2024 14:46:32 +0300 Subject: [PATCH] [#1154] node: Add info metric Signed-off-by: Alexander Chuprov --- internal/metrics/application.go | 21 +++++++++++++++++++++ internal/metrics/node.go | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 internal/metrics/application.go diff --git a/internal/metrics/application.go b/internal/metrics/application.go new file mode 100644 index 00000000..8bc408ab --- /dev/null +++ b/internal/metrics/application.go @@ -0,0 +1,21 @@ +package metrics + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" + "github.com/prometheus/client_golang/prometheus" +) + +type ApplicationInfo struct { + versionValue *prometheus.GaugeVec +} + +func NewApplicationInfo(version string) *ApplicationInfo { + appInfo := &ApplicationInfo{ + versionValue: metrics.NewGaugeVec(prometheus.GaugeOpts{ + Name: "app_info", + Help: "General information about the application.", + }, []string{"version"}), + } + appInfo.versionValue.With(prometheus.Labels{"version": version}) + return appInfo +} diff --git a/internal/metrics/node.go b/internal/metrics/node.go index 0dd86d90..d9e40144 100644 --- a/internal/metrics/node.go +++ b/internal/metrics/node.go @@ -1,6 +1,7 @@ package metrics import ( + "git.frostfs.info/TrueCloudLab/frostfs-node/misc" morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" @@ -24,6 +25,7 @@ type NodeMetrics struct { morphClient *morphClientMetrics morphCache *morphCacheMetrics log logger.LogMetrics + appInfo *ApplicationInfo } func NewNodeMetrics() *NodeMetrics { @@ -49,6 +51,7 @@ func NewNodeMetrics() *NodeMetrics { morphClient: newMorphClientMetrics(), morphCache: newMorphCacheMetrics(namespace), log: logger.NewLogMetrics(namespace), + appInfo: NewApplicationInfo(misc.Version), } }