Duansg commented on code in PR #3761:
URL: https://github.com/apache/hertzbeat/pull/3761#discussion_r2364632465


##########
hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/http/HttpCollectImpl.java:
##########
@@ -627,33 +627,35 @@ private void parseResponseByPromQl(String resp, 
List<String> aliasFields, HttpPr
     }
 
     private void parseResponseByPrometheusExporter(InputStream content, 
List<String> aliasFields, CollectRep.MetricsData.Builder builder) throws 
IOException {
-        Map<String, MetricFamily> metricFamilyMap = 
OnlineParser.parseMetrics(content);
+        String metrics = builder.getMetrics();
+        Map<String, MetricFamily> metricFamilyMap = 
OnlineParser.parseMetrics(content, metrics);
         if (metricFamilyMap == null || metricFamilyMap.isEmpty()) {
             return;
         }
-        String metrics = builder.getMetrics();
-        if (metricFamilyMap.containsKey(metrics)) {
-            MetricFamily metricFamily = metricFamilyMap.get(metrics);
-            for (MetricFamily.Metric metric : metricFamily.getMetricList()) {
-                Map<String, String> labelMap = metric.getLabels()
-                        .stream()
-                        .collect(Collectors.toMap(MetricFamily.Label::getName, 
MetricFamily.Label::getValue));
-                CollectRep.ValueRow.Builder valueRowBuilder = 
CollectRep.ValueRow.newBuilder();
-                for (String aliasField : aliasFields) {
-                    String columnValue = labelMap.get(aliasField);
-                    if (columnValue != null) {
-                        valueRowBuilder.addColumn(columnValue);
-                    } else if (CommonConstants.PROM_VALUE.equals(aliasField) 
|| CommonConstants.PROM_METRIC_VALUE.equals(aliasField)) {
-                        
valueRowBuilder.addColumn(String.valueOf(metric.getValue()));
-                    } else {
-                        valueRowBuilder.addColumn(CommonConstants.NULL_VALUE);
-                    }
+        MetricFamily metricFamily = metricFamilyMap.get(metrics);

Review Comment:
   This method must be retained, and both full analysis and single-indicator 
analysis must be provided.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to