Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -81,6 +81,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
| 81 | 81 |
read, err := src.Read(buf[n:upto]) |
| 82 | 82 |
if err != nil {
|
| 83 | 83 |
if err != io.EOF {
|
| 84 |
+ logReadsFailedCount.Inc(1) |
|
| 84 | 85 |
logrus.Errorf("Error scanning log stream: %s", err)
|
| 85 | 86 |
return |
| 86 | 87 |
} |
| ... | ... |
@@ -120,6 +121,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 | 122 |
if logErr := c.dst.Log(msg); logErr != nil {
|
| 123 |
+ logWritesFailedCount.Inc(1) |
|
| 123 | 124 |
logrus.Errorf("Failed to log msg %q for logger %s: %s", msg.Line, c.dst.Name(), logErr)
|
| 124 | 125 |
} |
| 125 | 126 |
} |
| ... | ... |
@@ -143,6 +145,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
| 143 | 143 |
partialid = stringid.GenerateRandomID() |
| 144 | 144 |
ordinal = 1 |
| 145 | 145 |
firstPartial = false |
| 146 |
+ totalPartialLogs.Inc(1) |
|
| 146 | 147 |
} else {
|
| 147 | 148 |
msg.Timestamp = partialTS |
| 148 | 149 |
} |
| ... | ... |
@@ -151,6 +154,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
|
| 151 | 151 |
hasMorePartial = true |
| 152 | 152 |
|
| 153 | 153 |
if logErr := c.dst.Log(msg); logErr != nil {
|
| 154 |
+ logWritesFailedCount.Inc(1) |
|
| 154 | 155 |
logrus.Errorf("Failed to log msg %q for logger %s: %s", msg.Line, c.dst.Name(), logErr)
|
| 155 | 156 |
} |
| 156 | 157 |
p = 0 |
| 157 | 158 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+package logger // import "github.com/docker/docker/daemon/logger" |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "github.com/docker/go-metrics" |
|
| 4 |
+) |
|
| 5 |
+ |
|
| 6 |
+var ( |
|
| 7 |
+ logWritesFailedCount metrics.Counter |
|
| 8 |
+ logReadsFailedCount metrics.Counter |
|
| 9 |
+ totalPartialLogs metrics.Counter |
|
| 10 |
+) |
|
| 11 |
+ |
|
| 12 |
+func init() {
|
|
| 13 |
+ loggerMetrics := metrics.NewNamespace("logger", "", nil)
|
|
| 14 |
+ |
|
| 15 |
+ logWritesFailedCount = loggerMetrics.NewCounter("log_write_operations_failed", "Number of log write operations that failed")
|
|
| 16 |
+ logReadsFailedCount = loggerMetrics.NewCounter("log_read_operations_failed", "Number of log reads from container stdio that failed")
|
|
| 17 |
+ totalPartialLogs = loggerMetrics.NewCounter("log_entries_size_greater_than_buffer", "Number of log entries which are larger than the log buffer")
|
|
| 18 |
+ |
|
| 19 |
+ metrics.Register(loggerMetrics) |
|
| 20 |
+} |