Skip to content
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

Display Broker and Brokerset Information in Orion UI #315

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,26 @@ public class NodeInfo implements Serializable {
private Map<String, String> agentSettings;
private Map<String, String> environment;
private Set<String> brokersets = new HashSet<>();
/**
* Save the broker status in printable format (string)
*/
private Map<String, String> brokerStatus;
/**
* Save the broker status in raw format (number)
*/
private Map<String, Double> rawBrokerStatus;
/**
* @param rawBrokerStatus
*/
public void setRawBrokerStatus(Map<String, Double> rawBrokerStatus) {
this.rawBrokerStatus = rawBrokerStatus;
}
/**
* @return the rawBrokerStatus
*/
public Map<String, Double> getRawBrokerStatus() {
return rawBrokerStatus;
}
/**
* @param brokerStatus
*/
Expand Down Expand Up @@ -202,15 +221,26 @@ public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "NodeInfo [nodeId=" + nodeId + ", hostname=" + hostname + ", ip=" + ip + ", clusterId="
+ clusterId + ", servicePort=" + servicePort + ", localtime="
+ localtime + ", rack=" + rack + ", serviceInfo=" + serviceInfo + ", agentSettings="
+ agentSettings + ", environment=" + environment + "]";
return String.format(
"NodeInfo [timestamp=%d, nodeId=%s, hostname=%s, ip=%s, clusterId=%s, servicePort=%d, " +
"localtime=%d, rack=%s, nodeType=%s, serviceInfo=%s, agentSettings=%s, environment=%s, brokersets=%s, " +
"brokerStatus=%s, rawBrokerStatus=%s]",
timestamp,
nodeId,
hostname,
ip,
clusterId,
servicePort,
localtime,
rack,
nodeType,
serviceInfo,
agentSettings,
environment,
brokersets,
brokerStatus,
rawBrokerStatus);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.pinterest.orion.core.automation.sensor.kafka;

import com.pinterest.orion.core.kafka.KafkaCluster;

public class BrokerMetricsSensor extends KafkaSensor {

@Override
public String getName() {
return "BrokerMetricsSensor";
}

@Override
public void sense(KafkaCluster cluster) throws Exception {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ public void sense(KafkaCluster cluster) throws Exception {
brokersetState.addBrokerRange(Arrays.asList(start, end));
}
brokersetState.setBrokerIds(new ArrayList<>(brokerIds));
try {
updateBrokersetStateWithMetrics(cluster, brokersetState, brokerIds);
} catch (Exception e) {
logger.warning(
String.format(
"Failed to update brokerset state with metrics for brokerset %s in cluster %s. Error: %s",
brokersetAlias,
cluster.getName(),
e.getMessage()));
}
brokersetStateMap.put(brokersetAlias, brokersetState);
if (invalidBrokerset) {
handleInvalidBrokerset(brokersetAlias, cluster.getName());
Expand All @@ -95,6 +105,19 @@ public void sense(KafkaCluster cluster) throws Exception {
}
}

/**
* Update brokerset state with metrics.
* This method should be overridden by subclasses to update brokerset state with metrics.
* @param cluster Kafka cluster.
* @param brokersetState Brokerset state to update. It has state fields and raw metrics fields to update.
* @param brokerIds Broker ids in the brokerset.
*/
protected void updateBrokersetStateWithMetrics(
KafkaCluster cluster,
BrokersetState brokersetState,
Set<String> brokerIds) {
}

@Override
public String getName() {
return "BrokersetStateSensor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class BrokersetState {
/**
* The brokersetAlias is the alias of the brokerset.
*/
private String brokersetAlias;
/**
* The instanceType is the type of the brokerset.
*/
private String instanceType;
/**
* The brokersetRanges are the ranges of brokerset that are in the brokerset.
* The brokersetRanges are obtained from the brokerset configuration file.
Expand All @@ -19,6 +24,14 @@ public class BrokersetState {
* The brokerIds are obtained from the cluster state.
*/
private List<String> brokerIds = new ArrayList<>();
/**
* Save the broker status in printable format (string).
*/
private Map<String, Double> rawBrokersetStatus;
/**
* Save the broker status in raw format (number).
*/
private Map<String, String> brokersetStatus;
/**
* The constructor of BrokersetState.
* @param brokersetAlias
Expand Down Expand Up @@ -108,4 +121,22 @@ public List<String> getBrokerIds() {
public void setBrokerIds(List<String> brokerIds) {
this.brokerIds = brokerIds;
}
public void setRawBrokersetStatus(Map<String, Double> rawBrokersetStatus) {
this.rawBrokersetStatus = rawBrokersetStatus;
}
public Map<String, Double> getRawBrokersetStatus() {
return rawBrokersetStatus;
}
public void setBrokersetStatus(Map<String, String> brokersetStatus) {
this.brokersetStatus = brokersetStatus;
}
public Map<String, String> getBrokersetStatus() {
return brokersetStatus;
}
public void setInstanceType(String instanceType) {
this.instanceType = instanceType;
}
public String getInstanceType() {
return instanceType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const routes = [
function getStatsData(clusterId, rawData) {
let brokersetStats = [];
let brokersetData = rawData.brokersetData;
brokersetStats.push({ key: "Broker Count", value: brokersetData.size});
brokersetStats.push({ key: "Broker_Count", value: brokersetData.size});
let brokersetStatus = brokersetData.brokersetStatus;
if (brokersetStatus !== undefined && brokersetStatus !== null) {
for (let key of Object.keys(brokersetStatus)) {
brokersetStats.push({ key: key, value: brokersetStatus[key] });
}
}
return brokersetStats;
}

Expand Down Expand Up @@ -111,6 +117,10 @@ function getBrokersetInfoHeader(rawData, clusterId) {
let brokersetData = rawData.brokersetData;
let brokersetAlias = brokersetData.brokersetAlias;
let brokerCount = brokersetData.size;
let instanceType = "Unknown";
if (brokersetData.instanceType !== undefined && brokersetData.instanceType !== null) {
instanceType = brokersetData.instanceType;
}
return (
<Box my={2}>
<Grid container display="flex" alignItems="center" spacing={2}>
Expand All @@ -130,6 +140,14 @@ function getBrokersetInfoHeader(rawData, clusterId) {
label={brokerCount + " brokers"}
/>
</Grid>
<Grid item>
<Chip
variant="outlined"
color="primary"
size="small"
label={instanceType}
/>
</Grid>
</Grid>
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,37 @@ export default function Brokersets(props) {
}
let columns = [
{ title: "Name", field: "brokersetAlias" },
{ title: "Broker Count", field: "brokerCount" }
{ title: "Broker Count", field: "brokerCount" },
{ title: "Max CPU Usage 7D", field: "maxCpuUsage7Day" },
{ title: "Max Disk Usage 7D", field: "maxDiskUsage7Day" },
{ title: "Updated Time", field: "timestamp" }
]
let clusterId = props.cluster.clusterId;
let brokersetToRowValuesMap = {};
for (let brokerset of brokersets) {
let brokersetAlias = brokerset.brokersetAlias;
let maxCpuUsage7Day = "N/A";
let maxDiskUsage7Day = "N/A";
let timestamp = "N/A"
if (brokerset.brokersetStatus) {
if (brokerset.brokersetStatus["CPU_Usage_Max_All_Brokers_7Days"] !== undefined) {
maxCpuUsage7Day = brokerset.brokersetStatus["CPU_Usage_Max_All_Brokers_7Days"];
}
if (brokerset.brokersetStatus["Disk_Usage_Max_All_Brokers_7Days"] !== undefined) {
maxDiskUsage7Day = brokerset.brokersetStatus["Disk_Usage_Max_All_Brokers_7Days"];
}
if (brokerset.brokersetStatus["Short_Timestamp"] !== undefined) {
timestamp = brokerset.brokersetStatus["Short_Timestamp"];
}
}
brokersetToRowValuesMap[brokersetAlias] = {
"brokersetAlias": brokersetAlias,
"clusterId": clusterId,
"brokerCount": brokerset.size,
"brokersetData": brokerset
"brokersetData": brokerset,
"maxCpuUsage7Day": maxCpuUsage7Day,
"maxDiskUsage7Day": maxDiskUsage7Day,
"timestamp": timestamp
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ function getBrokersetColumns() {

function getBrokerStatsData(cluster, node) {
let brokerStatsData = [];
let brokerStats = node.currentNodeInfo.brokerStatus;
if (brokerStats === undefined || brokerStats === null) {
return brokerStatsData;
}
for (let [key, value] of Object.entries(brokerStats)) {
brokerStatsData.push({key: key, value: JSON.stringify(value)});
}
return brokerStatsData;
}

Expand Down
Loading