Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Loki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Loki
Commits
904c1903
Commit
904c1903
authored
6 years ago
by
Ye Ben
Committed by
Tom Wilkie
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add readLines metric (#214)
parent
ee8c0a80
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/promtail/promtail-docker-config.yaml
+1
-1
1 addition, 1 deletion
cmd/promtail/promtail-docker-config.yaml
cmd/promtail/promtail-local-config.yaml
+1
-1
1 addition, 1 deletion
cmd/promtail/promtail-local-config.yaml
pkg/promtail/target.go
+8
-0
8 additions, 0 deletions
pkg/promtail/target.go
with
10 additions
and
2 deletions
cmd/promtail/promtail-docker-config.yaml
+
1
−
1
View file @
904c1903
server
:
http_listen_port
:
0
http_listen_port
:
908
0
grpc_listen_port
:
0
positions
:
...
...
This diff is collapsed.
Click to expand it.
cmd/promtail/promtail-local-config.yaml
+
1
−
1
View file @
904c1903
server
:
http_listen_port
:
0
http_listen_port
:
908
0
grpc_listen_port
:
0
positions
:
...
...
This diff is collapsed.
Click to expand it.
pkg/promtail/target.go
+
8
−
0
View file @
904c1903
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment