-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backend jmx metrics #64
Conversation
@@ -303,14 +358,10 @@ components: | |||
type: integer | |||
topicCount: | |||
type: integer | |||
bytesInPerSec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep these params here
kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java
Outdated
Show resolved
Hide resolved
|
||
public Map<String, Number> getJmxTrafficMetrics(int jmxPort, String jmxHost, String metricName) { | ||
private Map<String, Object> getJmxMetric(int jmxPort, String jmxHost, String canonicalName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why object here?
String jmxUrl = JMX_URL + jmxHost + ":" + jmxPort + "/" + JMX_SERVICE_TYPE; | ||
Map<String, Number> result = new HashMap<>(); | ||
|
||
Map<String, Object> resultAttr = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to collect metrics once, instead of doing it cluster-wide and then per broker
On my way.
…On 2 Jul 2020, 09:48 +0300, German Osin ***@***.***>, wrote:
@germanosin requested changes on this pull request.
In kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml:
> @@ -268,6 +273,61 @@ paths:
schema:
$ref: '#/components/schemas/ConsumerGroupDetails'
+# /api/clusters/{clusterName}/brokers/{brokerId}/metrics/{canonicalName}:
please clean up
In kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java:
>
- public Map<String, Number> getJmxTrafficMetrics(int jmxPort, String jmxHost, String metricName) {
+ private Map<String, Object> getJmxMetric(int jmxPort, String jmxHost, String canonicalName) {
Why object here?
In kafka-ui-api/src/main/java/com/provectus/kafka/ui/cluster/util/JmxClusterUtil.java:
> String jmxUrl = JMX_URL + jmxHost + ":" + jmxPort + "/" + JMX_SERVICE_TYPE;
- Map<String, Number> result = new HashMap<>();
+
+ Map<String, Object> resultAttr = new HashMap<>();
I think it's better to collect metrics once, instead of doing it cluster-wide and then per broker
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
.flatMapIterable(nodes -> nodes) | ||
.map(broker -> { | ||
var jmx = getJmxMetric(clusterName, broker); | ||
Map<Integer, InternalBrokerMetrics> result = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map.of ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove package-lock from commit
}) | ||
.collectList() | ||
.map(s -> { var brokerMetrics = ClusterUtil.toSingleMap(s.stream()); | ||
return internalClusterMetrics.toBuilder().internalBrokerMetrics(brokerMetrics).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it one line
.internalBrokerMetrics((brokers.stream().map(Node::id).collect(Collectors.toMap(k -> k, v -> InternalBrokerMetrics.builder().build())))) | ||
.bytesOutPerSec(bytesOutPerSec) | ||
.bytesInPerSec(bytesInPerSec); | ||
.internalBrokerMetrics((brokers.stream().map(Node::id).collect(Collectors.toMap(k -> k, v -> InternalBrokerMetrics.builder().build())))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you miss something here?
collect(Collectors.toMap(k -> k, v -> InternalBrokerMetrics.builder().build())))
brokerMetrics.setJmxMetrics(s.getInternalBrokerMetrics().get(id).getJmxMetrics()); | ||
brokerMetrics.setSegmentZise(Long.valueOf(s.getSegmentSize()).intValue()); | ||
return brokerMetrics; | ||
}).orElseThrow()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty mono?
jmxMetrics.forEach(j -> { | ||
JmxMetric metric = new JmxMetric(); | ||
metric.setCanonicalName(j.getCanonicalName()); | ||
metric.setValue(getJmxMetric(jmxPort, jmxHost, j.getCanonicalName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks strange
@@ -72,4 +99,12 @@ private void closeConnectionExceptionally(String url, JMXConnector srv) { | |||
log.error("Cannot invalidate object in pool, {}", url); | |||
} | |||
} | |||
|
|||
public static BigDecimal metricValueSum(Number value1, Number value2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up
return getOrCreateAdminClient(cluster) | ||
.flatMap( | ||
ac -> getClusterMetrics(ac.getAdminClient()) | ||
.flatMap(i -> fillJmxMetrics(i, cluster.getName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can pass adminclient to method
|
||
public List<JmxMetric> getJmxMetric(String clusterName, Node node) { | ||
return clustersStorage.getClusterByName(clusterName) | ||
.map(c -> jmxClusterUtil.getJmxMetrics(c.getJmxPort(), node.host())).orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty list better here
…rsec keywords in canonicalname
return internalClusterMetrics.getInternalBrokerMetrics().values().stream() | ||
.map(c -> | ||
c.getJmxMetrics().stream() | ||
.filter(j -> StringUtils.containsIgnoreCase(j.getCanonicalName(), "num") || StringUtils.containsIgnoreCase(j.getCanonicalName(), "persec")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to constants and array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's set list of metrics we could rollup
.filter(j -> StringUtils.containsIgnoreCase(j.getCanonicalName(), "num") || StringUtils.containsIgnoreCase(j.getCanonicalName(), "persec")) | ||
.map(j -> j.getValue().entrySet().stream() | ||
.map(e -> Pair.of(j.getCanonicalName() + "+" + e.getKey(), e.getValue())) | ||
.collect(Collectors.toList())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flatmap stream?
jmx.setCanonicalName(c.getKey()); | ||
jmx.setValue(Map.of(c.getValue().getKey(), c.getValue().getValue())); | ||
return jmx; | ||
}).collect(Collectors.groupingBy(JmxMetric::getCanonicalName, Collectors.toList())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reduce on groupingby
c.getJmxMetrics().stream() | ||
.filter(j -> StringUtils.containsIgnoreCase(j.getCanonicalName(), "num") || StringUtils.containsIgnoreCase(j.getCanonicalName(), "persec")) | ||
.map(j -> j.getValue().entrySet().stream() | ||
.map(e -> Pair.of(j.getCanonicalName() + "+" + e.getKey(), e.getValue())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think how to improve all these key transformations
type: object | ||
additionalProperties: | ||
type: number | ||
jmxMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's name it metrics, not a jmx metrics
$ref: '#/components/schemas/ConsumerTopicPartitionDetail' | ||
|
||
JmxMetric: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics
* Start doing endpoint for jmx metrics * Added endpoint for getting jmx metric per broker * Cluster jmx metrics sum endpoit added * Added endpoints for cluster metrics and broker metrics * Cleared some code * Fixed jmxmetrics names * Changed to all values in metrics * Removed redundant imports * Renamed param constant * Changed to calculate brokers and clusters metrics in one place * Removed redundant imports * Fixed some mistakes * Replaced multiple method usage into single * Fixed mulptiple call * Removed cluster level metrics, now only broker-level metrics in cluster * Just small fixes * removed redundant variable * Renamed method for cluster level metrics * Fixed after PR and added sum for number cluster metrics by num and persec keywords in canonicalname * Added metricdto object * Added list of metrics to enum * Renames and optimizings * Renamed jmxmetrics objects param to metrics Co-authored-by: Roman Nedzvetskiy <roman@Romans-MacBook-Pro.local>
WIP