From e42cff3c1d50a9867bef81feae227d99cb4bcd5b Mon Sep 17 00:00:00 2001 From: Dom Garguilo Date: Mon, 25 Nov 2024 15:06:43 -0500 Subject: [PATCH] Remove logs from monitor --- assemble/conf/log4j2-service.properties | 10 - .../org/apache/accumulo/monitor/Monitor.java | 6 - .../monitor/rest/logs/LogResource.java | 75 ------ .../monitor/rest/logs/SanitizedLogEvent.java | 67 ----- .../monitor/rest/logs/SingleLogEvent.java | 38 --- .../rest/status/StatusInformation.java | 8 +- .../monitor/rest/status/StatusResource.java | 4 +- .../util/logging/AccumuloMonitorAppender.java | 253 ------------------ .../monitor/util/logging/RecentLogs.java | 84 ------ .../accumulo/monitor/view/WebViews.java | 17 -- .../monitor/resources/js/functions.js | 14 - .../accumulo/monitor/resources/js/navbar.js | 29 +- .../apache/accumulo/monitor/templates/log.ftl | 130 --------- .../accumulo/monitor/templates/navbar.ftl | 1 - 14 files changed, 8 insertions(+), 728 deletions(-) delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/LogResource.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SanitizedLogEvent.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SingleLogEvent.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/RecentLogs.java delete mode 100644 server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/log.ftl diff --git a/assemble/conf/log4j2-service.properties b/assemble/conf/log4j2-service.properties index 984c543da49..6c7983182b2 100644 --- a/assemble/conf/log4j2-service.properties +++ b/assemble/conf/log4j2-service.properties @@ -67,14 +67,6 @@ appender.audit.policies.size.size=512MB appender.audit.strategy.type = DefaultRolloverStrategy appender.audit.strategy.max = 10 -appender.monitor.type = AccumuloMonitor -appender.monitor.name = MonitorLog -appender.monitor.filter.threshold.type = ThresholdFilter -appender.monitor.filter.threshold.level = warn -#appender.monitor.async = true -#appender.monitor.maxThreads = 2 -#appender.monitor.queueSize = 1024 - logger.zookeeper.name = org.apache.zookeeper logger.zookeeper.level = error @@ -90,5 +82,3 @@ logger.accumulo.level = debug rootLogger.level = info rootLogger.appenderRef.console.ref = STDERR rootLogger.appenderRef.rolling.ref = LogFiles -rootLogger.appenderRef.monitor.ref = MonitorLog - diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java index f25aa8f545b..b53b162fdab 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java @@ -81,7 +81,6 @@ import org.apache.accumulo.monitor.rest.compactions.external.ExternalCompactionInfo; import org.apache.accumulo.monitor.rest.compactions.external.RunningCompactions; import org.apache.accumulo.monitor.rest.compactions.external.RunningCompactorDetails; -import org.apache.accumulo.monitor.util.logging.RecentLogs; import org.apache.accumulo.server.AbstractServer; import org.apache.accumulo.server.HighlyAvailableService; import org.apache.accumulo.server.ServerContext; @@ -615,7 +614,6 @@ public static class CompactionStats { private final Map tserverScans = new HashMap<>(); private final Map sserverScans = new HashMap<>(); private final Map allCompactions = new HashMap<>(); - private final RecentLogs recentLogs = new RecentLogs(); private final ExternalCompactionInfo ecInfo = new ExternalCompactionInfo(); private long scansFetchedNanos = System.nanoTime(); @@ -1038,10 +1036,6 @@ public boolean isActiveService() { return monitorInitialized.get(); } - public RecentLogs recentLogs() { - return recentLogs; - } - public Optional getCoordinatorHost() { return coordinatorHost; } diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/LogResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/LogResource.java deleted file mode 100644 index d7813f6cd78..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/LogResource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.logs; - -import java.util.List; - -import jakarta.inject.Inject; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; - -import org.apache.accumulo.monitor.Monitor; - -/** - * Responsible for generating a new log JSON object - * - * @since 2.0.0 - */ -@Path("/logs") -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -public class LogResource { - - @Inject - private Monitor monitor; - - /** - * Generates log event list as a JSON object - * - * @return log event array - */ - @GET - public List getRecentLogs() { - return monitor.recentLogs().getSanitizedEvents(); - } - - /** - * REST call to clear the logs - */ - @POST - @Path("clear") - public void clearLogs() { - monitor.recentLogs().clearEvents(); - } - - /** - * REST call to append a log message - * - * @since 2.1.0 - */ - @POST - @Path("append") - @Consumes(MediaType.APPLICATION_JSON) - public void append(SingleLogEvent event) { - monitor.recentLogs().addEvent(event); - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SanitizedLogEvent.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SanitizedLogEvent.java deleted file mode 100644 index 05faa00d5b7..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SanitizedLogEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.logs; - -/** - * A log event type (with counts) suitable for display on the monitor at the REST endpoint, - * {@link LogResource#getRecentLogs()}. - */ -public class SanitizedLogEvent { - - // Variable names become JSON keys - public final long timestamp; - public final String application; - public final String logger; - public final String level; - public final String message; - public final String stacktrace; - public final int count; - - public SanitizedLogEvent(SingleLogEvent event, int count) { - this.timestamp = event.timestamp; - this.application = sanitize(event.application); - this.logger = sanitize(event.logger); - this.level = sanitize(event.level); - String msg = sanitize(event.message); - // truncate long messages - if (msg.length() > 300) { - msg = msg.substring(0, 300).trim(); - } - this.message = msg; - this.stacktrace = sanitize(event.stacktrace); - this.count = count; - } - - private String sanitize(String s) { - if (s == null) { - return null; - } - StringBuilder text = new StringBuilder(); - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - int type = Character.getType(c); - boolean notPrintable = type == Character.UNASSIGNED || type == Character.LINE_SEPARATOR - || type == Character.NON_SPACING_MARK || type == Character.PRIVATE_USE; - text.append(notPrintable ? '?' : c); - } - return text.toString().trim().replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", - ">"); - } - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SingleLogEvent.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SingleLogEvent.java deleted file mode 100644 index 4bc9fc81a90..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/SingleLogEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.logs; - -import org.apache.accumulo.monitor.util.logging.AccumuloMonitorAppender; - -/** - * A basic POJO to serialize single log events as JSON for transmitting from the - * {@link AccumuloMonitorAppender} to the REST endpoint at - * {@link LogResource#append(SingleLogEvent)}. - */ -public class SingleLogEvent { - - // Variable names become JSON keys - public long timestamp; - public String application; - public String logger; - public String level; - public String message; - public String stacktrace; - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java index c55e2876b7d..867fb1d2bb5 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java @@ -31,8 +31,6 @@ public class StatusInformation { public String tServerStatus = null; public String coordinatorStatus = null; - public Integer logNumber = 0; - public boolean logsHaveError = false; public Integer problemNumber = 0; public StatusInformation() {} @@ -44,18 +42,14 @@ public StatusInformation() {} * @param gcStatus Status for the GC * @param tServerStatus Status for the tserver * @param coordinatorStatus Status for the Compaction Coordinator - * @param logNumber Number of log reports - * @param logsHaveError Check if log reports include errors * @param problemNumber Number of problems per table */ public StatusInformation(String managerStatus, String gcStatus, String tServerStatus, - String coordinatorStatus, Integer logNumber, boolean logsHaveError, Integer problemNumber) { + String coordinatorStatus, Integer problemNumber) { this.managerStatus = managerStatus; this.gcStatus = gcStatus; this.tServerStatus = tServerStatus; this.coordinatorStatus = coordinatorStatus; - this.logNumber = logNumber; - this.logsHaveError = logsHaveError; this.problemNumber = problemNumber; } diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java index 775f612a61d..e94f5e2148f 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java @@ -97,7 +97,7 @@ public StatusInformation getTables() { } return new StatusInformation(managerStatus.toString(), gcStatus.toString(), - tServerStatus.toString(), coordinatorStatus.toString(), monitor.recentLogs().numEvents(), - monitor.recentLogs().eventsIncludeErrors(), monitor.getProblemSummary().entrySet().size()); + tServerStatus.toString(), coordinatorStatus.toString(), + monitor.getProblemSummary().entrySet().size()); } } diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java deleted file mode 100644 index 7619e49bd2c..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.util.logging; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.accumulo.core.util.LazySingletons.GSON; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpRequest.BodyPublishers; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandlers; -import java.util.Optional; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Supplier; - -import org.apache.accumulo.core.Constants; -import org.apache.accumulo.core.conf.SiteConfiguration; -import org.apache.accumulo.core.fate.zookeeper.ZooCache.ZcStat; -import org.apache.accumulo.core.util.Pair; -import org.apache.accumulo.monitor.rest.logs.LogResource; -import org.apache.accumulo.monitor.rest.logs.SingleLogEvent; -import org.apache.accumulo.server.ServerContext; -import org.apache.logging.log4j.core.Appender; -import org.apache.logging.log4j.core.Core; -import org.apache.logging.log4j.core.Filter; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.appender.AbstractAppender; -import org.apache.logging.log4j.core.config.Property; -import org.apache.logging.log4j.core.config.plugins.Plugin; -import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; -import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -/** - * A custom Log4j2 Appender which follows the registered location of the active Accumulo monitor - * service, and forwards log messages to its log4j REST endpoint at - * {@link LogResource#append(SingleLogEvent)}. - */ -@Plugin(name = "AccumuloMonitor", category = Core.CATEGORY_NAME, - elementType = Appender.ELEMENT_TYPE, printObject = true) -public class AccumuloMonitorAppender extends AbstractAppender { - - @PluginBuilderFactory - public static Builder newBuilder() { - return new Builder(); - } - - public static class Builder extends AbstractAppender.Builder - implements org.apache.logging.log4j.core.util.Builder { - - @PluginBuilderAttribute - private boolean async = true; - - @PluginBuilderAttribute - private int queueSize = 1024; - - @PluginBuilderAttribute - private int maxThreads = 2; - - public Builder setAsync(boolean async) { - this.async = async; - return this; - } - - public boolean getAsync() { - return async; - } - - public Builder setQueueSize(int size) { - queueSize = size; - return this; - } - - public int getQueueSize() { - return queueSize; - } - - public Builder setMaxThreads(int maxThreads) { - this.maxThreads = maxThreads; - return this; - } - - public int getMaxThreads() { - return maxThreads; - } - - @Override - public AccumuloMonitorAppender build() { - return new AccumuloMonitorAppender(getName(), getFilter(), isIgnoreExceptions(), - getPropertyArray(), getQueueSize(), getMaxThreads(), getAsync()); - } - - } - - private final HttpClient httpClient; - private final Supplier> monitorLocator; - private final ThreadPoolExecutor executor; - private final boolean async; - private final int queueSize; - private final AtomicLong appends = new AtomicLong(0); - private final AtomicLong discards = new AtomicLong(0); - private final AtomicLong errors = new AtomicLong(0); - private final ConcurrentMap statusCodes = new ConcurrentSkipListMap<>(); - - private ServerContext context; - private String path; - private Pair> lastResult = new Pair<>(0L, Optional.empty()); - - private AccumuloMonitorAppender(final String name, final Filter filter, - final boolean ignoreExceptions, final Property[] properties, int queueSize, int maxThreads, - boolean async) { - super(name, filter, null, ignoreExceptions, properties); - - this.executor = async ? new ThreadPoolExecutor(0, maxThreads, 30, TimeUnit.SECONDS, - new LinkedBlockingQueue()) : null; - final var builder = HttpClient.newBuilder(); - this.httpClient = (async ? builder.executor(executor) : builder).build(); - this.queueSize = queueSize; - this.async = async; - - final var stat = new ZcStat(); - this.monitorLocator = () -> { - // lazily set up context/path - if (context == null) { - context = new ServerContext(SiteConfiguration.auto()); - path = context.getZooKeeperRoot() + Constants.ZMONITOR_HTTP_ADDR; - } - // get the current location from the cache - byte[] loc = context.getZooCache().get(path, stat); - Pair> last = lastResult; - if (stat.getMzxid() != last.getFirst()) { - // only create new objects if there's a change - last = new Pair<>(stat.getMzxid(), Optional.ofNullable(loc) - .map(bytes -> URI.create(new String(bytes, UTF_8) + "rest/logs/append"))); - lastResult = last; - } - return last.getSecond(); - }; - } - - private String getStats() { - return "discards:" + discards.get() + " errors:" + errors.get() + " appends:" + appends.get() - + " statusCodes:" + statusCodes; - } - - private void processResponse(HttpResponse response) { - var statusCode = response.statusCode(); - statusCodes.computeIfAbsent(statusCode, sc -> new AtomicLong()).getAndIncrement(); - if (statusCode >= 400 && statusCode < 600) { - error("Unable to send HTTP in appender [" + getName() + "]. Status: " + statusCode + " " - + getStats()); - } - } - - @Override - public void append(final LogEvent event) { - appends.getAndIncrement(); - monitorLocator.get().ifPresentOrElse(uri -> { - try { - var pojo = new SingleLogEvent(); - pojo.timestamp = event.getTimeMillis(); - pojo.application = System.getProperty("accumulo.application", "unknown"); - pojo.logger = event.getLoggerName(); - pojo.level = event.getLevel().name(); - pojo.message = event.getMessage().getFormattedMessage(); - pojo.stacktrace = throwableToStacktrace(event.getThrown()); - - String jsonEvent = GSON.get().toJson(pojo); - - var req = HttpRequest.newBuilder(uri).POST(BodyPublishers.ofString(jsonEvent, UTF_8)) - .setHeader("Content-Type", "application/json").build(); - - if (async) { - if (executor.getQueue().size() < queueSize) { - httpClient.sendAsync(req, BodyHandlers.discarding()).thenAccept(this::processResponse) - .exceptionally(e -> { - errors.getAndIncrement(); - error("Unable to send HTTP in appender [" + getName() + "] " + getStats(), event, - e); - return null; - }); - } else { - discards.getAndIncrement(); - error("Unable to send HTTP in appender [" + getName() + "]. Queue full. " + getStats()); - } - } else { - processResponse(httpClient.send(req, BodyHandlers.discarding())); - } - } catch (final Exception e) { - errors.getAndIncrement(); - error("Unable to send HTTP in appender [" + getName() + "] " + getStats(), event, e); - } - }, () -> { - discards.getAndIncrement(); - error("Unable to send HTTP in appender [" + getName() + "]. No monitor is running. " - + getStats()); - }); - } - - @Override - protected boolean stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState) { - if (changeLifeCycleState) { - setStopping(); - } - if (executor != null) { - executor.shutdown(); - } - return super.stop(timeout, timeUnit, changeLifeCycleState); - } - - @SuppressFBWarnings(value = "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE", - justification = "throwable is intended to be printed to output stream, to send to monitor") - private static String throwableToStacktrace(Throwable t) { - if (t == null) { - return null; - } - StringWriter writer = new StringWriter(); - t.printStackTrace(new PrintWriter(writer)); - return writer.toString(); - } - - @Override - public String toString() { - return "AccumuloMonitorAppender{name=" + getName() + ", state=" + getState() + '}'; - } - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/RecentLogs.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/RecentLogs.java deleted file mode 100644 index 6ca1543ea5c..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/RecentLogs.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.util.logging; - -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import org.apache.accumulo.monitor.rest.logs.LogResource; -import org.apache.accumulo.monitor.rest.logs.SanitizedLogEvent; -import org.apache.accumulo.monitor.rest.logs.SingleLogEvent; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; - -/** - * A recent logs cache for the monitor that holds log messages received from - * {@link AccumuloMonitorAppender} instances at the monitor's REST endpoint - * {@link LogResource#append(SingleLogEvent)} until retrieved at the REST endpoint - * {@link LogResource#getRecentLogs()} or cleared via the REST endpoint - * {@link LogResource#clearLogs()}. - */ -public class RecentLogs { - - private static final int MAX_LOGS = 50; - - private final Cache events = - Caffeine.newBuilder().maximumSize(MAX_LOGS).build(); - - /** - * Internal class for keeping the current count and most recent event that matches a given cache - * key (derived from the event's application, logger, level, and message fields). - */ - private static class DedupedEvent { - private final SingleLogEvent event; - private final AtomicInteger count; - - private DedupedEvent(SingleLogEvent event) { - this.event = event; - this.count = new AtomicInteger(); - } - } - - public void addEvent(SingleLogEvent event) { - String key = event.application + ":" + event.logger + ":" + event.level + ":" + event.message; - events.asMap().computeIfAbsent(key, k -> new DedupedEvent(event)).count.incrementAndGet(); - } - - public void clearEvents() { - events.invalidateAll(); - } - - public int numEvents() { - return events.asMap().size(); - } - - public boolean eventsIncludeErrors() { - return events.asMap().values().stream().anyMatch( - x -> x.event.level.equalsIgnoreCase("ERROR") || x.event.level.equalsIgnoreCase("FATAL")); - } - - public List getSanitizedEvents() { - return events.asMap().values().stream() - .map(ev -> new SanitizedLogEvent(ev.event, ev.count.get())).limit(MAX_LOGS) - .collect(Collectors.toList()); - } - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java index d508e09c534..802fd5bdec8 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java @@ -302,23 +302,6 @@ public Map getTables( return model; } - /** - * Returns log report template - * - * @return Log report model - */ - @GET - @Path("log") - @Template(name = "/default.ftl") - public Map getLogs() { - - Map model = getModel(); - model.put("title", "Recent Logs"); - model.put("template", "log.ftl"); - - return model; - } - /** * Returns problem report template * 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 e76197d5897..c836267c5df 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 @@ -444,20 +444,6 @@ function getTableServers(tableID) { return getJSONForTable('/rest/tables/' + tableID, 'tableServers'); } -/** - * REST GET call for the logs, stores it on a sessionStorage variable - */ -function getLogs() { - return getJSONForTable('/rest/logs', 'logs'); -} - -/** - * REST POST call to clear logs - */ -function clearLogs() { - doLoggedPostCall('/rest/logs/clear', refresh, false); -} - /** * REST POST call to clear all table problems * 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 efb98e72b83..fb464167562 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 @@ -119,24 +119,6 @@ function updateServerNotifications(statusData) { }); } -/** - * Updates the notification color for the recent logs icon within the debug dropdown - */ -function updateRecentLogsNotification(statusData) { - if (statusData.logNumber > 0) { - if (statusData.logsHaveError) { - updateElementStatus('recentLogsNotifications', STATUS.ERROR); - } else { - updateElementStatus('recentLogsNotifications', STATUS.WARN); - } - } else { - updateElementStatus('recentLogsNotifications', STATUS.OK); - } - // Number - const logNumber = statusData.logNumber > 99 ? '99+' : statusData.logNumber; - $('#recentLogsNotifications').html(logNumber); -} - /** * Updates the notification color for the table problems icon within the debug dropdown */ @@ -155,8 +137,8 @@ function updateTableProblemsNotification(statusData) { * Updates the notification color for the debug dropdown icon */ function updateDebugDropdownNotification(statusData) { - if (statusData.logNumber > 0 || statusData.problemNumber > 0) { - if (statusData.logsHaveError || statusData.problemNumber > 0) { + if (statusData.problemNumber > 0) { + if (statusData.problemNumber > 0) { updateElementStatus('errorsNotification', STATUS.ERROR); } else { updateElementStatus('errorsNotification', STATUS.WARN); @@ -165,8 +147,8 @@ function updateDebugDropdownNotification(statusData) { updateElementStatus('errorsNotification', STATUS.OK); } // Number - var totalNumber = statusData.logNumber + statusData.problemNumber > 99 ? - '99+' : statusData.logNumber + statusData.problemNumber; + var totalNumber = statusData.problemNumber > 99 ? + '99+' : statusData.problemNumber; $('#errorsNotification').html(totalNumber); } @@ -195,14 +177,13 @@ function refreshNavBar() { } /** - * Generates the sidebar notifications for servers and logs + * Generates the sidebar notifications for servers */ function refreshSideBarNotifications() { const statusData = sessionStorage?.status ? JSON.parse(sessionStorage.status) : undefined; updateServerNotifications(statusData); - updateRecentLogsNotification(statusData); updateTableProblemsNotification(statusData); updateDebugDropdownNotification(statusData); } diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/log.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/log.ftl deleted file mode 100644 index cfa131cbc30..00000000000 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/log.ftl +++ /dev/null @@ -1,130 +0,0 @@ -<#-- - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> - -

${title}

- - - - - - - - - - - - - - -
Logs
TimestampApplicationLoggerCountLevelMessageStacktrace
-
- -
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 09561ed07ab..0d9dc494fac 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 @@ -63,7 +63,6 @@ role="button" data-bs-toggle="dropdown" aria-expanded="false">Debug