Skip to content

Commit b0430c5

Browse files
committed
fix: add checking + indicator for heartbeat
1 parent 35fb3eb commit b0430c5

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/src/components/Clusters.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
shards.sort((a, b) => a.shard_id - b.shard_id);
4242
4343
shards.forEach((s) => {
44-
if(!clusters[s.cluster_id]) clusters[s.cluster_id] = <Cluster>{cluster_id: s.cluster_id, avg_latency: 0, up: true, status: "healthy", shards: []};
44+
if(!clusters[s.cluster_id]) clusters[s.cluster_id] = <Cluster>{cluster_id: s.cluster_id, avg_latency: 0, up: true, shards_down: 0, status: "healthy", shards: []};
4545
clusters[s.cluster_id].shards.push(s);
4646
if(s.up){
4747
shards_up++;
@@ -51,12 +51,16 @@
5151
shards_total = shards.length;
5252
avg_latency = Math.floor(avg_latency/shards_up);
5353
54+
const fiveMinsAgo = Date.now() - (5*60*1000);
5455
clusters.forEach((c)=>{
5556
let l = 0;
5657
c.shards.forEach((s)=>{
5758
l+=s.latency;
5859
59-
if(!s.up) s.status = "down";
60+
if(!s.up || s.last_heartbeat.getTime() < fiveMinsAgo) {
61+
s.status = "down";
62+
c.shards_down++;
63+
}
6064
else if (s.latency < 300) s.status = "healthy";
6165
else if (s.latency < 600) s.status = "degraded";
6266
else s.status = "severe";
@@ -161,6 +165,9 @@
161165
<div class="cluster-ctr flex flex-wrap flex-row py-6 justify-start">
162166
{#each clusters as cluster}
163167
<button class="cluster aspect-square tooltip indicator {cluster.status}" on:click={()=>{showClusterHandler(cluster.cluster_id)}}>
168+
{#if cluster.shards_down > 0}
169+
<span class="indicator-item status status-error"></span>
170+
{/if}
164171
{cluster.cluster_id}
165172
<div class="tooltip-content">
166173
avg latency: {cluster.avg_latency}

frontend/src/lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Cluster {
1212
cluster_id: number;
1313
avg_latency: number;
1414
up: boolean;
15+
shards_down: number;
1516
status: string;
1617
shards: Shard[];
1718
}

0 commit comments

Comments
 (0)