如何使用dropwizard库访问Kafka指标数据

8ljdwjyq  于 2023-04-29  发布在  Apache
关注(0)|答案(1)|浏览(105)

有人能提供一个如何使用dropwizard lib访问Kafka指标的例子吗?
下面的代码使用yammer metrica访问具有给定指标Name的指标

MetricName  metricName = new MetricName("", "", "", "", "kafka.server:type=ZooKeeperClientMetrics,name=ZooKeeperRequestLatencyMs");
Metric m = Metrics.defaultRegistry().allMetrics().get(metricName);

another example of accessing the metrics using yammer

for (Map.Entry<String, SortedMap<MetricName, Metric>> entry : getMetricsRegistry()
                .groupedMetrics(MetricPredicate.ALL)
                .entrySet()) {
                for (Map.Entry<MetricName, Metric> subEntry : entry.getValue().entrySet()) {
                    final Metric metric = subEntry.getValue();
                    metric.processWith(this, subEntry.getKey(), epoch);                   
                }
            }


Does anybody know what is the equivalent code using dropwizard?

相关问题