Merge pull request #37034 from cpuguy83/moar_metrics
Add metrics for log failures/partials
This commit is contained in:
commit
ab0dccf801
2 changed files with 25 additions and 0 deletions
|
@ -81,6 +81,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
|||
read, err := src.Read(buf[n:upto])
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
logReadsFailedCount.Inc(1)
|
||||
logrus.Errorf("Error scanning log stream: %s", err)
|
||||
return
|
||||
}
|
||||
|
@ -120,6 +121,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
|||
}
|
||||
|
||||
if logErr := c.dst.Log(msg); logErr != nil {
|
||||
logWritesFailedCount.Inc(1)
|
||||
logrus.Errorf("Failed to log msg %q for logger %s: %s", msg.Line, c.dst.Name(), logErr)
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +145,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
|||
partialid = stringid.GenerateRandomID()
|
||||
ordinal = 1
|
||||
firstPartial = false
|
||||
totalPartialLogs.Inc(1)
|
||||
} else {
|
||||
msg.Timestamp = partialTS
|
||||
}
|
||||
|
@ -151,6 +154,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
|||
hasMorePartial = true
|
||||
|
||||
if logErr := c.dst.Log(msg); logErr != nil {
|
||||
logWritesFailedCount.Inc(1)
|
||||
logrus.Errorf("Failed to log msg %q for logger %s: %s", msg.Line, c.dst.Name(), logErr)
|
||||
}
|
||||
p = 0
|
||||
|
|
21
daemon/logger/metrics.go
Normal file
21
daemon/logger/metrics.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package logger // import "github.com/docker/docker/daemon/logger"
|
||||
|
||||
import (
|
||||
"github.com/docker/go-metrics"
|
||||
)
|
||||
|
||||
var (
|
||||
logWritesFailedCount metrics.Counter
|
||||
logReadsFailedCount metrics.Counter
|
||||
totalPartialLogs metrics.Counter
|
||||
)
|
||||
|
||||
func init() {
|
||||
loggerMetrics := metrics.NewNamespace("logger", "", nil)
|
||||
|
||||
logWritesFailedCount = loggerMetrics.NewCounter("log_write_operations_failed", "Number of log write operations that failed")
|
||||
logReadsFailedCount = loggerMetrics.NewCounter("log_read_operations_failed", "Number of log reads from container stdio that failed")
|
||||
totalPartialLogs = loggerMetrics.NewCounter("log_entries_size_greater_than_buffer", "Number of log entries which are larger than the log buffer")
|
||||
|
||||
metrics.Register(loggerMetrics)
|
||||
}
|
Loading…
Reference in a new issue