Skip to content

Commit

Permalink
fix statsMatcher's regex which didn't match route's stat_prefix (#51640)
Browse files Browse the repository at this point in the history
* fix statsMatcher's regex which didn't match route's stat_prefix

Fix #51639
Signed-off-by: spacewander <[email protected]>

* u

Signed-off-by: spacewander <[email protected]>

* apply

Signed-off-by: spacewander <[email protected]>

---------

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Jun 20, 2024
1 parent 2e7743b commit 70f049e
Show file tree
Hide file tree
Showing 25 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/bootstrap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const (
requiredEnvoyStatsMatcherInclusionSuffixes = rbacEnvoyStatsMatcherInclusionSuffix + ",downstream_cx_active" // Needed for draining.

// required for metrics based on stat_prefix in virtual service.
requiredEnvoyStatsMatcherInclusionRegexes = `vhost\.*\.route\.*`
requiredEnvoyStatsMatcherInclusionRegexes = `vhost\..*\.route\..*`

// Prefixes of V2 metrics.
// "reporter" prefix is for istio standard metrics.
Expand Down
8 changes: 8 additions & 0 deletions pkg/bootstrap/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/json"
"os"
"reflect"
"regexp"
"testing"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -319,3 +320,10 @@ func TestGetStatOptions(t *testing.T) {
})
}
}

func TestRequiredEnvoyStatsMatcherInclusionRegexes(t *testing.T) {
ok, _ := regexp.MatchString(requiredEnvoyStatsMatcherInclusionRegexes, "vhost.default.local:18000.route.routev1.upstream_rq_200")
if !ok {
t.Fatalf("requiredEnvoyStatsMatcherInclusionRegexes doesn't match the route's stat_prefix")
}
}
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/all_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/auth_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/authsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/default_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/lrs_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/metrics_no_statsd_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/running_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/runningsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/stats_compression_gzip_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/stats_compression_zstd_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/stats_inclusion_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
"safe_regex": {"regex":"http.[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*_8080.downstream_rq_time"}
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_datadog_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_lightstep_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_none_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_opencensusagent_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_tls_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/tracing_zipkin_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/testdata/xdsproxy_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"suffix": "shadow_denied"
},
{
"safe_regex": {"regex":"vhost\\.*\\.route\\.*"}
"safe_regex": {"regex":"vhost\\..*\\.route\\..*"}
},
{
"prefix": "component"
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/51640.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: release-notes/v2
kind: bug-fix
area: telemetry
releaseNotes:
- |
**Fixed** statsMatcher's regex which didn't match route's stat_prefix

0 comments on commit 70f049e

Please sign in to comment.