未验证 提交 7b099888 编写于 作者: C caosiyang 提交者: GitHub

Fix #2248: use hostname and port as instance label of metrics (#2249)

Signed-off-by: Ncaosiyang <csy3228@gmail.com>
上级 104cda1a
......@@ -48,6 +48,7 @@ Please mark all change in change log and use the issue from GitHub
- \#2185 Change id to string format in http module
- \#2186 Update endpoints in http module
- \#2190 Fix memory usage is twice of index size when using GPU searching
- \#2248 Use hostname and port as instance label of metrics
- \#2252 Upgrade mishards to v0.9.0
## Task
......
......@@ -15,6 +15,7 @@
#include "metrics/SystemInfo.h"
#include "utils/Log.h"
#include <unistd.h>
#include <string>
#include <utility>
......@@ -31,14 +32,23 @@ PrometheusMetrics::Init() {
}
// Following should be read from config file.
std::string push_port, push_address;
std::string server_port, push_port, push_address;
CONFIG_CHECK(config.GetServerConfigPort(server_port));
CONFIG_CHECK(config.GetMetricConfigPort(push_port));
CONFIG_CHECK(config.GetMetricConfigAddress(push_address));
const std::string uri = std::string("/metrics");
// const std::size_t num_threads = 2;
auto labels = prometheus::Gateway::GetInstanceLabel("pushgateway");
std::string hostportstr;
char hostname[1024];
if (gethostname(hostname, sizeof(hostname)) == 0) {
hostportstr = std::string(hostname) + ":" + server_port;
} else {
hostportstr = "pushgateway";
}
auto labels = prometheus::Gateway::GetInstanceLabel(hostportstr);
// Init pushgateway
gateway_ = std::make_shared<prometheus::Gateway>(push_address, push_port, "milvus_metrics", labels);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册