Skip to content

Commit

Permalink
[BACKPORT 2.21.1][#22532] yugabyted-ui: Fix yugabyted UI Metrics is n…
Browse files Browse the repository at this point in the history
…ot getting displayed with k8s operator deployed clusters

Summary:
Original commit: 267720a / D35322
Currently, the yugabyted UI is not displaying the metrics when deployed using the Kubernetes OSS operator.
This is because yugabyted API server gets the uuid of a node using the GetHostToUuidMap method which calls the 7000/tablet-servers endpoint and parses the HTML.
In the Kubernetes environment, the operator sets leader preferences, which adds some text to the page and breaks the HTML parsing.

This fix modifies the HTML parsing to account for this.

Test Plan: no test plan

Reviewers: nikhil

Reviewed By: nikhil

Subscribers: djiang, yugabyted-dev

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D35368
  • Loading branch information
Daniel Jiang authored and svarnau committed Jun 4, 2024
1 parent 19afe06 commit d65732c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,11 @@ func (c *Container) getRawMetricsForAllNodes(
var ts int64
var value int
var details string
c.logger.Infof("Getting metrics for nodes: %v", nodeList)
for _, hostName := range nodeList {
query := fmt.Sprintf(QUERY_FORMAT_NODE, "system.metrics", metricColumnValue,
hostToUuid[hostName], startTime*1000, endTime*1000)
c.logger.Infof("Metrics query for node %s: %s", hostName, query)
iter := session.Query(query).Iter()
values := [][]float64{}
for iter.Scan(&ts, &value, &details) {
Expand Down Expand Up @@ -463,6 +465,7 @@ func (c *Container) GetClusterMetric(ctx echo.Context) error {
return ctx.String(http.StatusInternalServerError, err.Error())
}
}
c.logger.Infof("Getting metrics for nodes: %v", nodeList)
hostToUuid, err := c.helper.GetHostToUuidMap(helpers.HOST)
if err != nil {
c.logger.Errorf("[GetHostToUuidMap]: %s", err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (h *HelperContainer) GetHostToUuidMap(nodeHost string) (map[string]string,
// Now we parse the html to get the hostnames and uuids
// This regex will not work if the layout of the page changes. In the future, it would be
// better if this information can be found in a json endpoint.
regex, err := regexp.Compile(`<\/tr>\s*<tr>\s*<td><a href=.*?>(.*?)<\/a><\/br>\s*(.*?)<\/td>`)
regex, err := regexp.Compile(`<\/tr>\s*<tr>\s*<td><a href=.*?>(.*?)<\/a><\/br>\s*(.*?)<\/`)
if err != nil {
return hostToUuidMap, err
}
Expand Down

0 comments on commit d65732c

Please sign in to comment.