You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2023/03/23 08:40:23 UTC
[skywalking] branch master updated: Fix PromQL HTTP API `/api/v1/labels` response missing `service` label. (#10579)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new d88d887a32 Fix PromQL HTTP API `/api/v1/labels` response missing `service` label. (#10579)
d88d887a32 is described below
commit d88d887a32f791d0670e4e8d5c2fd615126234cf
Author: Wan Kai <wa...@foxmail.com>
AuthorDate: Thu Mar 23 16:40:05 2023 +0800
Fix PromQL HTTP API `/api/v1/labels` response missing `service` label. (#10579)
---
docs/en/api/promql-service.md | 8 ++++----
docs/en/changes/changes.md | 1 +
.../oap/query/promql/handler/PromQLApiHandler.java | 2 +-
.../oap/query/promql/rt/PromQLExprQueryVisitor.java | 12 ++++++------
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/docs/en/api/promql-service.md b/docs/en/api/promql-service.md
index c4f69ae3e6..686b5599c3 100644
--- a/docs/en/api/promql-service.md
+++ b/docs/en/api/promql-service.md
@@ -2,10 +2,10 @@
PromQL([Prometheus Query Language](https://prometheus.io/docs/prometheus/latest/querying/basics/)) Service
exposes Prometheus Querying HTTP APIs including the bundled PromQL expression system.
Third-party systems or visualization platforms that already support PromQL (such as Grafana),
-could obtain metrics through PromeQL Service.
+could obtain metrics through PromQL Service.
As SkyWalking and Prometheus have fundamental differences in metrics classification, format, storage, etc.
-The PromQL Service supported will be a subset of the complete PromQL
+The PromQL Service supported will be a subset of the complete PromQL.
## Details Of Supported Protocol
The following doc describes the details of the supported protocol and compared it to the PromQL official documentation.
@@ -286,7 +286,7 @@ Result:
"status": "success",
"data": [
"layer",
- "scope",
+ "service",
"top_n",
"order",
"service_instance",
@@ -382,7 +382,7 @@ Result:
## Metrics Type For Query
### Supported Metrics [Scope](../../../oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/enumeration/Scope.java)(Catalog)
-All scopes are not supported completely, please check the following table:
+Not all scopes are supported for now, please check the following table:
| Scope | Support |
|-------------------------|---------|
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 3d34aab7cb..1a2ca979c8 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -18,6 +18,7 @@
* Support collect process level related metrics.
* Fix K8sRetag reads the wrong k8s service from the cache due to a possible namespace mismatch.
* [Breaking Change] Support cross-thread trace profiling. The data structure and query APIs are changed.
+* Fix PromQL HTTP API `/api/v1/labels` response missing `service` label.
#### UI
* Revert: cpm5d function. This feature is cancelled from backend.
diff --git a/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java b/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java
index ae2063c9e7..04d612b660 100644
--- a/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java
+++ b/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java
@@ -459,7 +459,7 @@ public class PromQLApiHandler {
Column.ValueDataType dataType) {
List<LabelName> labelNames = new ArrayList<>();
labelNames.add(LabelName.LAYER);
- labelNames.add(LabelName.SCOPE);
+ labelNames.add(LabelName.SERVICE);
labelNames.add(LabelName.TOP_N);
labelNames.add(LabelName.ORDER);
if (Column.ValueDataType.LABELED_VALUE == dataType) {
diff --git a/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/rt/PromQLExprQueryVisitor.java b/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/rt/PromQLExprQueryVisitor.java
index 8aaf9db95d..7338f70a1a 100644
--- a/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/rt/PromQLExprQueryVisitor.java
+++ b/oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/rt/PromQLExprQueryVisitor.java
@@ -179,7 +179,7 @@ public class PromQLExprQueryVisitor extends PromQLParserBaseVisitor<ParseResult>
try {
String metricName = ctx.metricName().getText();
Optional<ValueColumnMetadata.ValueColumn> valueColumn = getValueColumn(metricName);
- if (!valueColumn.isPresent()) {
+ if (valueColumn.isEmpty()) {
result.setErrorType(ErrorType.BAD_DATA);
result.setErrorInfo("Metric: [" + metricName + "] dose not exist.");
return result;
@@ -261,9 +261,9 @@ public class PromQLExprQueryVisitor extends PromQLParserBaseVisitor<ParseResult>
LabelName... labelNames) throws IllegalExpressionException {
StringBuilder missLabels = new StringBuilder();
int j = 0;
- for (int i = 0; i < labelNames.length; i++) {
- String labelName = labelNames[i].toString();
- if (labelMap.get(labelNames[i]) == null) {
+ for (final LabelName name : labelNames) {
+ String labelName = name.toString();
+ if (labelMap.get(name) == null) {
missLabels.append(j++ > 0 ? "," : "").append(labelName);
}
}
@@ -335,12 +335,12 @@ public class PromQLExprQueryVisitor extends PromQLParserBaseVisitor<ParseResult>
MetricsCondition metricsCondition = buildMetricsCondition(metricName, layer, scope, labelMap);
Map<String, String> relabelMap = new HashMap<>();
String queryLabels = labelMap.get(LabelName.LABELS);
- List<String> queryLabelList = Collections.EMPTY_LIST;
+ List<String> queryLabelList = Collections.emptyList();
if (StringUtil.isNotBlank(queryLabels)) {
queryLabelList = Arrays.asList(queryLabels.split(Const.COMMA));
String relabels = labelMap.get(LabelName.RELABELS);
- List<String> relabelList = Collections.EMPTY_LIST;
+ List<String> relabelList = Collections.emptyList();
if (StringUtil.isNotBlank(relabels)) {
relabelList = Arrays.asList(relabels.split(Const.COMMA));
}