Class KafkaSourceReaderMetrics
KafkaSourceReader.
All metrics of Kafka source reader are registered under group "KafkaSourceReader", which is a
child group of OperatorMetricGroup. Metrics related to a
specific topic partition will be registered in the group
"KafkaSourceReader.topic.{topic_name}.partition.{partition_id}".
For example, current consuming offset of topic "my-topic" and partition 1 will be reported in metric: "{some_parent_groups}.operator.KafkaSourceReader.topic.my-topic.partition.1.currentOffset"
and number of successful commits will be reported in metric: "{some_parent_groups}.operator.KafkaSourceReader.commitsSucceeded"
All metrics of Kafka consumer are also registered under group "KafkaSourceReader.KafkaConsumer". For example, Kafka consumer metric "records-consumed-total" can be found at: {some_parent_groups}.operator.KafkaSourceReader.KafkaConsumer.records-consumed-total"
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKafkaSourceReaderMetrics(org.apache.flink.metrics.groups.SourceReaderMetricGroup sourceReaderMetricGroup) -
Method Summary
Modifier and TypeMethodDescriptionvoidmaybeAddRecordsLagMetric(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> consumer, org.apache.kafka.common.TopicPartition tp) Add a partition's records-lag metric to tracking list if this partition never appears before.voidrecordCommittedOffset(org.apache.kafka.common.TopicPartition tp, long offset) Update the latest committed offset of the givenTopicPartition.voidrecordCurrentOffset(org.apache.kafka.common.TopicPartition tp, long offset) Update current consuming offset of the givenTopicPartition.voidMark a failure commit.voidMark a successful commit.voidregisterKafkaConsumerMetrics(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> kafkaConsumer) Register metrics of KafkaConsumer in Kafka metric group.voidregisterNumBytesIn(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> consumer) RegisterMetricNames.IO_NUM_BYTES_IN.voidregisterTopicPartition(org.apache.kafka.common.TopicPartition tp) Register metric groups for the givenTopicPartition.voidremoveRecordsLagMetric(org.apache.kafka.common.TopicPartition tp) Remove a partition's records-lag metric from tracking list.voidUpdateMetricNames.IO_NUM_BYTES_IN.
-
Field Details
-
KAFKA_SOURCE_READER_METRIC_GROUP
- See Also:
-
TOPIC_GROUP
- See Also:
-
PARTITION_GROUP
- See Also:
-
CURRENT_OFFSET_METRIC_GAUGE
- See Also:
-
COMMITTED_OFFSET_METRIC_GAUGE
- See Also:
-
COMMITS_SUCCEEDED_METRIC_COUNTER
- See Also:
-
COMMITS_FAILED_METRIC_COUNTER
- See Also:
-
KAFKA_CONSUMER_METRIC_GROUP
- See Also:
-
CONSUMER_FETCH_MANAGER_GROUP
- See Also:
-
BYTES_CONSUMED_TOTAL
- See Also:
-
RECORDS_LAG
- See Also:
-
INITIAL_OFFSET
public static final long INITIAL_OFFSET- See Also:
-
-
Constructor Details
-
KafkaSourceReaderMetrics
public KafkaSourceReaderMetrics(org.apache.flink.metrics.groups.SourceReaderMetricGroup sourceReaderMetricGroup)
-
-
Method Details
-
registerKafkaConsumerMetrics
public void registerKafkaConsumerMetrics(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> kafkaConsumer) Register metrics of KafkaConsumer in Kafka metric group.- Parameters:
kafkaConsumer- Kafka consumer used by partition split reader.
-
registerTopicPartition
public void registerTopicPartition(org.apache.kafka.common.TopicPartition tp) Register metric groups for the givenTopicPartition.- Parameters:
tp- Registering topic partition
-
recordCurrentOffset
public void recordCurrentOffset(org.apache.kafka.common.TopicPartition tp, long offset) Update current consuming offset of the givenTopicPartition.- Parameters:
tp- Updating topic partitionoffset- Current consuming offset
-
recordCommittedOffset
public void recordCommittedOffset(org.apache.kafka.common.TopicPartition tp, long offset) Update the latest committed offset of the givenTopicPartition.- Parameters:
tp- Updating topic partitionoffset- Committing offset
-
recordSucceededCommit
public void recordSucceededCommit()Mark a successful commit. -
recordFailedCommit
public void recordFailedCommit()Mark a failure commit. -
registerNumBytesIn
public void registerNumBytesIn(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> consumer) RegisterMetricNames.IO_NUM_BYTES_IN.- Parameters:
consumer- Kafka consumer
-
maybeAddRecordsLagMetric
public void maybeAddRecordsLagMetric(org.apache.kafka.clients.consumer.KafkaConsumer<?, ?> consumer, org.apache.kafka.common.TopicPartition tp) Add a partition's records-lag metric to tracking list if this partition never appears before.This method also lazily register
MetricNames.PENDING_RECORDSinSourceReaderMetricGroup- Parameters:
consumer- Kafka consumertp- Topic partition
-
removeRecordsLagMetric
public void removeRecordsLagMetric(org.apache.kafka.common.TopicPartition tp) Remove a partition's records-lag metric from tracking list.- Parameters:
tp- Unassigned topic partition
-
updateNumBytesInCounter
public void updateNumBytesInCounter()UpdateMetricNames.IO_NUM_BYTES_IN.Instead of simply setting
OperatorIOMetricGroup.getNumBytesInCounter()to the same value as bytes-consumed-total from Kafka consumer, which will screwTaskIOMetricGroup.getNumBytesInCounter()if chained sources exist, we track the increment of bytes-consumed-total and count it towards the counter.
-