gianm commented on code in PR #17919:
URL: https://github.com/apache/druid/pull/17919#discussion_r2046092221


##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaConsumerMonitor.java:
##########
@@ -33,22 +31,95 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 public class KafkaConsumerMonitor extends AbstractMonitor
 {
   private volatile boolean stopAfterNext = false;
 
-  // Kafka metric name -> Druid metric name
-  private static final Map<String, String> METRICS =
-      ImmutableMap.<String, String>builder()
-                  .put("bytes-consumed-total", "kafka/consumer/bytesConsumed")
-                  .put("records-consumed-total", 
"kafka/consumer/recordsConsumed")
-                  .build();
-  private static final String TOPIC_TAG = "topic";
-  private static final Set<String> TOPIC_METRIC_TAGS = 
ImmutableSet.of("client-id", TOPIC_TAG);
+  private static final String CLIENT_ID_TAG = "client-id";
+
+  // Kafka metric name -> Kafka metric descriptor
+  private static final Map<String, KafkaConsumerMetric> METRICS =
+      Stream.of(
+          new KafkaConsumerMetric(
+              "bytes-consumed-total",
+              "kafka/consumer/bytesConsumed",
+              Set.of(CLIENT_ID_TAG, "topic"),
+              KafkaConsumerMetric.MetricType.COUNTER
+          ),
+          new KafkaConsumerMetric(
+              "records-consumed-total",
+              "kafka/consumer/recordsConsumed",
+              Set.of(CLIENT_ID_TAG, "topic"),
+              KafkaConsumerMetric.MetricType.COUNTER
+          ),
+          new KafkaConsumerMetric(
+              "fetch-total",
+              "kafka/consumer/fetch",
+              Set.of(CLIENT_ID_TAG),
+              KafkaConsumerMetric.MetricType.COUNTER
+          ),
+          new KafkaConsumerMetric(
+              "fetch-rate",
+              "kafka/consumer/fetchRate",
+              Set.of(CLIENT_ID_TAG),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "fetch-latency-avg",
+              "kafka/consumer/fetchLatencyAvg",
+              Set.of(CLIENT_ID_TAG),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "fetch-latency-max",
+              "kafka/consumer/fetchLatencyMax",
+              Set.of(CLIENT_ID_TAG),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "fetch-size-avg",
+              "kafka/consumer/fetchSizeAvg",
+              Set.of(CLIENT_ID_TAG, "topic"),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "fetch-size-max",
+              "kafka/consumer/fetchSizeMax",
+              Set.of(CLIENT_ID_TAG, "topic"),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "records-lag",
+              "kafka/consumer/recordsLag",
+              Set.of(CLIENT_ID_TAG, "topic", "partition"),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "records-per-request-avg",
+              "kafka/consumer/recordsPerRequestAvg",
+              Set.of(CLIENT_ID_TAG, "topic"),
+              KafkaConsumerMetric.MetricType.GAUGE
+          ),
+          new KafkaConsumerMetric(
+              "outgoing-byte-total",
+              "kafka/consumer/outgoingBytes",
+              Set.of(CLIENT_ID_TAG, "node-id"),

Review Comment:
   Updated.



-- 
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