You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/08/04 02:23:26 UTC

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #7399: Support Metric level function `serviceRelation` in `MAL` and binding envoy metrics into the topology.

kezhenxu94 commented on a change in pull request #7399:
URL: https://github.com/apache/skywalking/pull/7399#discussion_r682231166



##########
File path: oap-server/server-bootstrap/src/main/resources/envoy-metrics-rules/envoy-svc-relation.yaml
##########
@@ -0,0 +1,50 @@
+# 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.
+
+# This will parse a textual representation of a duration. The formats
+# accepted are based on the ISO-8601 duration format {@code PnDTnHnMn.nS}
+# with days considered to be exactly 24 hours.
+# <p>
+# Examples:
+# <pre>
+#    "PT20.345S" -- parses as "20.345 seconds"
+#    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
+#    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
+#    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+#    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
+#    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
+#    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
+#    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
+# </pre>
+
+expSuffix: serviceRelation(DetectPoint.CLIENT, ['app'], ['cluster_name'])
+metricPrefix: envoy_sr
+metricsRules:
+
+

Review comment:
       Remove these blank lines

##########
File path: oap-server/server-bootstrap/src/main/resources/ui-initialized-templates/topology-service-relation.yml
##########
@@ -120,127 +120,83 @@ templates:
             }
           ]
         },
-        "tcp":{
+        "envoy_metrics":{
           "server":[
+          ],
+          "client":[
             {
               "width":12,
-              "title":"Response Time",
+              "title":"Upstream CX Active",
               "height":"200",
               "entityType":"ServiceRelation",
               "metricType":"REGULAR_VALUE",
-              "metricName":"service_relation_server_resp_time",
+              "metricName":"envoy_sr_cluster_up_cx_active",
               "queryMetricType":"readMetricsValues",
-              "chartType":"ChartLine",
-              "unit":"ms"
+              "chartType":"ChartLine"
             },
             {
               "width":12,
-              "title":"Response Time Percentile",
-              "height":200,
-              "entityType":"ServiceRelation",
-              "metricType":"LABELED_VALUE",
-              "metricName":"service_relation_server_percentile",
-              "queryMetricType":"readLabeledMetricsValues",
-              "chartType":"ChartLine",
-              "unit":"ms",
-              "metricLabels":"P50, P75, P90, P95, P99",
-              "labelsIndex":"0, 1, 2, 3, 4"
-            },
-            {
-              "width":12,
-              "title":"Successful Rate",
+              "title":"Upstream CX Increase",
               "height":"200",
               "entityType":"ServiceRelation",
               "metricType":"REGULAR_VALUE",
-              "metricName":"service_relation_server_call_sla",
+              "metricName":"envoy_sr_cluster_up_cx_incr",
               "queryMetricType":"readMetricsValues",
               "chartType":"ChartLine",
-              "unit":"%",
-              "aggregation":"/",
-              "aggregationNum":"100"
+              "unit":"Per Minute"
             },
             {
               "width":12,
-              "title":"Load",
+              "title":"Upstream RQ Active",
               "height":"200",
               "entityType":"ServiceRelation",
               "metricType":"REGULAR_VALUE",
-              "metricName":"service_relation_server_cpm",
+              "metricName":"envoy_sr_cluster_up_rq_active",
               "queryMetricType":"readMetricsValues",
-              "chartType":"ChartLine",
-              "unit":"PPM - Packets Per Minute"
+              "chartType":"ChartLine"
             },
             {
               "width":12,
-              "title":"Throughput",
-              "height":"200",
-              "entityType":"ServiceRelation",
-              "metricType":"REGULAR_VALUE",
-              "metricName":"service_relation_server_received,service_relation_server_sent",
-              "queryMetricType":"readMetricsValues",
-              "chartType":"ChartLine",
-              "unit":"PPM - Packets Per Minutes"
-            }
-          ],
-          "client":[
-            {
-              "width":12,
-              "title":"Response Time",
+              "title":"Upstream RQ Increase",

Review comment:
       You already use abbreviations in the metrics names, let's use the full words in the title, otherwise there is nowhere to know the full description, the same for other places
   
   ```suggestion
                 "title":"Upstream Request Increase",
   ```

##########
File path: oap-server/server-bootstrap/src/main/resources/ui-initialized-templates/topology-service-relation.yml
##########
@@ -120,127 +120,83 @@ templates:
             }
           ]
         },
-        "tcp":{
+        "envoy_metrics":{

Review comment:
       Why remove `tcp` template?

##########
File path: oap-server/server-bootstrap/src/main/resources/metadata-service-mapping.yaml
##########
@@ -13,5 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-serviceName: ${LABELS."service.istio.io/canonical-revision"}.${LABELS."service.istio.io/canonical-name",LABELS."app.kubernetes.io/name",LABELS.app}.${NAMESPACE}
+serviceName: ${LABELS."service.istio.io/canonical-name",LABELS."app.kubernetes.io/name",LABELS.app}

Review comment:
       What's the reason to change this back and forth? I remember you change this in the previous PR

##########
File path: test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/mesh/MetricsServiceE2E.java
##########
@@ -124,7 +132,61 @@ void test() throws Exception {
                     instanceRespTimeMatcher.setValue(greaterThanZero);
                     instanceRespTimeMatcher.verify(instanceMetrics.getValues());
                 }
+
+                for (Map.Entry<String, List<String>> entry : ALL_ENVOY_LABELED_METRICS.entrySet()) {
+                    String metricsName = entry.getKey();
+                    List<String> labels = entry.getValue();
+                    LOGGER.info("verifying envoy labeledMetrics: {}", metricsName);
+                    List<ReadMetrics> labeledMetrics = graphql.readLabeledMetrics(
+                        new ReadLabeledMetricsQuery().stepByMinute()
+                                                     .metricsName(metricsName)
+                                                     .serviceName(service.getLabel())
+                                                     .scope("ServiceInstance")
+                                                     .instanceName(instance.getLabel())
+                                                     .labels(labels)
+                    );
+                    LOGGER.info("envoy labeledMetrics: {}", labeledMetrics);
+
+                    Metrics allValues = new Metrics();
+                    for (ReadMetrics readMetrics : labeledMetrics) {
+                        allValues.getValues().addAll(readMetrics.getValues().getValues());
+                    }
+                    final AtLeastOneOfMetricsMatcher instanceRespTimeMatcher = new AtLeastOneOfMetricsMatcher();
+                    final MetricsValueMatcher greaterThanZero = new MetricsValueMatcher();
+                    greaterThanZero.setValue("gt 0");
+                    instanceRespTimeMatcher.setValue(greaterThanZero);
+                    instanceRespTimeMatcher.verify(allValues);
+                }
             }
         }
     }
+
+    /*

Review comment:
       Remember to revert this

##########
File path: oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
##########
@@ -429,10 +448,29 @@ public SampleFamily endpoint(List<String> serviceKeys, List<String> endpointKeys
         return createMeterSamples(new EndpointEntityDescription(serviceKeys, endpointKeys));
     }
 
+    public SampleFamily serviceRelation(DetectPoint detectPoint,
+                                         List<String> serviceKeys,
+                                         List<String> relateServiceKeys) {

Review comment:
       ```suggestion
       public SampleFamily serviceRelation(DetectPoint detectPoint,
                                           List<String> serviceKeys,
                                           List<String> relateServiceKeys) {
   ```

##########
File path: oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
##########
@@ -429,10 +448,29 @@ public SampleFamily endpoint(List<String> serviceKeys, List<String> endpointKeys
         return createMeterSamples(new EndpointEntityDescription(serviceKeys, endpointKeys));
     }
 
+    public SampleFamily serviceRelation(DetectPoint detectPoint,
+                                         List<String> serviceKeys,
+                                         List<String> relateServiceKeys) {
+        Preconditions.checkArgument(serviceKeys.size() > 0);
+        Preconditions.checkArgument(relateServiceKeys.size() > 0);
+        ExpressionParsingContext.get().ifPresent(ctx -> ctx.scopeType = ScopeType.SERVICE_RELATION);

Review comment:
       ```suggestion
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org