From d97bf62654cbeb445d83c7cad159767100e67778 Mon Sep 17 00:00:00 2001 From: dongdong Date: Tue, 21 May 2024 19:49:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=87=E9=9B=86=E5=99=A8=20corefile?= =?UTF-8?q?=20=E9=87=87=E9=9B=86=E6=AD=A3=E5=88=99=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=20--story=3D117576710=20(#?= =?UTF-8?q?348)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/bkmonitorbeat/VERSION | 2 +- .../collector/corefile/utils_unix.go | 2 +- .../collector/corefile/utils_unix_test.go | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/bkmonitorbeat/VERSION b/pkg/bkmonitorbeat/VERSION index 71f993d25..84dcc6711 100644 --- a/pkg/bkmonitorbeat/VERSION +++ b/pkg/bkmonitorbeat/VERSION @@ -1 +1 @@ -v3.34.x +v3.35.x diff --git a/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix.go b/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix.go index e58d9a8ca..43f385dab 100644 --- a/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix.go +++ b/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix.go @@ -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 } diff --git a/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix_test.go b/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix_test.go index 561af9e56..d62bb5def 100644 --- a/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix_test.go +++ b/pkg/bkmonitorbeat/tasks/exceptionbeat/collector/corefile/utils_unix_test.go @@ -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, @@ -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) {