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
9d0a8c13
Commit
9d0a8c13
authored
6 years ago
by
Steven Sheehy
Committed by
Ed
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add stream label to CRI
Signed-off-by:
Steven Sheehy
<
ssheehy@firescope.com
>
parent
f13b232d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/promtail/api/entry_parser.go
+1
-0
1 addition, 0 deletions
pkg/promtail/api/entry_parser.go
pkg/promtail/api/entry_parser_test.go
+15
-6
15 additions, 6 deletions
pkg/promtail/api/entry_parser_test.go
with
16 additions
and
6 deletions
pkg/promtail/api/entry_parser.go
+
1
−
0
View file @
9d0a8c13
...
...
@@ -79,6 +79,7 @@ func (e EntryParser) Wrap(next EntryHandler) EntryHandler {
return
fmt
.
Errorf
(
"CRI timestamp '%s' does not match RFC3339Nano"
,
parts
[
1
])
}
labels
=
labels
.
Merge
(
model
.
LabelSet
{
"stream"
:
model
.
LabelValue
(
parts
[
2
])})
return
next
.
Handle
(
labels
,
timestamp
,
parts
[
4
])
})
case
Docker
:
...
...
This diff is collapsed.
Click to expand it.
pkg/promtail/api/entry_parser_test.go
+
15
−
6
View file @
9d0a8c13
...
...
@@ -13,8 +13,13 @@ var (
)
type
Entry
struct
{
Time
time
.
Time
Log
string
Time
time
.
Time
Log
string
Labels
model
.
LabelSet
}
func
NewEntry
(
message
string
,
stream
string
)
Entry
{
return
Entry
{
TestTime
,
message
,
model
.
LabelSet
{
"stream"
:
model
.
LabelValue
(
stream
)}}
}
var
criTestCases
=
[]
struct
{
...
...
@@ -29,9 +34,9 @@ var criTestCases = []struct {
{
TestTimeStr
+
" invalid F message"
,
true
,
Entry
{}},
{
"2019-01-01 01:00:00.000000001 stdout F message"
,
true
,
Entry
{}},
{
" "
+
TestTimeStr
+
" stdout F message"
,
true
,
Entry
{}},
{
TestTimeStr
+
" stdout F message"
,
false
,
Entry
{
TestTime
,
"message"
}
},
{
TestTimeStr
+
" stderr P message"
,
false
,
Entry
{
TestTime
,
"message"
}
},
{
TestTimeStr
+
" stderr P message1
\n
message2"
,
false
,
Entry
{
TestTime
,
"message1
\n
message2"
}
},
{
TestTimeStr
+
" stdout F message"
,
false
,
New
Entry
(
"message"
,
"stdout"
)
},
{
TestTimeStr
+
" stderr P message"
,
false
,
New
Entry
(
"message"
,
"stderr"
)
},
{
TestTimeStr
+
" stderr P message1
\n
message2"
,
false
,
New
Entry
(
"message1
\n
message2"
,
"stderr"
)
},
}
func
TestCRI
(
t
*
testing
.
T
)
{
...
...
@@ -62,6 +67,10 @@ func TestCRI(t *testing.T) {
if
tc
.
Expected
.
Log
!=
entry
.
Log
{
t
.
Error
(
"For"
,
tc
.
Line
,
"expected"
,
tc
.
Expected
.
Log
,
"got"
,
entry
.
Log
)
}
if
!
tc
.
Expected
.
Labels
.
Equal
(
entry
.
Labels
)
{
t
.
Error
(
"For"
,
tc
.
Line
,
"expected"
,
tc
.
Expected
.
Labels
,
"got"
,
entry
.
Labels
)
}
}
}
}
...
...
@@ -71,6 +80,6 @@ type TestClient struct {
}
func
(
c
*
TestClient
)
Handle
(
ls
model
.
LabelSet
,
t
time
.
Time
,
s
string
)
error
{
c
.
Entries
=
append
(
c
.
Entries
,
Entry
{
t
,
s
})
c
.
Entries
=
append
(
c
.
Entries
,
Entry
{
t
,
s
,
ls
})
return
nil
}
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