Skip to content

Commit

Permalink
parse string metrics to float to display on grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
jsousa02 committed May 27, 2024
1 parent b12baf0 commit 5bd7064
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions proj/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func main() {

// Add timestamp
data["timestamp"] = time.Now().Format(time.RFC3339)
data["CPUUsage"], _ = strconv.ParseFloat(stat.CPUUsage[:len(stat.CPUUsage) - 1], 32)
data["MemoryUsage"], _ = strconv.ParseFloat(stat.MemoryUsage[:len(stat.MemoryUsage) - 1], 32)

// Marshal back to JSON
updatedOutput, err := json.MarshalIndent(data, "", " ")
Expand Down

0 comments on commit 5bd7064

Please sign in to comment.