Skip to content
Snippets Groups Projects
Commit 6f883b33 authored by Tom Wilkie's avatar Tom Wilkie
Browse files

Add metric for number of bytes read from each log.


Signed-off-by: default avatarTom Wilkie <tom.wilkie@gmail.com>
parent 6b837173
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,24 @@ import (
"time"
"github.com/hpcloud/tail"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
log "github.com/sirupsen/logrus"
fsnotify "gopkg.in/fsnotify.v1"
)
var (
readBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "promtail",
Name: "read_bytes_total",
Help: "Number of bytes read.",
}, []string{})
)
func init() {
prometheus.MustRegister(readBytes)
}
type Target struct {
labels model.LabelSet
client *Client
......@@ -191,6 +204,7 @@ func (t *tailer) run() {
log.Errorf("error reading line: %v", line.Err)
}
readBytes.WithLabelValues(t.path).Add(float64(len(line.Text)))
if err := t.target.handleLine(line.Time, line.Text); err != nil {
log.Infof("error handling line: %v", err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment