diff --git a/.github/workflows/skywalking.yaml b/.github/workflows/skywalking.yaml index e4f80444d6..52226fb86e 100644 --- a/.github/workflows/skywalking.yaml +++ b/.github/workflows/skywalking.yaml @@ -750,8 +750,8 @@ jobs: matrix: analyzer: [k8s-mesh, mx-mesh] versions: - - istio: 1.7.1 - kubernetes: 18 + #- istio: 1.7.1 + # kubernetes: 18 - istio: 1.8.2 kubernetes: 19 - istio: 1.9.1 diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md index 683bdeec14..0aa57650f5 100644 --- a/docs/en/changes/changes.md +++ b/docs/en/changes/changes.md @@ -14,9 +14,10 @@ * Remove patterns from `HttpUriRecognitionService#feedRawData` and add max 10 candidates of raw URIs for each pattern. * Add component ID for WebSphere. * Fix AI Pipeline uri caching NullPointer and IllegalArgument Exceptions. +* Fix `NPE` in metrics query when the metric is not exist. #### UI - +* Fix metric name `browser_app_error_rate` in `Browser-Root` dashboard. #### Documentation diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java index 9bd7b03568..37687ff22b 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java @@ -137,19 +137,22 @@ public class MetricsQuery implements GraphQLQueryResolver { * Read time-series values in the duration of required metrics */ public MetricsValues readMetricsValues(MetricsCondition condition, Duration duration) throws IOException { - if (!condition.senseScope() || !condition.getEntity().isValid()) { + boolean hasScope = condition.senseScope(); + if (!hasScope || !condition.getEntity().isValid()) { final List pointOfTimes = duration.assembleDurationPoints(); + String entityId = "UNKNOWN_METRIC_NAME"; + if (hasScope) { + entityId = "ILLEGAL_ENTITY"; + } MetricsValues values = new MetricsValues(); - pointOfTimes.forEach(pointOfTime -> { - String id = pointOfTime.id( - condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY" - ); + for (PointOfTime pointOfTime : pointOfTimes) { + String id = pointOfTime.id(entityId); final KVInt kvInt = new KVInt(); kvInt.setId(id); kvInt.setValue(0); kvInt.setEmptyValue(true); values.getValues().addKVInt(kvInt); - }); + } return values; } return getMetricsQueryService().readMetricsValues(condition, duration); @@ -173,25 +176,27 @@ public class MetricsQuery implements GraphQLQueryResolver { public List readLabeledMetricsValues(MetricsCondition condition, List labels, Duration duration) throws IOException { - if (!condition.senseScope() || !condition.getEntity().isValid()) { + boolean hasScope = condition.senseScope(); + if (!hasScope || !condition.getEntity().isValid()) { final List pointOfTimes = duration.assembleDurationPoints(); - + String entityId = "UNKNOWN_METRIC_NAME"; + if (hasScope) { + entityId = "ILLEGAL_ENTITY"; + } List labeledValues = new ArrayList<>(labels.size()); - labels.forEach(label -> { + for (String label : labels) { MetricsValues values = new MetricsValues(); - pointOfTimes.forEach(pointOfTime -> { - String id = pointOfTime.id( - condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY" - ); + for (PointOfTime pointOfTime : pointOfTimes) { + String id = pointOfTime.id(entityId); final KVInt kvInt = new KVInt(); kvInt.setId(id); kvInt.setValue(0); kvInt.setEmptyValue(true); values.getValues().addKVInt(kvInt); - }); + } values.setLabel(label); labeledValues.add(values); - }); + } return labeledValues; } return getMetricsQueryService().readLabeledMetricsValues(condition, labels, duration); @@ -210,18 +215,21 @@ public class MetricsQuery implements GraphQLQueryResolver { * */ public HeatMap readHeatMap(MetricsCondition condition, Duration duration) throws IOException { - if (!condition.senseScope() || !condition.getEntity().isValid()) { + boolean hasScope = condition.senseScope(); + if (!hasScope || !condition.getEntity().isValid()) { DataTable emptyData = new DataTable(); emptyData.put("0", 0L); final String rawdata = emptyData.toStorageData(); final HeatMap heatMap = new HeatMap(); final List pointOfTimes = duration.assembleDurationPoints(); - pointOfTimes.forEach(pointOfTime -> { - String id = pointOfTime.id( - condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY" - ); + String entityId = "UNKNOWN_METRIC_NAME"; + if (hasScope) { + entityId = "ILLEGAL_ENTITY"; + } + for (PointOfTime pointOfTime : pointOfTimes) { + String id = pointOfTime.id(entityId); heatMap.buildColumn(id, rawdata, 0); - }); + } return heatMap; } return getMetricsQueryService().readHeatMap(condition, duration); diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json index f8fdce713d..92edb7e853 100644 --- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json +++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json @@ -40,7 +40,7 @@ }, "metrics": [ "browser_app_pv", - "browser_app_error_rage" + "browser_app_error_rate" ], "metricTypes": [ "readMetricsValues",