This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new eb086d9 [metrics] KUDU-3269: Add UUID and hostname of the server into
the metrics output
eb086d9 is described below
commit eb086d9af32dd4d5b593111618467ac7a06cfe91
Author: Abhishek Chennaka <[email protected]>
AuthorDate: Mon Jun 14 11:22:34 2021 -0400
[metrics] KUDU-3269: Add UUID and hostname of the server into the metrics
output
This patch adds the UUID and the server hostname into the metrics
webpage of master and tablet server. These are added in the attributes
section of the metrics webpage. For example:
"type": "server",
"id": "kudu.master",
"attributes": {
"hostname": "MacBook-Pro.local",
"uuid": "4b8015e347dd4efd92bb0d38e03434e6"
},
Change-Id: I7d6d1e96f8067a7b1593da4f9d0e1931d3001016
Reviewed-on: http://gerrit.cloudera.org:8080/17607
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Alexey Serbin <[email protected]>
---
src/kudu/master/master-test.cc | 14 ++++++++++++++
src/kudu/server/server_base.cc | 7 +++++++
src/kudu/tserver/tablet_server-test.cc | 14 ++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/src/kudu/master/master-test.cc b/src/kudu/master/master-test.cc
index b7076e3..c644e4d 100644
--- a/src/kudu/master/master-test.cc
+++ b/src/kudu/master/master-test.cc
@@ -1383,6 +1383,20 @@ TEST_P(ConcurrentGetTableSchemaTest, Rpc) {
total / kRunInterval.ToSeconds(), supports_authz_ ? "enabled" :
"disabled");
}
+// Validate the hostname and the UUID of the server from the metrics webpage
+TEST_F(MasterTest, ServerAttributes) {
+ EasyCurl c;
+ faststring buf;
+ ASSERT_OK(c.FetchURL(Substitute("http://$0/metrics?ids=kudu.master",
+ mini_master_->bound_http_addr().ToString()),
+ &buf));
+ string raw = buf.ToString();
+ string server_hostname;
+ ASSERT_STR_CONTAINS(raw, "\"uuid\": \"" + mini_master_->permanent_uuid() +
"\"");
+ ASSERT_OK(GetFQDN(&server_hostname));
+ ASSERT_STR_CONTAINS(raw, "\"hostname\": \"" + server_hostname + "\"");
+}
+
// Run multiple threads calling GetTableSchema() directly to system catalog.
TEST_P(ConcurrentGetTableSchemaTest, DirectMethodCall) {
SKIP_IF_SLOW_NOT_ALLOWED();
diff --git a/src/kudu/server/server_base.cc b/src/kudu/server/server_base.cc
index 808faaf..0cba6fc 100644
--- a/src/kudu/server/server_base.cc
+++ b/src/kudu/server/server_base.cc
@@ -848,6 +848,13 @@ std::string ServerBase::FooterHtml() const {
Status ServerBase::Start() {
GenerateInstanceID();
+ metric_entity_->SetAttribute("uuid", fs_manager_->uuid());
+ // Get the FQDN. If that fails server_hostname will have either the local
hostname
+ // (if GetHostname() succeeds) or still be empty (if GetHostname() fails)
+ string server_hostname = "";
+ WARN_NOT_OK(GetFQDN(&server_hostname), "could not determine host FQDN");
+ metric_entity_->SetAttribute("hostname", server_hostname);
+
RETURN_NOT_OK(RegisterService(
unique_ptr<rpc::ServiceIf>(new GenericServiceImpl(this))));
diff --git a/src/kudu/tserver/tablet_server-test.cc
b/src/kudu/tserver/tablet_server-test.cc
index 3a9e360..ffd3849 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -3815,6 +3815,20 @@ TEST_F(TabletServerTest, TestConcurrentDeleteTablet) {
ASSERT_EQ(1, num_success);
}
+// Validate the hostname and the UUID of the server from the metrics webpage
+TEST_F(TabletServerTest, ServerAttributes) {
+ EasyCurl c;
+ faststring buf;
+ ASSERT_OK(c.FetchURL(Substitute("http://$0/metrics?ids=kudu.tabletserver",
+ mini_server_->bound_http_addr().ToString()),
+ &buf));
+ string raw = buf.ToString();
+ string server_hostname;
+ ASSERT_STR_CONTAINS(raw, "\"uuid\": \"" + mini_server_->uuid() + "\"");
+ ASSERT_OK(GetFQDN(&server_hostname));
+ ASSERT_STR_CONTAINS(raw, "\"hostname\": \"" + server_hostname + "\"");
+}
+
TEST_F(TabletServerTest, TestInsertLatencyMicroBenchmark) {
METRIC_DEFINE_entity(test);
METRIC_DEFINE_histogram(test, insert_latency,