Skip to content

Commit 86e6a92

Browse files
authored
Add consumer rates to consumer view (#180)
* Calculate rate of consumption in table * Add graph for consumer rate * fix bug in label overflow * add graph for producer rate * Add lag graph * resolve selectors * add totals row * reduce rolling average window * update changelog
1 parent 67fa428 commit 86e6a92

File tree

9 files changed

+400
-24
lines changed

9 files changed

+400
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
The format is based on [Keep a Changelog](http://keepachangelog.com/)
33
and this project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## 2.3.1 (UNRELEASED)
5+
## 2.4.0 (UNRELEASED)
6+
#### New Features
7+
- [PR-180]() Consumer Group inspector now shows average rate of consumption per partition.
8+
69
#### Bug Fixes
710
- [ISSUE-175](https://github.com/SourceLabOrg/kafka-webview/issues/175) Update multi-threaded consumers with unique consumerId [PR](https://github.com/SourceLabOrg/kafka-webview/pull/176).
811
- [PR-178](https://github.com/SourceLabOrg/kafka-webview/pull/178) @[lucrito](https://github.com/lucrito) fixed shebang in start.sh script. Thanks!
912
- [PR-179](https://github.com/SourceLabOrg/kafka-webview/pull/179) Streaming consumer now persists consumer state.
13+
- [PR-180](https://github.com/SourceLabOrg/kafka-webview/pull/180) Adds additional metrics (consume rate, producer rate, lag) and graphs to Consumer details page.
1014

1115
## 2.3.0 (06/19/2019)
1216
#### New Features

dev-cluster/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<artifactId>kafka-webview</artifactId>
77
<groupId>org.sourcelab</groupId>
8-
<version>2.3.1</version>
8+
<version>2.4.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>dev-cluster</artifactId>
13-
<version>2.3.1</version>
13+
<version>2.4.0</version>
1414

1515
<!-- Require Maven 3.3.9 -->
1616
<prerequisites>

kafka-webview-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.sourcelab</groupId>
77
<artifactId>kafka-webview</artifactId>
8-
<version>2.3.1</version>
8+
<version>2.4.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<artifactId>kafka-webview-plugin</artifactId>

kafka-webview-ui/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<artifactId>kafka-webview</artifactId>
77
<groupId>org.sourcelab</groupId>
8-
<version>2.3.1</version>
8+
<version>2.4.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<artifactId>kafka-webview-ui</artifactId>
12-
<version>2.3.1</version>
12+
<version>2.4.0</version>
1313

1414
<!-- Module Description and Ownership -->
1515
<name>Kafka WebView UI</name>

kafka-webview-ui/src/main/frontend/js/app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,20 @@ var DateTools = {
444444

445445
return year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sec + DateTools.formatTz(myDate);
446446
},
447+
displayTimeOnly: function(timestampMs) {
448+
// Adjusts timestamp into local timezone and locate
449+
var myDate = new Date(timestampMs);
450+
451+
var hour = myDate.getHours();
452+
var min = myDate.getMinutes();
453+
var sec = myDate.getSeconds();
454+
455+
hour = (hour < 10 ? "0" : "") + hour;
456+
min = (min < 10 ? "0" : "") + min;
457+
sec = (sec < 10 ? "0" : "") + sec;
458+
459+
return hour + ':' + min + ':' + sec;
460+
},
447461
formatTz: function(date) {
448462
var timezone_offset_min = date.getTimezoneOffset(),
449463
offset_hrs = parseInt(Math.abs(timezone_offset_min/60)),

kafka-webview-ui/src/main/java/org/sourcelab/kafka/webview/ui/manager/kafka/KafkaOperations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.kafka.clients.admin.ConfigEntry;
3131
import org.apache.kafka.clients.admin.CreateTopicsResult;
3232
import org.apache.kafka.clients.admin.DeleteConsumerGroupsResult;
33-
import org.apache.kafka.clients.admin.DeleteTopicsOptions;
3433
import org.apache.kafka.clients.admin.DeleteTopicsResult;
3534
import org.apache.kafka.clients.admin.DescribeConfigsResult;
3635
import org.apache.kafka.clients.admin.DescribeConsumerGroupsResult;
@@ -506,7 +505,8 @@ public ConsumerGroupOffsetsWithTailPositions getConsumerGroupOffsetsWithTailOffs
506505
return new ConsumerGroupOffsetsWithTailPositions(
507506
consumerGroupId,
508507
consumerGroupOffsets.getTopic(),
509-
offsetsWithPartitions
508+
offsetsWithPartitions,
509+
System.currentTimeMillis()
510510
);
511511
}
512512

kafka-webview-ui/src/main/java/org/sourcelab/kafka/webview/ui/manager/kafka/dto/ConsumerGroupOffsetsWithTailPositions.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ public class ConsumerGroupOffsetsWithTailPositions {
4141
private final String consumerId;
4242
private final String topic;
4343
private final Map<Integer, PartitionOffsetWithTailPosition> offsetMap;
44+
private final long timestamp;
4445

4546
/**
4647
* Constructor.
4748
* @param consumerId id of consumer group.
4849
* @param topic name of the topic.
4950
* @param offsets details about each partition and offset.
51+
* @param timestamp Timestamp offsets were retrieved.
5052
*/
5153
public ConsumerGroupOffsetsWithTailPositions(
5254
final String consumerId,
5355
final String topic,
54-
final Iterable<PartitionOffsetWithTailPosition> offsets
55-
) {
56+
final Iterable<PartitionOffsetWithTailPosition> offsets,
57+
final long timestamp) {
5658
this.consumerId = consumerId;
5759
this.topic = topic;
60+
this.timestamp = timestamp;
5861

5962
final Map<Integer, PartitionOffsetWithTailPosition> copiedMap = new HashMap<>();
6063
for (final PartitionOffsetWithTailPosition offset : offsets) {
@@ -74,6 +77,10 @@ public String getTopic() {
7477
return topic;
7578
}
7679

80+
public long getTimestamp() {
81+
return timestamp;
82+
}
83+
7784
/**
7885
* Marked private to keep from being serialized in responses.
7986
*/
@@ -143,6 +150,7 @@ public String toString() {
143150
return "ConsumerGroupOffsetsWithTailPositions{"
144151
+ "consumerId='" + consumerId + '\''
145152
+ ", topic='" + topic + '\''
153+
+ ", timestamp='" + timestamp + '\''
146154
+ ", offsetMap=" + offsetMap
147155
+ '}';
148156
}

0 commit comments

Comments
 (0)