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

Skip misconfigured vts entries #227

Merged
merged 3 commits into from
Jun 17, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v3.1.7
* [BUGFIX] Do not generate Prometheus metrics for invalid nginx-vts entries

# v3.1.6
* [BUGFIX] Reduce the number of DescribeTargetGroups to avoid reaching the API limits
* [BUGFIX] Do not set the nlb updater as initialised if it failed to describe the target groups
Expand Down
4 changes: 2 additions & 2 deletions nginx/nginx_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func updateIngressMetrics(metrics VTSMetrics) {
}

strs := strings.Split(zone, "::")
if len(strs) != 2 {
log.Warnf("filter name not formatted as expected for %s, got %s without a '::' split", host, zone)
if len(strs) != 2 || strs[1] == "" {
log.Warnf("filter name not formatted as expected for %s, got %s without a valid '::' split", host, zone)
continue
}
path := strs[0]
Expand Down
208 changes: 208 additions & 0 deletions nginx/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,15 @@ func TestUpdatesMetricsFromNginxStatusPage(t *testing.T) {
assertEndpointRequestCounters(t,
"kube-system.10.254.201.199.80", "10.254.201.199:80",
2910.0, 1570.0, 1.0, 10.0, 9.0, 2.0, 3.0)

// Assert that hosts with both valid and invalid entries for the same path generate metrics for the correct, valid VTS entry
assertIngressRequestCounters(t,
"ingress-with-valid-duplicate-path.sandbox.cosmic.sky", "/path/",
5000.0, 2000.0, 0.0, 5.0, 0.0, 0.0, 0.0)
// Assert that invalid paths do not generate metrics, even if the VTS data shows hits (e.g. 3xx's)
assertIngressRequestCounters(t,
"ingress-with-invalid-path.sandbox.cosmic.sky", "/bad/",
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
}

func assertIngressRequestCounters(t *testing.T, host, path string, in, out, ones, twos, threes, fours, fives float64) {
Expand Down Expand Up @@ -2267,6 +2276,84 @@ var statusResponseBody = []byte(`{
"scarce": 0
}
},
"ingress-with-valid-duplicate-path.sandbox.cosmic.sky": {
"requestCounter": 5,
"inBytes": 5000,
"outBytes": 2000,
"responses": {
"1xx": 0,
"2xx": 5,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
},
"overCounts": {
"maxIntegerSize": 18446744073709551615,
"requestCounter": 0,
"inBytes": 0,
"outBytes": 0,
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
}
},
"ingress-with-invalid-path.sandbox.cosmic.sky": {
"requestCounter": 10,
"inBytes": 10,
"outBytes": 5,
"responses": {
"1xx": 0,
"2xx": 0,
"3xx": 10,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
},
"overCounts": {
"maxIntegerSize": 18446744073709551615,
"requestCounter": 0,
"inBytes": 0,
"outBytes": 0,
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
}
},
"*": {
"requestCounter": 10,
"inBytes": 2910,
Expand Down Expand Up @@ -2389,6 +2476,127 @@ var statusResponseBody = []byte(`{
"scarce": 0
}
}
},
"ingress-with-valid-duplicate-path.sandbox.cosmic.sky": {
"/path/::some-app.10.254.204.100.8080": {
"requestCounter": 10,
"inBytes": 5000,
"outBytes": 2000,
"responses": {
"1xx": 0,
"2xx": 5,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
},
"overCounts": {
"maxIntegerSize": 18446744073709551615,
"requestCounter": 0,
"inBytes": 0,
"outBytes": 0,
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
}
},
"/path/::": {
"requestCounter": 50,
"inBytes": 50,
"outBytes": 50,
"responses": {
"1xx": 50,
"2xx": 50,
"3xx": 50,
"4xx": 50,
"5xx": 50,
"miss": 50,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
},
"overCounts": {
"maxIntegerSize": 18446744073709551615,
"requestCounter": 0,
"inBytes": 0,
"outBytes": 0,
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
}
}
},
"ingress-with-invalid-path.sandbox.cosmic.sky": {
"/bad::": {
"requestCounter": 10,
"inBytes": 10,
"outBytes": 5,
"responses": {
"1xx": 0,
"2xx": 10,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
},
"overCounts": {
"maxIntegerSize": 18446744073709551615,
"requestCounter": 0,
"inBytes": 0,
"outBytes": 0,
"1xx": 0,
"2xx": 0,
"3xx": 0,
"4xx": 0,
"5xx": 0,
"miss": 0,
"bypass": 0,
"expired": 0,
"stale": 0,
"updating": 0,
"revalidated": 0,
"hit": 0,
"scarce": 0
}
}
}
},
"upstreamZones": {
Expand Down