Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 pkg/handler/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func expandQueries(queries filters.MultiQueries, namespace string, isForProm fun
}
q2 := filters.SingleQuery{
filters.NewMatch(fields.FlowDirection, `"`+string(constants.Egress)+`"`),
filters.NewMatch(fields.DstOwnerName, `""`),
filters.NewMatch(fields.DstOwnerType, `"","Service"`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact we could use:

Suggested change
filters.NewMatch(fields.DstOwnerType, `"","Service"`),
filters.NewMatch(fields.DstType, `"","Service"`),

.. it works the same, but with the advantage to not have to add another index (it's already indexed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we go
609a606

}

shouldSkip := func(q filters.SingleQuery) bool {
Expand Down
10 changes: 5 additions & 5 deletions pkg/handler/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestSplitForReportersMerge(t *testing.T) {
}, res[0])
assert.Equal(t, filters.SingleQuery{
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
filters.NewMatch("DstK8S_OwnerName", `""`),
filters.NewMatch("DstK8S_OwnerType", `"","Service"`),
filters.NewMatch("srcns", "a"),
filters.NewMatch("dstns", "b"),
}, res[1])
Expand Down Expand Up @@ -73,14 +73,14 @@ func TestExpand_ComplexQuery(t *testing.T) {
assert.Equal(t, filters.SingleQuery{
filters.NewMatch("SrcK8S_Namespace", `"my-namespace"`),
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
filters.NewMatch("DstK8S_OwnerName", `""`),
filters.NewMatch("DstK8S_OwnerType", `"","Service"`),
filters.NewMatch("key1", "a"),
filters.NewMatch("key2", "b"),
}, res[4])
assert.Equal(t, filters.SingleQuery{
filters.NewMatch("DstK8S_Namespace", `"my-namespace"`),
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
filters.NewMatch("DstK8S_OwnerName", `""`),
filters.NewMatch("DstK8S_OwnerType", `"","Service"`),
filters.NewMatch("key1", "a"),
filters.NewMatch("key2", "b"),
}, res[5])
Expand All @@ -104,14 +104,14 @@ func TestExpand_ComplexQuery(t *testing.T) {
assert.Equal(t, filters.SingleQuery{
filters.NewMatch("SrcK8S_Namespace", `"my-namespace"`),
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
filters.NewMatch("DstK8S_OwnerName", `""`),
filters.NewMatch("DstK8S_OwnerType", `"","Service"`),
filters.NewMatch("key1", "c"),
filters.NewMatch("key2", "d"),
}, res[9])
assert.Equal(t, filters.SingleQuery{
filters.NewMatch("DstK8S_Namespace", `"my-namespace"`),
filters.NewMatch("FlowDirection", `"`+string(constants.Egress)+`"`),
filters.NewMatch("DstK8S_OwnerName", `""`),
filters.NewMatch("DstK8S_OwnerType", `"","Service"`),
filters.NewMatch("key1", "c"),
filters.NewMatch("key2", "d"),
}, res[10])
Expand Down
6 changes: 3 additions & 3 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func TestLokiConfigurationForTopology(t *testing.T) {
Loki: config.Loki{
URL: lokiSvc.URL,
Timeout: config.Duration{Duration: time.Second},
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.FlowDirection},
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.SrcOwnerType, fields.DstOwnerType, fields.FlowDirection},
},
Frontend: config.Frontend{Deduper: config.Deduper{
Mark: true,
Expand All @@ -361,7 +361,7 @@ func TestLokiConfigurationForTopology(t *testing.T) {
queries := []string{req1.URL.Query().Get("query"), req2.URL.Query().Get("query")}
expected := []string{
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection=~"^0$|^2$"}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection="1",DstK8S_OwnerName=""}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
`topk(100,sum by(SrcK8S_Name,SrcK8S_Type,SrcK8S_OwnerName,SrcK8S_OwnerType,SrcK8S_Namespace,SrcAddr,SrcK8S_HostName,DstK8S_Name,DstK8S_Type,DstK8S_OwnerName,DstK8S_OwnerType,DstK8S_Namespace,DstAddr,DstK8S_HostName)(rate({app="netobserv-flowcollector",FlowDirection="1",DstK8S_OwnerType=~"^$|^Service$"}!~` + "`" + `Duplicate":true` + "`" + `|json|unwrap Bytes|__error__=""[1m])))`,
}
// We don't predict the order so sort both actual and expected
sort.Strings(queries)
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestLokiConfigurationForTableHistogram(t *testing.T) {
Loki: config.Loki{
URL: lokiSvc.URL,
Timeout: config.Duration{Duration: time.Second},
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.FlowDirection},
Labels: []string{fields.SrcNamespace, fields.DstNamespace, fields.SrcOwnerName, fields.DstOwnerName, fields.SrcOwnerType, fields.DstOwnerType, fields.FlowDirection},
},
Frontend: config.Frontend{Deduper: config.Deduper{
Mark: true,
Expand Down
Loading