You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/09/08 00:51:43 UTC

[GitHub] [hadoop] aajisaka commented on a change in pull request #3369: HADOOP-17804. Expose prometheus metrics only after a flush and dedupe with tag values

aajisaka commented on a change in pull request #3369:
URL: https://github.com/apache/hadoop/pull/3369#discussion_r703945269



##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/PrometheusMetricsSink.java
##########
@@ -53,42 +57,16 @@ public PrometheusMetricsSink() {
 
   @Override
   public void putMetrics(MetricsRecord metricsRecord) {
-    for (AbstractMetric metrics : metricsRecord.metrics()) {
-      if (metrics.type() == MetricType.COUNTER
-          || metrics.type() == MetricType.GAUGE) {
+    for (AbstractMetric metric : metricsRecord.metrics()) {
+      if (metric.type() == MetricType.COUNTER
+          || metric.type() == MetricType.GAUGE) {
 
         String key = prometheusName(
-            metricsRecord.name(), metrics.name());
-
-        StringBuilder builder = new StringBuilder();
-        builder.append("# TYPE ")
-            .append(key)
-            .append(" ")
-            .append(metrics.type().toString().toLowerCase())
-            .append("\n")
-            .append(key)
-            .append("{");
-        String sep = "";
-
-        //add tags
-        for (MetricsTag tag : metricsRecord.tags()) {
-          String tagName = tag.name().toLowerCase();
-
-          //ignore specific tag which includes sub-hierarchy
-          if (!tagName.equals("numopenconnectionsperuser")) {
-            builder.append(sep)
-                .append(tagName)
-                .append("=\"")
-                .append(tag.value())
-                .append("\"");
-            sep = ",";
-          }

Review comment:
       @Kimahriman 
   Before committing your patch, I tested it on my local environment and found an issue.
   
   Would you ignore "numopenconnectionsperuser" tag in your patch? The label value can become `numopenconnectionsperuser="{"hdfs":17}"`, and it is not valid in prometheus.
   
   ```
   % curl -s http://<namenode>:9870/prom | promtool check metrics                                  
   error while linting: text format parsing error in line 21: unexpected end of label value "{"
   ```
   
   Sorry for the back and forth.




-- 
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: common-issues-unsubscribe@hadoop.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org