From 7c4a5bc37ccc1f5f1567cf97c65fb04cd3be26ad Mon Sep 17 00:00:00 2001 From: skelUA Date: Sat, 19 Jul 2025 23:14:42 +0300 Subject: [PATCH] fix(Core/Metrics): InfluxDB v1 config check #22358 (#22479) Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> --- src/common/Metric/Metric.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index c35fa30b6..96e142faf 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -107,18 +107,17 @@ void Metric::LoadFromConfigs() } std::vector tokens = Acore::Tokenize(connectionInfo, ';', true); - if (tokens.size() != 2) - { - LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file."); - return; - } - - _hostname.assign(tokens[0]); - _port.assign(tokens[1]); - _useV2 = sConfigMgr->GetOption("Metric.InfluxDB.v2", false); if (_useV2) { + if (tokens.size() != 2) + { + LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file. (hostname;port)"); + return; + } + + _hostname.assign(tokens[0]); + _port.assign(tokens[1]); _org = sConfigMgr->GetOption("Metric.InfluxDB.Org", ""); _bucket = sConfigMgr->GetOption("Metric.InfluxDB.Bucket", ""); _token = sConfigMgr->GetOption("Metric.InfluxDB.Token", ""); @@ -133,10 +132,12 @@ void Metric::LoadFromConfigs() { if (tokens.size() != 3) { - LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file."); + LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file. (hostname;port;database)"); return; } + _hostname.assign(tokens[0]); + _port.assign(tokens[1]); _databaseName.assign(tokens[2]); }