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

feature(ui): service/cluster information and status page #369

Merged
merged 21 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5358049
feat(ui) show information about monitor, gateway, brokers and their p…
nitram509 Feb 14, 2022
bf97ddc
feat(ui) implement auto-refresh of the status page
nitram509 Feb 14, 2022
f940e1e
chore(test): improve test of status page to detect missing DTO fields…
nitram509 Feb 15, 2022
3f6f1a4
fix(build) fix maven warning by defining explicit plugin version
nitram509 Feb 15, 2022
ff06c60
fix bean injection of BuildProperties and add some documentation
nitram509 Feb 15, 2022
4d73171
ignore JVM crash files
nitram509 Feb 15, 2022
2de520b
dropped broken test - superseeded by another test
nitram509 Feb 15, 2022
fae493c
Merge branch 'master' into feature/status-page
nitram509 Feb 24, 2022
178d657
drop built time and use package information
nitram509 Oct 5, 2022
7075837
Merge remote-tracking branch 'zeebe/main' into feature/status-page
nitram509 Oct 5, 2022
55621c7
remove toggle
nitram509 Oct 5, 2022
724672c
remove toggle, part2
nitram509 Oct 5, 2022
42f198d
remove toggle, part3
nitram509 Oct 5, 2022
fd87e7d
build manifest.mf to be able to get a version information
nitram509 Oct 5, 2022
96852c9
implement modal view for cluster status details and "healthy" indicat…
nitram509 Oct 5, 2022
729f7ab
build custom version info loader, because the former way did not work.
nitram509 Oct 5, 2022
13af17b
fix error handling, when manifest can't be read
nitram509 Oct 5, 2022
529bfd7
Merge branch 'main' into feature/status-page
nitram509 Dec 11, 2022
b94f6d9
Merge branch 'main' into feature/status-page
nitram509 Dec 11, 2022
951dbe9
fix NPE during startup
nitram509 Dec 11, 2022
2530dd8
remove unused header template not used anymore
nitram509 Dec 20, 2022
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ docs/book
docs/mdbook

hs_err*.log
replay_pid*.log
/data/
/metrics/
docker/**/*.jar
docker/**/*.jar
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,34 @@ type ```text``` in PostgreSQL. This type needs some special treatment.
you will see just some 5-digit numbers.\
**Solution**: you need to convert the large object like this\
```SELECT convert_from(lo_get(value_::oid), 'UTF8') FROM variable```

### Known Issue: Application Failed To Start, required bean 'BuildProperties' could not be found

If you're about to run the application locally (e.g. via IntelliJ 'run'),
you might run into the issue

```
***************************
APPLICATION FAILED TO START
***************************

Description:

Field buildProperties in io.zeebe.monitor.rest.ServiceStatusViewController required a bean of type 'org.springframework.boot.info.BuildProperties' that could not be found.
```

#### Solution

Simply compile the application via maven command.
```shell
mvn -DskipTests compile
```

#### Root cause

The Spring framework supports injecting build information at runtime.
This requires a file ```META-INF/build-info.properties``` to be present in the classpath.
This file is created by Maven during the compile phase, via ```spring-boot-maven-plugin``` (see pom.xml).
When using e.g. IntelliJ 'run' command, Maven is not used by default, to build the application,
and thus, the file is missing and the bean can't be created.
The error message is completely miss-leading.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,14 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
<execution>
<goals>
<goal>repackage</goal>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/io/zeebe/monitor/ZeebeSimpleMonitorApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
@EnableSpringDataWebSupport
public class ZeebeSimpleMonitorApp {

public static final String REPLACEMENT_CHARACTER_QUESTIONMARK = "\u2370"; // == ⍰ character

public static void main(final String... args) {
SpringApplication.run(ZeebeSimpleMonitorApp.class, args);
}
Expand All @@ -58,6 +60,9 @@ public Executor asyncExecutor() {
@Bean
public Mustache.Compiler configureFallbackValueForMissingVariablesInMustacheTemplates(
Mustache.TemplateLoader templateLoader) {
return Mustache.compiler().defaultValue("⍰").withLoader(templateLoader);
return Mustache.compiler()
.defaultValue(REPLACEMENT_CHARACTER_QUESTIONMARK)
.withLoader(templateLoader);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package io.zeebe.monitor.rest;

import io.camunda.zeebe.client.api.response.BrokerInfo;
import io.camunda.zeebe.client.api.response.PartitionInfo;
import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.monitor.rest.dto.BrokerDto;
import io.zeebe.monitor.rest.dto.PartitionInfoDto;
import io.zeebe.monitor.rest.dto.StatusDto;
import io.zeebe.monitor.zeebe.ZeebeStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

@Controller
public class ServiceStatusViewController extends AbstractViewController {

@Autowired private ZeebeStatusService zeebeStatusService;
@Autowired BuildProperties buildProperties;

@GetMapping("/views/service-status")
public String index(final Map<String, Object> model, final Pageable pageable) {
nitram509 marked this conversation as resolved.
Show resolved Hide resolved
addDefaultAttributesToModel(model);

final Topology topology = zeebeStatusService.getTopology();
model.put("status", toDto(topology, buildProperties));

return "service-status-view";
}

private StatusDto toDto(Topology topology, BuildProperties buildProperties) {
final StatusDto statusDto = new StatusDto();
statusDto.setClusterSize(topology.getClusterSize());
statusDto.setGatewayVersion(topology.getGatewayVersion());
statusDto.setPartitionsCount(topology.getPartitionsCount());
statusDto.setReplicationFactor(topology.getReplicationFactor());
statusDto.setSimpleMonitorVersion(buildProperties.getVersion());
nitram509 marked this conversation as resolved.
Show resolved Hide resolved
statusDto.setSimpleMonitorBuildTime(buildProperties.getTime().toString());
nitram509 marked this conversation as resolved.
Show resolved Hide resolved
for (BrokerInfo broker : topology.getBrokers()) {
final BrokerDto brokerDto = new BrokerDto();
brokerDto.setAddress(broker.getAddress());
brokerDto.setHost(broker.getHost());
brokerDto.setNodeId(broker.getNodeId());
brokerDto.setPort(broker.getPort());
brokerDto.setVersion(broker.getVersion());
for (PartitionInfo partition : broker.getPartitions()) {
final PartitionInfoDto partitionInfoDto = new PartitionInfoDto();
partitionInfoDto.setPartitionId(partition.getPartitionId());
partitionInfoDto.setRole(String.valueOf(partition.getRole()));
partitionInfoDto.setHealth(String.valueOf(partition.getHealth()));
partitionInfoDto.setLeader(partition.isLeader());
brokerDto.addPartitionInfo(partitionInfoDto);
}
statusDto.addBroker(brokerDto);
}
return statusDto;
}

}
61 changes: 61 additions & 0 deletions src/main/java/io/zeebe/monitor/rest/dto/BrokerDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.zeebe.monitor.rest.dto;

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

public class BrokerDto {
private int nodeId;
private String address;
private String host;
private int port;
private String version;
private List<PartitionInfoDto> partitionInfos = new ArrayList<>();

public void setAddress(String address) {
this.address = address;
}

public String getAddress() {
return address;
}

public void setHost(String host) {
this.host = host;
}

public String getHost() {
return host;
}

public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}

public int getNodeId() {
return nodeId;
}

public void setPort(int port) {
this.port = port;
}

public int getPort() {
return port;
}

public void setVersion(String version) {
this.version = version;
}

public String getVersion() {
return version;
}

public void addPartitionInfo(PartitionInfoDto partitionInfoDto) {
this.partitionInfos.add(partitionInfoDto);
}

public List<PartitionInfoDto> getPartitionInfos() {
return partitionInfos;
}
}
41 changes: 41 additions & 0 deletions src/main/java/io/zeebe/monitor/rest/dto/PartitionInfoDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.zeebe.monitor.rest.dto;

public class PartitionInfoDto {

private int partitionId;
private String role;
private String health;
private boolean leader;

public void setPartitionId(int partitionId) {
this.partitionId = partitionId;
}

public int getPartitionId() {
return partitionId;
}

public void setRole(String role) {
this.role = role;
}

public String getRole() {
return role;
}

public void setHealth(String health) {
this.health = health;
}

public String getHealth() {
return health;
}

public void setLeader(boolean leader) {
this.leader = leader;
}

public boolean getLeader() {
return leader;
}
}
71 changes: 71 additions & 0 deletions src/main/java/io/zeebe/monitor/rest/dto/StatusDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package io.zeebe.monitor.rest.dto;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

public class StatusDto {
private String gatewayVersion;
private String simpleMonitorVersion;
private int clusterSize;
private int replicationFactor;
private int partitionsCount;
private List<BrokerDto> brokers = new ArrayList<>();
private String simpleMonitorBuildTime;

public void setClusterSize(int clusterSize) {
this.clusterSize = clusterSize;
}

public int getClusterSize() {
return clusterSize;
}

public void setGatewayVersion(String gatewayVersion) {
this.gatewayVersion = gatewayVersion;
}

public String getGatewayVersion() {
return gatewayVersion;
}

public void setReplicationFactor(int replicationFactor) {
this.replicationFactor = replicationFactor;
}

public int getReplicationFactor() {
return replicationFactor;
}

public void setPartitionsCount(int partitionsCount) {
this.partitionsCount = partitionsCount;
}

public int getPartitionsCount() {
return partitionsCount;
}

public void addBroker(BrokerDto brokerDto) {
this.brokers.add(brokerDto);
}

public List<BrokerDto> getBrokers() {
return brokers;
}

public void setSimpleMonitorVersion(String simpleMonitorVersion) {
this.simpleMonitorVersion = simpleMonitorVersion;
}

public String getSimpleMonitorVersion() {
return simpleMonitorVersion;
}

public void setSimpleMonitorBuildTime(String simpleMonitorBuildTime) {
this.simpleMonitorBuildTime = simpleMonitorBuildTime;
}

public String getSimpleMonitorBuildTime() {
return simpleMonitorBuildTime;
}
}
23 changes: 23 additions & 0 deletions src/main/java/io/zeebe/monitor/zeebe/ZeebeStatusService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.zeebe.monitor.zeebe;

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.Topology;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Component
public class ZeebeStatusService {

@Autowired private ZeebeClient zeebeClient;

public Topology getTopology() {
return zeebeClient.newTopologyRequest()
.requestTimeout(Duration.ofSeconds(5))
.send()
.join();
}


}
10 changes: 10 additions & 0 deletions src/main/resources/public/css/bootstrap4-toggle.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading