You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/03/29 04:03:47 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #6615: Export ManagedLedgerCache metric to prometheus

codelipenghui commented on a change in pull request #6615: Export ManagedLedgerCache metric to prometheus
URL: https://github.com/apache/pulsar/pull/6615#discussion_r399741095
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java
 ##########
 @@ -75,12 +81,54 @@ public static void generate(PulsarService pulsar, boolean includeTopicMetrics, b
             FunctionsStatsGenerator.generate(pulsar.getWorkerService(),
                     pulsar.getConfiguration().getClusterName(), stream);
 
+            generateBrokerBasicMetrics(pulsar, stream);
+
             out.write(buf.array(), buf.arrayOffset(), buf.readableBytes());
         } finally {
             buf.release();
         }
     }
 
+    private static void generateBrokerBasicMetrics(PulsarService pulsar, SimpleTextOutputStream stream) {
+        String clusterName = pulsar.getConfiguration().getClusterName();
+        // generate managedLedgerCache metrics
+        parseMetricsToPrometheusMetrics(new ManagedLedgerCacheMetrics(pulsar).generate(),
+                clusterName, "managedLedgerCache", Collector.Type.GAUGE, stream);
+
+        // generate managerLedger metrics
+        parseMetricsToPrometheusMetrics(new ManagedLedgerMetrics(pulsar).generate(),
+                clusterName, "manageLedger", Collector.Type.GAUGE, stream);
+
+        // generate brokerService topic metrics
+        parseMetricsToPrometheusMetrics(pulsar.getBrokerService().getTopicMetrics(),
+                clusterName, "brokerService", Collector.Type.GAUGE, stream);
 
 Review comment:
   We already expose topic level metrics, why we need to add topic metrics again.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services