Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-2084: get nested data as native maps [backport 1.8] #804

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/netobserv/gopipes v0.3.0
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b
github.com/netsampler/goflow2 v1.3.7
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ github.com/netobserv/gopipes v0.3.0 h1:IYmPnnAVCdSK7VmHmpFhrVBOEm45qpgbZmJz1sSW+
github.com/netobserv/gopipes v0.3.0/go.mod h1:N7/Gz05EOF0CQQSKWsv3eof22Cj2PB08Pbttw98YFYU=
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500 h1:RmnoJe/ci5q+QdM7upFdxiU+D8F3L3qTd5wXCwwHefw=
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500/go.mod h1:LHXpc5tjKvsfZn0pwLKrvlgEhZcCaw3Di9mUEZGAI4E=
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42 h1:7eqxS+GU66ZvD9yO/GrPupzP2G6uENIJ7H7g808lMs8=
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42/go.mod h1:MP3H40HA1Xa/lBDHHyuhohNXKenV5j2S6+wGgqqD+Qc=
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b h1:qOjnvcS5SGiqiGYxM5zzRxnvthx/9Pi8vvFsqnGGXtg=
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b/go.mod h1:MP3H40HA1Xa/lBDHHyuhohNXKenV5j2S6+wGgqqD+Qc=
github.com/netsampler/goflow2 v1.3.7 h1:XZaTy8kkMnGXpJ9hS3KbO1McyrFTpVNhVFEx9rNhMmc=
github.com/netsampler/goflow2 v1.3.7/go.mod h1:4UZsVGVAs//iMCptUHn3WNScztJeUhZH7kDW2+/vDdQ=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
14 changes: 7 additions & 7 deletions pkg/pipeline/encode/encode_prom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,15 @@ func Test_WithObjectListField(t *testing.T) {
{
"namespace": "A",
"events": []any{
config.GenericMap{"type": "acl", "name": "my_policy"},
map[string]string{"type": "acl", "name": "my_policy"},
},
"bytes": 1,
},
{
"namespace": "A",
"events": []any{
config.GenericMap{"type": "egress", "name": "my_egress"},
config.GenericMap{"type": "acl", "name": "my_policy"},
map[string]string{"type": "egress", "name": "my_egress"},
map[string]string{"type": "acl", "name": "my_policy"},
},
"bytes": 10,
},
Expand Down Expand Up @@ -733,8 +733,8 @@ func Test_WithObjectListField_bis(t *testing.T) {
{
"namespace": "A",
"events": []any{
config.GenericMap{"type": "egress", "name": "my_egress"},
config.GenericMap{"type": "acl", "name": "my_policy"},
map[string]string{"type": "egress", "name": "my_egress"},
map[string]string{"type": "acl", "name": "my_policy"},
},
"bytes": 10,
},
Expand Down Expand Up @@ -774,8 +774,8 @@ func Test_WithObjectListField_ter(t *testing.T) {
{
"namespace": "A",
"events": []any{
config.GenericMap{"type": "egress", "name": "my_egress"},
config.GenericMap{"type": "acl", "name": "my_policy"},
map[string]string{"type": "egress", "name": "my_egress"},
map[string]string{"type": "acl", "name": "my_policy"},
},
"bytes": 10,
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipeline/encode/metrics/flattening.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func (p *Preprocessed) GenerateFlatParts(flow config.GenericMap) []config.Generi
prefix := fl + ">"
for _, vv := range v {
switch vvv := vv.(type) {
case config.GenericMap:
case map[string]string:
partsForLabel = append(partsForLabel, flattenNested(prefix, vvv))
default:
partsForLabel = append(partsForLabel, config.GenericMap{fl: vv})
}
}
case []config.GenericMap:
case []map[string]string:
prefix := fl + ">"
for _, vv := range v {
partsForLabel = append(partsForLabel, flattenNested(prefix, vv))
Expand Down Expand Up @@ -79,7 +79,7 @@ func distribute(allUnflat [][]config.GenericMap) []config.GenericMap {
return ret
}

func flattenNested(prefix string, nested config.GenericMap) config.GenericMap {
func flattenNested(prefix string, nested map[string]string) config.GenericMap {
subFlow := config.GenericMap{}
for k, v := range nested {
subFlow[prefix+k] = v
Expand Down
4 changes: 2 additions & 2 deletions pkg/pipeline/encode/metrics/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func Test_Flatten(t *testing.T) {
"namespace": "A",
"interfaces": []string{"eth0", "123456"},
"events": []any{
config.GenericMap{"type": "egress", "name": "my_egress"},
config.GenericMap{"type": "acl", "name": "my_policy"},
map[string]string{"type": "egress", "name": "my_egress"},
map[string]string{"type": "acl", "name": "my_policy"},
},
"bytes": 7,
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ github.com/netobserv/loki-client-go/pkg/labelutil
github.com/netobserv/loki-client-go/pkg/logproto
github.com/netobserv/loki-client-go/pkg/metric
github.com/netobserv/loki-client-go/pkg/urlutil
# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42
# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b
## explicit; go 1.23.0
github.com/netobserv/netobserv-ebpf-agent/pkg/decode
github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf
Expand Down