Fix PromQL HTTP API `/api/v1/series` response missing `service` label when matching metric (#10715)

This commit is contained in:
Wan Kai 2023-04-23 10:31:52 +08:00 committed by GitHub
parent af2cf9958f
commit 1ca9e0acfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 98 additions and 0 deletions

View File

@ -35,6 +35,7 @@
* Support no-proxy mode for aws-firehose receiver
* Bump up armeria to 1.23.1
* Support Elasticsearch Monitoring.
* Fix PromQL HTTP API `/api/v1/series` response missing `service` label when matching metric.
#### UI
* Revert: cpm5d function. This feature is cancelled from backend.

View File

@ -500,11 +500,13 @@ public class PromQLApiHandler {
break;
case ServiceInstance:
metricInfo.getLabels().add(new LabelValuePair(LabelName.SCOPE, Scope.ServiceInstance.name()));
metricInfo.getLabels().add(new LabelValuePair(LabelName.SERVICE, ""));
metricInfo.getLabels().add(new LabelValuePair(LabelName.SERVICE_INSTANCE, ""));
metricInfo.getLabels().add(new LabelValuePair(LabelName.PARENT_SERVICE, ""));
break;
case Endpoint:
metricInfo.getLabels().add(new LabelValuePair(LabelName.SCOPE, Scope.Endpoint.name()));
metricInfo.getLabels().add(new LabelValuePair(LabelName.SERVICE, ""));
metricInfo.getLabels().add(new LabelValuePair(LabelName.ENDPOINT, ""));
metricInfo.getLabels().add(new LabelValuePair(LabelName.PARENT_SERVICE, ""));
break;

View File

@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
"status": "success",
"data": [
{
"__name__": "endpoint_cpm",
"layer": "",
"top_n": "",
"order": "",
"scope": "Endpoint",
"service": "",
"endpoint": "",
"parent_service": ""
}
]
}

View File

@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
"status": "success",
"data": [
{
"__name__": "service_instance_cpm",
"layer": "",
"top_n": "",
"order": "",
"scope": "ServiceInstance",
"service": "",
"service_instance": "",
"parent_service": ""
}
]
}

View File

@ -0,0 +1,28 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
"status": "success",
"data": [
{
"__name__": "service_cpm",
"layer": "",
"top_n": "",
"order": "",
"scope": "Service",
"service": ""
}
]
}

View File

@ -21,6 +21,13 @@ cases:
expected: expected/instance-traffic.yml
- query: curl -X GET http://${oap_host}:${oap_9090}/api/v1/series -d 'match[]=endpoint_traffic{layer="GENERAL", service="e2e-service-provider", keyword="POST:/users"}&start='$(($(date +%s)-1800))'&end='$(date +%s)
expected: expected/endpoint-traffic.yml
# metrics series
- query: curl -X GET http://${oap_host}:${oap_9090}/api/v1/series -d 'match[]=service_cpm&start='$(($(date +%s)-1800))'&end='$(date +%s)
expected: expected/service-metric-series.yml
- query: curl -X GET http://${oap_host}:${oap_9090}/api/v1/series -d 'match[]=service_instance_cpm&start='$(($(date +%s)-1800))'&end='$(date +%s)
expected: expected/instance-metric-series.yml
- query: curl -X GET http://${oap_host}:${oap_9090}/api/v1/series -d 'match[]=endpoint_cpm&start='$(($(date +%s)-1800))'&end='$(date +%s)
expected: expected/endpoint-metric-series.yml
# metrics names query
- query: curl -X GET http://${oap_host}:${oap_9090}/api/v1/label/__name__/values
expected: expected/metrics-names.yml