I have metric:
http_server_requests_seconds_count{service="application", status="200", uri="/v1/rest/clients/ids"} 30
http_server_requests_seconds_count{service="application", status="500", uri="/v1/rest/clients/ids"} 20
And I need to calculate the number of Uri in general and Uri with a certain status.
Request 1: (Count by Uri)
round(sum(delta(http_server_requests_seconds_count[5m])) by (service, uri))
"result" : [
{
"metric" : {
"service" : "application",
"uri" : "/v1/rest/clients/ids"
},
"value" : [
1.662458065998E9,
"50"
]
},
Request 2: (Count by Uri and status)
round(sum(delta(http_server_requests_seconds_count[5m])) by (service, uri, status))
"result" : [
{
"metric" : {
"service" : "application",
"status" : "200",
"uri" : "/v1/rest/clients/ids"
},
"value" : [
1.662458065998E9,
"30"
]
},
{
"metric" : {
"service" : "application",
"status" : "500",
"uri" : "/v1/rest/clients/ids"
},
"value" : [
1.662458065998E9,
"20"
]
},
How can I combine these 2 requests by service and url and get 2(3) values? Something like this:
"result" : [
{
"metric" : {
"service" : "application",
"uri" : "/v1/rest/clients/ids",
"status": {
"200": {
"value" : [
1.662458065998E9,
"30"
]
},
"500": {
"value" : [
1.662458065998E9,
"20"
]
},
},
"value" : [
1.662458065998E9,
"50"
]
},
I tried to use query:
round(sum(delta(http_server_requests_seconds_count[5m])) by (service, uri))
* on (service,uri) group_right(status)
round(sum(delta(http_server_requests_seconds_count[5m])) by (service,uri, status))
But got error
{"status":"error","errorType":"execution","error":"multiple matches for labels: grouping labels must ensure unique matches"}