Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] Interesting, could you open an issue?

[DiscordArchive] Interesting, could you open an issue?

[DiscordArchive] Interesting, could you open an issue?

Pages (2): Previous 1 2
rektbyfaith
Administrator
0
05-24-2023, 08:40 PM
#11
Archived author: Foe • Posted: 2023-05-24T20:40:37.480000+00:00
Original source

```Diff
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index b1302aacb5..7c492dba17 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -87,9 +87,17 @@ void Metric::LoadFromConfigs()
return;
}

+ std:Confusedtring apiToken = sConfigMgr->GetStringDefault("Metric.Token", "");
+ if (apiToken.empty())
+ {
+ TC_LOG_ERROR("metric", "'Metric.Token' not specified in configuration file.");
+ return;
+ }
+
_hostname.assign(tokens[0]);
_port.assign(tokens[1]);
_databaseName.assign(tokens[2]);
+ _apiToken.assign(apiToken);
Connect();

ScheduleSend();
@@ -171,6 +179,7 @@ void Metric::SendBatch()

GetDataStream() << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
GetDataStream() << "Host: " << _hostname << ":" << _port << "\r\n";
+ GetDataStream() << "Authorization: Token " << _apiToken << "\r\n";
GetDataStream() << "Accept: */*\r\n";
GetDataStream() << "Content-Type: application/octet-stream\r\n";
GetDataStream() << "Content-Transfer-Encoding: binary\r\n";
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index d46e056613..45de415e5a 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -75,6 +75,7 @@ private:
std:Confusedtring _hostname;
std:Confusedtring _port;
std:Confusedtring _databaseName;
+ std:Confusedtring _apiToken;
std::function<void()> _overallStatusLogger;
std:Confusedtring _realmName;

```

Here's a quick fix to allow the base metric system to communicate with Influxdb v2.x using API tokens, you still have to do some workarounds like creating a v1 API user and generating said API tokens but it's functional
rektbyfaith
05-24-2023, 08:40 PM #11

Archived author: Foe • Posted: 2023-05-24T20:40:37.480000+00:00
Original source

```Diff
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index b1302aacb5..7c492dba17 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -87,9 +87,17 @@ void Metric::LoadFromConfigs()
return;
}

+ std:Confusedtring apiToken = sConfigMgr->GetStringDefault("Metric.Token", "");
+ if (apiToken.empty())
+ {
+ TC_LOG_ERROR("metric", "'Metric.Token' not specified in configuration file.");
+ return;
+ }
+
_hostname.assign(tokens[0]);
_port.assign(tokens[1]);
_databaseName.assign(tokens[2]);
+ _apiToken.assign(apiToken);
Connect();

ScheduleSend();
@@ -171,6 +179,7 @@ void Metric::SendBatch()

GetDataStream() << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
GetDataStream() << "Host: " << _hostname << ":" << _port << "\r\n";
+ GetDataStream() << "Authorization: Token " << _apiToken << "\r\n";
GetDataStream() << "Accept: */*\r\n";
GetDataStream() << "Content-Type: application/octet-stream\r\n";
GetDataStream() << "Content-Transfer-Encoding: binary\r\n";
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index d46e056613..45de415e5a 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -75,6 +75,7 @@ private:
std:Confusedtring _hostname;
std:Confusedtring _port;
std:Confusedtring _databaseName;
+ std:Confusedtring _apiToken;
std::function<void()> _overallStatusLogger;
std:Confusedtring _realmName;

```

Here's a quick fix to allow the base metric system to communicate with Influxdb v2.x using API tokens, you still have to do some workarounds like creating a v1 API user and generating said API tokens but it's functional

rektbyfaith
Administrator
0
05-24-2023, 08:41 PM
#12
Archived author: Foe • Posted: 2023-05-24T20:41:17.930000+00:00
Original source

Working on converting my dashboards to the new flux language now, but data is coming in at least
[Image: image.png?ex=690c5f2d&is=690b0dad&hm=922...8ec58290e&]
rektbyfaith
05-24-2023, 08:41 PM #12

Archived author: Foe • Posted: 2023-05-24T20:41:17.930000+00:00
Original source

Working on converting my dashboards to the new flux language now, but data is coming in at least
[Image: image.png?ex=690c5f2d&is=690b0dad&hm=922...8ec58290e&]

Pages (2): Previous 1 2
Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)