This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 5273e2ad78 Added msg count endpoint and badge (#6373)
5273e2ad78 is described below
commit 5273e2ad782456a94277f4857577f0c6dfd2cbbe
Author: Dave Marion <[email protected]>
AuthorDate: Tue May 19 16:56:39 2026 -0400
Added msg count endpoint and badge (#6373)
Adds a badge containing the count of critical or
high messages to the Messages link in the NavBar.
If the number of critical messages is > 0, then the
badge is red with the number of critical messages.
Otherwise, if there are high messages, then the
badge is yellow with the number of those messages.
Added an API endpoint to return the underlying counts
which does not use the same query parameters that are
used with the switches. This means that counts will reflect
messages that may not be seen on the messages page
if the user has a switch turned off. This will allow for users
to be notified that there are messages that they might not
be seeing.
---
.../apache/accumulo/monitor/next/Endpoints.java | 9 +++++++
.../accumulo/monitor/next/SystemInformation.java | 27 +++++++++++++++++++
.../accumulo/monitor/resources/js/functions.js | 9 +++++++
.../apache/accumulo/monitor/resources/js/navbar.js | 31 ++++++++++++++++++++++
.../apache/accumulo/monitor/templates/navbar.ftl | 2 +-
5 files changed, 77 insertions(+), 1 deletion(-)
diff --git
a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java
index 72dfc4a136..f5719637b2 100644
---
a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java
+++
b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import jakarta.inject.Inject;
@@ -448,6 +449,14 @@ public class Endpoints {
public record Message(String priority, String category, String message) {
}
+ @GET
+ @Path("message/counts")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Description("Returns count of messages by priority")
+ public Map<MessagePriority,AtomicLong> getMessageCounts() {
+ return
monitor.getInformationFetcher().getSummaryForEndpoint().getMessageCounts();
+ }
+
@GET
@Path("messages")
@Produces(MediaType.APPLICATION_JSON)
diff --git
a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java
index e5d7491f58..7700e1d6f6 100644
---
a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java
+++
b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java
@@ -521,6 +521,8 @@ public class SystemInformation {
private final Map<MessagePriority,Map<MessageCategory,Set<String>>> messages
=
new EnumMap<>(MessagePriority.class);
+ private final EnumMap<MessagePriority,AtomicLong> messageCounts =
+ new EnumMap<>(MessagePriority.class);
private final Set<String> configuredCompactionResourceGroups =
ConcurrentHashMap.newKeySet();
@@ -538,6 +540,9 @@ public class SystemInformation {
this.ctx = ctx;
this.rgLongRunningCompactionSize =
this.ctx.getConfiguration().getCount(Property.MONITOR_LONG_RUNNING_COMPACTION_LIMIT);
+ for (MessagePriority p : MessagePriority.values()) {
+ messageCounts.put(p, new AtomicLong(0));
+ }
}
public void clear() {
@@ -570,6 +575,7 @@ public class SystemInformation {
componentStatuses.clear();
managerGoalState = null;
serverMetricsView.clear();
+ messageCounts.clear();
}
public void addMessage(MessagePriority pri, MessageCategory cat, String msg)
{
@@ -582,6 +588,22 @@ public class SystemInformation {
.getOrDefault(cat, new HashSet<String>()).removeIf(s ->
s.contains(part));
}
+ private void computeMessageCounts() {
+ for (MessagePriority pri : MessagePriority.values()) {
+ long count = 0;
+ Map<MessageCategory,Set<String>> cats = messages.get(pri);
+ if (cats != null) {
+ for (MessageCategory cat : MessageCategory.values()) {
+ Set<String> msgs = cats.get(cat);
+ if (msgs != null) {
+ count += msgs.size();
+ }
+ }
+ }
+ messageCounts.get(pri).set(count);
+ }
+ }
+
private void updateAggregates(final MetricResponse response,
final Map<Id,CumulativeDistributionSummary> total,
final Map<String,Map<Id,CumulativeDistributionSummary>> rg) {
@@ -1181,6 +1203,7 @@ public class SystemInformation {
}
}
deploymentOverview = DeploymentOverview.fromSummary(deployment, timestamp);
+ computeMessageCounts();
}
public Set<String> getResourceGroups() {
@@ -1352,6 +1375,10 @@ public class SystemInformation {
return this.messages;
}
+ public Map<MessagePriority,AtomicLong> getMessageCounts() {
+ return this.messageCounts;
+ }
+
public long getTimestamp() {
return this.timestamp.get();
}
diff --git
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
index 093d2d1d75..15adaf0397 100644
---
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
+++
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
@@ -40,6 +40,7 @@ const RUNNING_COMPACTIONS_BY_GROUP =
'runningCompactionsByGroup';
const AUTO_REFRESH_KEY = 'auto-refresh';
const MESSAGE_CATEGORIES = 'messageCategories';
const MESSAGES = 'messages';
+const MESSAGE_COUNTS = 'messageCounts'
const RECOVERY = 'recovery';
// Override Length Menu options for dataTables
@@ -547,6 +548,14 @@ function getMessageCategories() {
return getJSONForTable(REST_V2_PREFIX + '/message/categories',
MESSAGE_CATEGORIES);
}
+/**
+ * REST GET call for /message/counts
+ * store it on a sessionStorage variable
+ */
+function getMessageCounts() {
+ return getJSONForTable(REST_V2_PREFIX + '/message/counts', MESSAGE_COUNTS);
+}
+
/**
* REST GET call for /messages,
* results are not stored in session as this
diff --git
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
index 5a55271151..83d3b5aace 100644
---
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
+++
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js
@@ -152,6 +152,7 @@ $(function () {
updateDarkThemeSwitch();
updateMessagePriorities();
refreshSidebar();
+ refreshMessageBadge();
categories = getStoredArray(MESSAGE_CATEGORIES);
if (categories.length === 0) {
@@ -178,6 +179,7 @@ function refreshSidebar() {
*/
function refreshNavBar() {
refreshSidebar();
+ refreshMessageBadge();
}
/**
@@ -235,6 +237,35 @@ function updateDarkThemeSwitch() {
});
}
+/**
+ * Updates the badge on the Messages label on the Nav Bar
+ */
+function refreshMessageBadge() {
+ getMessageCounts().then(function () {
+
+ var messageAnchor = $('#message-anchor');
+
+ var msgCounts = getStoredJson(MESSAGE_COUNTS, {
+ "Critical": 0,
+ "High": 0,
+ "Info": 0
+ });
+ var critMsgCount = msgCounts.Critical;
+ var highMsgCount = msgCounts.High;
+
+ messageAnchor.find('span').remove();
+
+ if (critMsgCount > 0) {
+ messageAnchor.append('<span class="badge position-relative top-0 start-0
translate-middle-y rounded-pill bg-danger">' +
+ critMsgCount + '</span>');
+ } else if (highMsgCount > 0) {
+ messageAnchor.append(
+ '<span class="badge position-relative top-0 start-0 translate-middle-y
rounded-pill bg-warning">' +
+ highMsgCount + '</span>');
+ }
+ });
+}
+
/**
* Update the High and Info Message Category Switches
*/
diff --git
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/navbar.ftl
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/navbar.ftl
index f1bde79ce5..841c3f44d0 100644
---
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/navbar.ftl
+++
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/navbar.ftl
@@ -62,7 +62,7 @@
</ul>
</li>
<li>
- <a class="nav-link" aria-current="page"
href="messages">Messages</a>
+ <a id="message-anchor" class="nav-link" aria-current="page"
href="messages">Messages</a>
</li>
<li class="dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown"