Skip to content

Commit

Permalink
Add uptime value to metric reporting
Browse files Browse the repository at this point in the history
This metric can be useful in combination with elastic#2456 to track how long the harvesting of a file took. Uptime is reported before shutdown.
  • Loading branch information
ruflin committed Sep 5, 2016
1 parent 95df88a commit 3fba39a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions libbeat/logp/logp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ import (
"github.com/elastic/beats/libbeat/paths"
)

// cmd line flags
var verbose *bool
var toStderr *bool
var debugSelectorsStr *string
var (
// cmd line flags
verbose *bool
toStderr *bool
debugSelectorsStr *string

// Beat start time
startTime time.Time
)

func init() {
startTime = time.Now()
}

type Logging struct {
Selectors []string
Expand Down Expand Up @@ -234,4 +243,5 @@ func LogTotalExpvars(cfg *Logging) {
snapshotExpvars(vals)
metrics := buildMetricsOutput(prevVals, vals)
Info("Total non-zero values: %s", metrics)
Info("Uptime: %s", time.Now().Sub(startTime))
}

0 comments on commit 3fba39a

Please sign in to comment.