Skip to content

Commit

Permalink
feat: 采集器 corefile 采集正则过滤问题修复 --story=117576710 (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx authored May 21, 2024
1 parent 5b8efe0 commit d97bf62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/bkmonitorbeat/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.34.x
v3.35.x
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func (c *CoreFileCollector) fillDimension(filePath string) (beat.MapStr, bool) {
m, ok := c.fillDimensionV0(filePath)
// 正则匹配模式下,不需要关心是否 dimensions 能否匹配到
if c.matchRegx != nil {
matched := c.matchRegx.MatchString(filePath)
matched := c.matchRegx.MatchString(filepath.Base(filePath))
return m, matched
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func TestCoreFileCollector_fillDimension(t *testing.T) {
want1: true,
},
{
name: "正则过滤(failed)",
name: "正则过滤(failed) - 1",
fields: fields{
pattern: "core_%t_%e_%s",
isUsesPid: false,
Expand All @@ -450,6 +450,19 @@ func TestCoreFileCollector_fillDimension(t *testing.T) {
want: beat.MapStr{},
want1: false,
},
{
name: "正则过滤(failed) - 2",
fields: fields{
pattern: "core_%e_%t",
isUsesPid: false,
},
args: args{
filePath: "/data/corefile/alarms.txt",
},
reg: regexp.MustCompile("core_*"),
want: beat.MapStr{},
want1: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit d97bf62

Please sign in to comment.