From 2ca90a879f9a77f0ca2a28fb3d1eab3c26319506 Mon Sep 17 00:00:00 2001 From: David AMSALLEM Date: Wed, 21 Feb 2024 11:38:32 +0100 Subject: [PATCH] Fix the parsing of metaKey * namespaces can contains '-'. * get the substring after the prefix. --- pkg/aerospike/config.go | 2 +- pkg/aerospike/discovery.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/aerospike/config.go b/pkg/aerospike/config.go index 00c123b..e54b8f4 100644 --- a/pkg/aerospike/config.go +++ b/pkg/aerospike/config.go @@ -64,7 +64,7 @@ var ( TLSTag: "tls", TLSHostnameMetaKey: "tls-hostname", NamespaceMetaKey: "", - NamespaceMetaKeyPrefix: "", + NamespaceMetaKeyPrefix: "aerospike-monitoring-", MonitoringSet: "monitoring", LatencyKeyPrefix: "monitoring_latency_", DurabilityKeyPrefix: "monitoring_durability_", diff --git a/pkg/aerospike/discovery.go b/pkg/aerospike/discovery.go index ff6540d..8ba82c4 100644 --- a/pkg/aerospike/discovery.go +++ b/pkg/aerospike/discovery.go @@ -96,8 +96,10 @@ func (conf AerospikeProbeConfig) getNamespacesFromEntry(logger log.Logger, entry if !ready { continue } - ns := strings.Split(metaKey, "-")[2] // MetaKey is like : "aerospike-monitoring-closeststore" - namespaces[ns] = struct{}{} + ns := metaKey[len(conf.AerospikeEndpointConfig.NamespaceMetaKeyPrefix):] // MetaKey is like : "aerospike-monitoring-closeststore" + if len(ns) > 0 { + namespaces[ns] = struct{}{} + } } // DEPRECATED way to get namespaces in case of fallback required or empty namespaces with the new method