Skip to content

Commit

Permalink
More verbose error logs for collecting monitoring metrics (elastic#6429)
Browse files Browse the repository at this point in the history
* libbeat: more info error messages && fixes
* libbeat: add variable of failing conversion to message
  • Loading branch information
kvch authored and ph committed Feb 21, 2018
1 parent 4b83474 commit baa740d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libbeat/cmd/instance/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func getRSSSize() (uint64, error) {
beatPID := os.Getpid()
state, err := beatProcessStats.GetOne(beatPID)
if err != nil {
return 0, fmt.Errorf("error retrieving process stats")
return 0, fmt.Errorf("error retrieving process stats: %v", err)
}

iRss, err := state.GetValue("memory.rss.bytes")
Expand All @@ -86,7 +86,7 @@ func getRSSSize() (uint64, error) {

rss, ok := iRss.(uint64)
if !ok {
return 0, fmt.Errorf("error converting Resident Set Size: %v", err)
return 0, fmt.Errorf("error converting Resident Set Size to uint64: %v", iRss)
}
return rss, nil
}
Expand Down Expand Up @@ -139,7 +139,7 @@ func getCPUUsage() (float64, *process.Ticks, error) {
beatPID := os.Getpid()
state, err := beatProcessStats.GetOne(beatPID)
if err != nil {
return 0.0, nil, fmt.Errorf("error retrieving process stats")
return 0.0, nil, fmt.Errorf("error retrieving process stats: %v", err)
}

iTotalCPUUsage, err := state.GetValue("cpu.total.value")
Expand All @@ -149,7 +149,7 @@ func getCPUUsage() (float64, *process.Ticks, error) {

totalCPUUsage, ok := iTotalCPUUsage.(float64)
if !ok {
return 0.0, nil, fmt.Errorf("error converting value of CPU usage since start")
return 0.0, nil, fmt.Errorf("error converting value of CPU usage since start to float64: %v", iTotalCPUUsage)
}

iTotalCPUUserTicks, err := state.GetValue("cpu.user.ticks")
Expand All @@ -159,7 +159,7 @@ func getCPUUsage() (float64, *process.Ticks, error) {

totalCPUUserTicks, ok := iTotalCPUUserTicks.(uint64)
if !ok {
return 0.0, nil, fmt.Errorf("error converting value of user CPU ticks since start")
return 0.0, nil, fmt.Errorf("error converting value of user CPU ticks since start to uint64: %v", iTotalCPUUserTicks)
}

iTotalCPUSystemTicks, err := state.GetValue("cpu.system.ticks")
Expand All @@ -169,7 +169,7 @@ func getCPUUsage() (float64, *process.Ticks, error) {

totalCPUSystemTicks, ok := iTotalCPUSystemTicks.(uint64)
if !ok {
return 0.0, nil, fmt.Errorf("error converting value of system CPU ticks since start")
return 0.0, nil, fmt.Errorf("error converting value of system CPU ticks since start to uint64: %v", iTotalCPUSystemTicks)
}

iTotalCPUTicks, err := state.GetValue("cpu.total.ticks")
Expand All @@ -179,7 +179,7 @@ func getCPUUsage() (float64, *process.Ticks, error) {

totalCPUTicks, ok := iTotalCPUTicks.(uint64)
if !ok {
return 0.0, nil, fmt.Errorf("error converting total value of CPU ticks since start")
return 0.0, nil, fmt.Errorf("error converting total value of CPU ticks since start to uint64: %v", iTotalCPUTicks)
}

p := process.Ticks{
Expand Down

0 comments on commit baa740d

Please sign in to comment.