Skip to content
Snippets Groups Projects
Commit 904c1903 authored by Ye Ben's avatar Ye Ben Committed by Tom Wilkie
Browse files

add readLines metric (#214)

parent ee8c0a80
No related branches found
No related tags found
No related merge requests found
server:
http_listen_port: 0
http_listen_port: 9080
grpc_listen_port: 0
positions:
......
server:
http_listen_port: 0
http_listen_port: 9080
grpc_listen_port: 0
positions:
......
......@@ -22,6 +22,12 @@ var (
Name: "read_bytes_total",
Help: "Number of bytes read.",
}, []string{"path"})
readLines = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "promtail",
Name: "read_lines_total",
Help: "Number of lines read.",
}, []string{"path"})
)
const (
......@@ -30,6 +36,7 @@ const (
func init() {
prometheus.MustRegister(readBytes)
prometheus.MustRegister(readLines)
}
// Target describes a particular set of logs.
......@@ -204,6 +211,7 @@ func (t *tailer) run() {
level.Error(t.logger).Log("msg", "error reading line", "error", line.Err)
}
readLines.WithLabelValues(t.path).Inc()
readBytes.WithLabelValues(t.path).Add(float64(len(line.Text)))
if err := t.handler.Handle(model.LabelSet{}, line.Time, line.Text); err != nil {
level.Error(t.logger).Log("msg", "error handling line", "error", 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