Skip to content

Commit

Permalink
feat: update time field
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Nov 22, 2024
1 parent 238ce66 commit fb33b24
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
12 changes: 8 additions & 4 deletions cmd/collectors/rest/plugins/clustersoftware/clustersoftware.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (c *ClusterSoftware) createUpdateMetrics() error {
instanceKeys.NewChildS("", "phase")
instanceKeys.NewChildS("", "state")
instanceKeys.NewChildS("", "node")
instanceKeys.NewChildS("", "elapsed_duration")

mat.SetExportOptions(exportOptions)

Expand Down Expand Up @@ -147,6 +148,7 @@ func (c *ClusterSoftware) handleUpdateDetails(updateDetailsJSON gjson.Result, gl
for _, updateDetail := range updateDetailsJSON.Array() {
phase := updateDetail.Get("phase").ClonedString()
state := updateDetail.Get("state").ClonedString()
elapsedDuration := updateDetail.Get("elapsed_duration").ClonedString()
nodeName := updateDetail.Get("node.name").ClonedString()
key = phase + state + nodeName

Expand All @@ -157,6 +159,7 @@ func (c *ClusterSoftware) handleUpdateDetails(updateDetailsJSON gjson.Result, gl
clusterUpdateInstance.SetLabel("node", nodeName)
clusterUpdateInstance.SetLabel("state", state)
clusterUpdateInstance.SetLabel("phase", phase)
clusterUpdateInstance.SetLabel("elapsed_duration", elapsedDuration)

// populate numeric data
value := 0.0
Expand Down Expand Up @@ -240,12 +243,13 @@ func (c *ClusterSoftware) handleValidationDetails(validationDetailsJSON gjson.Re
clusterValidationInstance.SetLabel("update_check", updateCheck)
clusterValidationInstance.SetLabel("status", status)

// populate numeric data
value := 0.0
if status == "warning" {
value = 1.0
// ignore all the validation result which are not in warning status
if status != "warning" {
continue
}

// populate numeric data
value := 1.0
met := c.data[validationMatrix].GetMetric(validationMatrix)
if err := met.SetValueFloat64(clusterValidationInstance, value); err != nil {
c.SLogger.Error("Failed to parse value", slogx.Err(err), slog.Float64("value", value))
Expand Down
25 changes: 20 additions & 5 deletions grafana/dashboards/cmode/cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -4506,6 +4506,18 @@
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "Approximate time elapsed"
},
"properties": [
{
"id": "unit",
"value": "s"
}
]
}
]
},
Expand Down Expand Up @@ -4552,7 +4564,8 @@
"cluster",
"phase",
"node",
"datacenter"
"datacenter",
"elapsed_duration"
]
}
}
Expand All @@ -4564,13 +4577,15 @@
"indexByName": {
"cluster": 1,
"datacenter": 0,
"elapsed_duration": 5,
"node": 2,
"phase": 3,
"state": 4
},
"renameByName": {
"phase": "Update Phase",
"state": "State"
"elapsed_duration": "Approximate time elapsed",
"phase": "Phase",
"state": "Status"
}
}
}
Expand Down Expand Up @@ -4734,7 +4749,7 @@
},
"renameByName": {
"name": "Job Name",
"state": "State"
"state": "Status"
}
}
}
Expand Down Expand Up @@ -4874,7 +4889,7 @@
},
"renameByName": {
"status": "Status",
"update_check": "Validation Check Name"
"update_check": "Pre-update Check"
}
}
}
Expand Down

0 comments on commit fb33b24

Please sign in to comment.