|
28 | 28 | #include "Transports/UDP.h" |
29 | 29 | #include "Transports/Unix.h" |
30 | 30 | #include "Transports/StdOut.h" |
| 31 | +#include "Transports/WebSocket.h" |
31 | 32 |
|
32 | 33 | #ifdef O2_MONITORING_WITH_APPMON |
33 | 34 | #include "Backends/ApMonBackend.h" |
@@ -116,6 +117,17 @@ std::unique_ptr<Backend> getInfluxDb(http::url uri) |
116 | 117 | auto transport = std::make_unique<transports::StdOut>(); |
117 | 118 | return std::make_unique<backends::InfluxDB>(std::move(transport)); |
118 | 119 | } |
| 120 | + if (uri.protocol == "ws") { |
| 121 | + std::string tokenLabel = "token="; |
| 122 | + auto tokenSearch = uri.search.find(tokenLabel); |
| 123 | + uri.path.erase(std::remove(uri.path.begin(), uri.path.end(), '/'), uri.path.end()); |
| 124 | + if (tokenSearch == std::string::npos) { |
| 125 | + throw MonitoringException("Factory", "Grafana token is required for WebSocket backend"); |
| 126 | + } |
| 127 | + std::string token = uri.search.substr(tokenSearch + tokenLabel.length()); |
| 128 | + auto transport = std::make_unique<transports::WebSocket>(uri.host, uri.port, token, uri.path); |
| 129 | + return std::make_unique<backends::InfluxDB>(std::move(transport)); |
| 130 | + } |
119 | 131 | if (uri.protocol == "kafka") { |
120 | 132 | #ifdef O2_MONITORING_WITH_KAFKA |
121 | 133 | auto transport = std::make_unique<transports::Kafka>(uri.host, uri.port, uri.search); |
@@ -165,6 +177,7 @@ std::unique_ptr<Backend> MonitoringFactory::GetBackend(std::string& url) |
165 | 177 | {"influxdb-unix", getInfluxDb}, |
166 | 178 | {"influxdb-stdout", getInfluxDb}, |
167 | 179 | {"influxdb-kafka", getInfluxDb}, |
| 180 | + {"influxdb-ws", getInfluxDb}, |
168 | 181 | {"influxdbv2", getInfluxDbv2}, |
169 | 182 | {"apmon", getApMon}, |
170 | 183 | {"no-op", getNoop} |
|
0 commit comments