Add path tag to logparser containing path of logfile (#3098)

This commit is contained in:
Daniel Nelson
2017-08-07 16:16:31 -07:00
committed by GitHub
parent 1fb5373962
commit 3e27134872
2 changed files with 35 additions and 13 deletions

View File

@@ -69,7 +69,10 @@ func TestGrokParseLogFiles(t *testing.T) {
"response_time": int64(5432),
"myint": int64(101),
},
map[string]string{"response_code": "200"})
map[string]string{
"response_code": "200",
"path": thisdir + "grok/testdata/test_a.log",
})
acc.AssertContainsTaggedFields(t, "logparser_grok",
map[string]interface{}{
@@ -77,7 +80,9 @@ func TestGrokParseLogFiles(t *testing.T) {
"mystring": "mystring",
"nomodifier": "nomodifier",
},
map[string]string{})
map[string]string{
"path": thisdir + "grok/testdata/test_b.log",
})
}
func TestGrokParseLogFilesAppearLater(t *testing.T) {
@@ -115,7 +120,10 @@ func TestGrokParseLogFilesAppearLater(t *testing.T) {
"response_time": int64(5432),
"myint": int64(101),
},
map[string]string{"response_code": "200"})
map[string]string{
"response_code": "200",
"path": emptydir + "/test_a.log",
})
}
// Test that test_a.log line gets parsed even though we don't have the correct
@@ -148,7 +156,10 @@ func TestGrokParseLogFilesOneBad(t *testing.T) {
"response_time": int64(5432),
"myint": int64(101),
},
map[string]string{"response_code": "200"})
map[string]string{
"response_code": "200",
"path": thisdir + "grok/testdata/test_a.log",
})
}
func getCurrentDir() string {