fix inconsistent-label-cardinality for prometheus metrics: nginx_ingress_controller_requests (#8225)
* fix inconsistent-label-cardinality for prometheus metrics: nginx_ingress_controller_requests * add host to collectorLabels only if metricsPerHost is true
This commit is contained in:
parent
53a232f829
commit
86964b15a8
2 changed files with 42 additions and 4 deletions
|
|
@ -153,7 +153,35 @@ func TestCollector(t *testing.T) {
|
|||
wantAfter: `
|
||||
`,
|
||||
},
|
||||
|
||||
{
|
||||
name: "valid metric object should update requests metrics",
|
||||
data: []string{`[{
|
||||
"host":"testshop.com",
|
||||
"status":"200",
|
||||
"bytesSent":150.0,
|
||||
"method":"GET",
|
||||
"path":"/admin",
|
||||
"requestLength":300.0,
|
||||
"requestTime":60.0,
|
||||
"upstreamName":"test-upstream",
|
||||
"upstreamIP":"1.1.1.1:8080",
|
||||
"upstreamResponseTime":200,
|
||||
"upstreamStatus":"220",
|
||||
"namespace":"test-app-production",
|
||||
"ingress":"web-yml",
|
||||
"service":"test-app",
|
||||
"canary":""
|
||||
}]`},
|
||||
metrics: []string{"nginx_ingress_controller_requests"},
|
||||
wantBefore: `
|
||||
# HELP nginx_ingress_controller_requests The total number of client requests.
|
||||
# TYPE nginx_ingress_controller_requests counter
|
||||
nginx_ingress_controller_requests{canary="",controller_class="ingress",controller_namespace="default",controller_pod="pod",host="testshop.com",ingress="web-yml",method="GET",namespace="test-app-production",path="/admin",service="test-app",status="200"} 1
|
||||
`,
|
||||
removeIngresses: []string{"test-app-production/web-yml"},
|
||||
wantAfter: `
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "valid metric object with canary information should update prometheus metrics",
|
||||
data: []string{`[{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue