mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 07:53:44 +00:00
Merge branch 'master' into Playerbot
This commit is contained in:
@@ -99,25 +99,48 @@ void Metric::LoadFromConfigs()
|
||||
// Cancel any scheduled operation if the config changed from Enabled to Disabled.
|
||||
if (_enabled && !previousValue)
|
||||
{
|
||||
std::string connectionInfo = sConfigMgr->GetOption<std::string>("Metric.ConnectionInfo", "");
|
||||
std::string connectionInfo = sConfigMgr->GetOption<std::string>("Metric.InfluxDB.Connection", "");
|
||||
if (connectionInfo.empty())
|
||||
{
|
||||
LOG_ERROR("metric", "'Metric.ConnectionInfo' not specified in configuration file.");
|
||||
LOG_ERROR("metric", "Metric.InfluxDB.Connection not specified in configuration file.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(connectionInfo, ';', true);
|
||||
if (tokens.size() != 3)
|
||||
if (tokens.size() != 2)
|
||||
{
|
||||
LOG_ERROR("metric", "'Metric.ConnectionInfo' specified with wrong format in configuration file.");
|
||||
LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file.");
|
||||
return;
|
||||
}
|
||||
|
||||
_hostname.assign(tokens[0]);
|
||||
_port.assign(tokens[1]);
|
||||
_databaseName.assign(tokens[2]);
|
||||
Connect();
|
||||
|
||||
_useV2 = sConfigMgr->GetOption<bool>("Metric.InfluxDB.v2", false);
|
||||
if (_useV2)
|
||||
{
|
||||
_org = sConfigMgr->GetOption<std::string>("Metric.InfluxDB.Org", "");
|
||||
_bucket = sConfigMgr->GetOption<std::string>("Metric.InfluxDB.Bucket", "");
|
||||
_token = sConfigMgr->GetOption<std::string>("Metric.InfluxDB.Token", "");
|
||||
|
||||
if (_org.empty() || _bucket.empty() || _token.empty())
|
||||
{
|
||||
LOG_ERROR("metric", "InfluxDB v2 parameters missing: org, bucket, or token.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tokens.size() != 3)
|
||||
{
|
||||
LOG_ERROR("metric", "Metric.InfluxDB.Connection specified with wrong format in configuration file.");
|
||||
return;
|
||||
}
|
||||
|
||||
_databaseName.assign(tokens[2]);
|
||||
}
|
||||
|
||||
Connect();
|
||||
ScheduleSend();
|
||||
ScheduleOverallStatusLog();
|
||||
}
|
||||
@@ -206,8 +229,18 @@ void Metric::SendBatch()
|
||||
if (!GetDataStream().good() && !Connect())
|
||||
return;
|
||||
|
||||
GetDataStream() << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
|
||||
GetDataStream() << "Host: " << _hostname << ":" << _port << "\r\n";
|
||||
if (_useV2)
|
||||
{
|
||||
GetDataStream() << "POST " << "/api/v2/write?bucket=" << _bucket
|
||||
<< "&org=" << _org << "&precision=ns HTTP/1.1\r\n";
|
||||
GetDataStream() << "Host: " << _hostname << ":" << _port << "\r\n";
|
||||
GetDataStream() << "Authorization: Token " << _token << "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
GetDataStream() << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
|
||||
GetDataStream() << "Host: " << _hostname << ":" << _port << "\r\n";
|
||||
}
|
||||
GetDataStream() << "Accept: */*\r\n";
|
||||
GetDataStream() << "Content-Type: application/octet-stream\r\n";
|
||||
GetDataStream() << "Content-Transfer-Encoding: binary\r\n";
|
||||
|
||||
@@ -71,6 +71,10 @@ private:
|
||||
std::string _hostname;
|
||||
std::string _port;
|
||||
std::string _databaseName;
|
||||
bool _useV2 = false;
|
||||
std::string _org;
|
||||
std::string _bucket;
|
||||
std::string _token;
|
||||
std::function<void()> _overallStatusLogger;
|
||||
std::string _realmName;
|
||||
std::unordered_map<std::string, int64> _thresholds;
|
||||
|
||||
Reference in New Issue
Block a user