Update grok package to support for field names containing '-' and '.' (#8276)

This commit is contained in:
Hong 2020-12-03 02:11:35 +08:00 committed by GitHub
parent 6fcc12a9b6
commit a5f3121f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

2
go.mod
View File

@ -123,7 +123,7 @@ require (
github.com/tidwall/gjson v1.6.0
github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e // indirect
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
github.com/vjeantet/grok v1.0.0
github.com/vjeantet/grok v1.0.1-0.20180213041522-5a86c829f3c3
github.com/vmware/govmomi v0.19.0
github.com/wavefronthq/wavefront-sdk-go v0.9.2
github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf

4
go.sum
View File

@ -588,8 +588,8 @@ github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e h1:f1yevOHP+Su
github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
github.com/vjeantet/grok v1.0.0 h1:uxMqatJP6MOFXsj6C1tZBnqqAThQEeqnizUZ48gSJQQ=
github.com/vjeantet/grok v1.0.0/go.mod h1:/FWYEVYekkm+2VjcFmO9PufDU5FgXHUz9oy2EGqmQBo=
github.com/vjeantet/grok v1.0.1-0.20180213041522-5a86c829f3c3 h1:T3ATR84Xk4b9g0QbGgLJVpRYWm/jvixqLTWRsR108sI=
github.com/vjeantet/grok v1.0.1-0.20180213041522-5a86c829f3c3/go.mod h1:/FWYEVYekkm+2VjcFmO9PufDU5FgXHUz9oy2EGqmQBo=
github.com/vmware/govmomi v0.19.0 h1:CR6tEByWCPOnRoRyhLzuHaU+6o2ybF3qufNRWS/MGrY=
github.com/vmware/govmomi v0.19.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
github.com/wavefronthq/wavefront-sdk-go v0.9.2 h1:/LvWgZYNjHFUg+ZUX+qv+7e+M8sEMi0lM15zPp681Gk=

View File

@ -1115,3 +1115,22 @@ func TestTrimRegression(t *testing.T) {
)
require.Equal(t, expected, actual)
}
func TestAdvanceFieldName(t *testing.T) {
p := &Parser{
Patterns: []string{`rts=%{NUMBER:response-time.s} local=%{IP:local-ip} remote=%{IP:remote.ip}`},
}
assert.NoError(t, p.Compile())
metricA, err := p.ParseLine(`rts=1.283 local=127.0.0.1 remote=10.0.0.1`)
require.NotNil(t, metricA)
assert.NoError(t, err)
assert.Equal(t,
map[string]interface{}{
"response-time.s": "1.283",
"local-ip": "127.0.0.1",
"remote.ip": "10.0.0.1",
},
metricA.Fields())
assert.Equal(t, map[string]string{}, metricA.Tags())
}