Skip to content

Commit dfb74ba

Browse files
authored
NETOBSERV-2084: get nested data as native maps [backport 1.8] (#804)
* NETOBSERV-2084: get nested data as native maps * bump agent
1 parent 18a80e1 commit dfb74ba

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/mitchellh/mapstructure v1.5.0
1919
github.com/netobserv/gopipes v0.3.0
2020
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500
21-
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42
21+
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b
2222
github.com/netsampler/goflow2 v1.3.7
2323
github.com/pkg/errors v0.9.1
2424
github.com/prometheus/client_golang v1.20.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ github.com/netobserv/gopipes v0.3.0 h1:IYmPnnAVCdSK7VmHmpFhrVBOEm45qpgbZmJz1sSW+
692692
github.com/netobserv/gopipes v0.3.0/go.mod h1:N7/Gz05EOF0CQQSKWsv3eof22Cj2PB08Pbttw98YFYU=
693693
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500 h1:RmnoJe/ci5q+QdM7upFdxiU+D8F3L3qTd5wXCwwHefw=
694694
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500/go.mod h1:LHXpc5tjKvsfZn0pwLKrvlgEhZcCaw3Di9mUEZGAI4E=
695-
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42 h1:7eqxS+GU66ZvD9yO/GrPupzP2G6uENIJ7H7g808lMs8=
696-
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42/go.mod h1:MP3H40HA1Xa/lBDHHyuhohNXKenV5j2S6+wGgqqD+Qc=
695+
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b h1:qOjnvcS5SGiqiGYxM5zzRxnvthx/9Pi8vvFsqnGGXtg=
696+
github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b/go.mod h1:MP3H40HA1Xa/lBDHHyuhohNXKenV5j2S6+wGgqqD+Qc=
697697
github.com/netsampler/goflow2 v1.3.7 h1:XZaTy8kkMnGXpJ9hS3KbO1McyrFTpVNhVFEx9rNhMmc=
698698
github.com/netsampler/goflow2 v1.3.7/go.mod h1:4UZsVGVAs//iMCptUHn3WNScztJeUhZH7kDW2+/vDdQ=
699699
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

pkg/pipeline/encode/encode_prom_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,15 +675,15 @@ func Test_WithObjectListField(t *testing.T) {
675675
{
676676
"namespace": "A",
677677
"events": []any{
678-
config.GenericMap{"type": "acl", "name": "my_policy"},
678+
map[string]string{"type": "acl", "name": "my_policy"},
679679
},
680680
"bytes": 1,
681681
},
682682
{
683683
"namespace": "A",
684684
"events": []any{
685-
config.GenericMap{"type": "egress", "name": "my_egress"},
686-
config.GenericMap{"type": "acl", "name": "my_policy"},
685+
map[string]string{"type": "egress", "name": "my_egress"},
686+
map[string]string{"type": "acl", "name": "my_policy"},
687687
},
688688
"bytes": 10,
689689
},
@@ -733,8 +733,8 @@ func Test_WithObjectListField_bis(t *testing.T) {
733733
{
734734
"namespace": "A",
735735
"events": []any{
736-
config.GenericMap{"type": "egress", "name": "my_egress"},
737-
config.GenericMap{"type": "acl", "name": "my_policy"},
736+
map[string]string{"type": "egress", "name": "my_egress"},
737+
map[string]string{"type": "acl", "name": "my_policy"},
738738
},
739739
"bytes": 10,
740740
},
@@ -774,8 +774,8 @@ func Test_WithObjectListField_ter(t *testing.T) {
774774
{
775775
"namespace": "A",
776776
"events": []any{
777-
config.GenericMap{"type": "egress", "name": "my_egress"},
778-
config.GenericMap{"type": "acl", "name": "my_policy"},
777+
map[string]string{"type": "egress", "name": "my_egress"},
778+
map[string]string{"type": "acl", "name": "my_policy"},
779779
},
780780
"bytes": 10,
781781
},

pkg/pipeline/encode/metrics/flattening.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ func (p *Preprocessed) GenerateFlatParts(flow config.GenericMap) []config.Generi
2121
prefix := fl + ">"
2222
for _, vv := range v {
2323
switch vvv := vv.(type) {
24-
case config.GenericMap:
24+
case map[string]string:
2525
partsForLabel = append(partsForLabel, flattenNested(prefix, vvv))
2626
default:
2727
partsForLabel = append(partsForLabel, config.GenericMap{fl: vv})
2828
}
2929
}
30-
case []config.GenericMap:
30+
case []map[string]string:
3131
prefix := fl + ">"
3232
for _, vv := range v {
3333
partsForLabel = append(partsForLabel, flattenNested(prefix, vv))
@@ -79,7 +79,7 @@ func distribute(allUnflat [][]config.GenericMap) []config.GenericMap {
7979
return ret
8080
}
8181

82-
func flattenNested(prefix string, nested config.GenericMap) config.GenericMap {
82+
func flattenNested(prefix string, nested map[string]string) config.GenericMap {
8383
subFlow := config.GenericMap{}
8484
for k, v := range nested {
8585
subFlow[prefix+k] = v

pkg/pipeline/encode/metrics/preprocess_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ func Test_Flatten(t *testing.T) {
1414
"namespace": "A",
1515
"interfaces": []string{"eth0", "123456"},
1616
"events": []any{
17-
config.GenericMap{"type": "egress", "name": "my_egress"},
18-
config.GenericMap{"type": "acl", "name": "my_policy"},
17+
map[string]string{"type": "egress", "name": "my_egress"},
18+
map[string]string{"type": "acl", "name": "my_policy"},
1919
},
2020
"bytes": 7,
2121
})

vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow/proto.go

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ github.com/netobserv/loki-client-go/pkg/labelutil
311311
github.com/netobserv/loki-client-go/pkg/logproto
312312
github.com/netobserv/loki-client-go/pkg/metric
313313
github.com/netobserv/loki-client-go/pkg/urlutil
314-
# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250128120438-528ec8c1eb42
314+
# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250130135234-c2d377a18f1b
315315
## explicit; go 1.23.0
316316
github.com/netobserv/netobserv-ebpf-agent/pkg/decode
317317
github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf

0 commit comments

Comments
 (0)