This is an automated email from the ASF dual-hosted git repository. mmiller 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 e7a20c0a2b Add all endpoints page on Monitor (#2639) e7a20c0a2b is described below commit e7a20c0a2b038f9c8d7661ceef026bba9de2a09c Author: Mike Miller <mmil...@apache.org> AuthorDate: Wed Apr 20 08:46:20 2022 -0400 Add all endpoints page on Monitor (#2639) * Create a debug page on the monitor and an endpoint to display all of the REST endpoints available on the monitor * Also create a variable to store the live port number when the server starts up --- .../java/org/apache/accumulo/monitor/Monitor.java | 10 ++++- .../org/apache/accumulo/monitor/view/WebViews.java | 45 ++++++++++++++++++++++ .../apache/accumulo/monitor/templates/debug.ftl | 28 ++++++++++++++ .../apache/accumulo/monitor/templates/navbar.ftl | 5 ++- 4 files changed, 85 insertions(+), 3 deletions(-) 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 d6403bc220..158119587c 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 @@ -181,6 +181,7 @@ public class Monitor extends AbstractServer implements HighlyAvailableService { + "'accumulo compaction-coordinator'."; private EmbeddedWebServer server; + private int livePort = 0; private ServiceLock monitorLock; @@ -447,12 +448,13 @@ public class Monitor extends AbstractServer implements HighlyAvailableService { int[] ports = getConfiguration().getPort(Property.MONITOR_PORT); for (int port : ports) { try { - log.debug("Creating monitor on port {}", port); + log.debug("Trying monitor on port {}", port); server = new EmbeddedWebServer(this, port); server.addServlet(getDefaultServlet(), "/resources/*"); server.addServlet(getRestServlet(), "/rest/*"); server.addServlet(getViewServlet(), "/*"); server.start(); + livePort = port; break; } catch (Exception ex) { log.error("Unable to start embedded web server", ex); @@ -461,6 +463,8 @@ public class Monitor extends AbstractServer implements HighlyAvailableService { if (!server.isRunning()) { throw new RuntimeException( "Unable to start embedded web server on ports: " + Arrays.toString(ports)); + } else { + log.debug("Monitor started on port {}", livePort); } try { @@ -967,4 +971,8 @@ public class Monitor extends AbstractServer implements HighlyAvailableService { public Optional<HostAndPort> getCoordinatorHost() { return coordinatorHost; } + + public int getLivePort() { + return livePort; + } } 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 eb4b1e9faa..4c1a981bb6 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 @@ -446,4 +446,49 @@ public class WebViews { return model; } + + @GET + @Path("all") + @Template(name = "/default.ftl") + public Map<String,Object> getRestView() { + + Map<String,Object> model = getModel(); + model.put("title", "Rest Endpoints"); + + model.put("template", "debug.ftl"); + model.put("js", "functions.js"); + + model.put("endpoints", getEndpoints()); + + return model; + } + + private List<String> getEndpoints() { + List<String> endpoints = new ArrayList<>(); + endpoints.add("/rest/manager"); + endpoints.add("/rest/tables/namespaces"); + endpoints.add("/rest/problems/summary"); + endpoints.add("/rest/tables"); + endpoints.add("/rest/tservers"); + endpoints.add("/rest/scans"); + endpoints.add("/rest/bulkImports"); + endpoints.add("/rest/tservers/serverStats"); + endpoints.add("/rest/tservers/recovery"); + endpoints.add("/rest/logs"); + endpoints.add("/rest/problems/details"); + endpoints.add("/rest/replication"); + endpoints.add("/rest/statistics/time/ingestRate"); + endpoints.add("/rest/statistics/time/scanEntries"); + endpoints.add("/rest/statistics/time/ingestByteRate"); + endpoints.add("/rest/statistics/time/queryByteRate"); + endpoints.add("/rest/statistics/time/load"); + endpoints.add("/rest/statistics/time/lookups"); + endpoints.add("/rest/statistics/time/minorCompactions"); + endpoints.add("/rest/statistics/time/majorCompactions"); + endpoints.add("/rest/statistics/time/indexCacheHitRate"); + endpoints.add("/rest/statistics/time/dataCacheHitRate"); + endpoints.add("/rest/status"); + return endpoints; + } + } diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/debug.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/debug.ftl new file mode 100644 index 0000000000..a700c0549a --- /dev/null +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/debug.ftl @@ -0,0 +1,28 @@ +<#-- + + 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 + + http://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. + +--> +<h3>${title}</h3> + +<#if endpoints?has_content> + <#list endpoints as val> + <a href="${val}">${val}</a></br> + </#list> +</#if> + 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 a9cca5939e..c3acde3c18 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 @@ -72,8 +72,9 @@ REST <span class="caret"></span> </a> <ul class="dropdown-menu"> - <li><a href="/rest/xml">XML</a></li> - <li><a href="/rest/json">JSON</a></li> + <li><a href="/all">All Endpoints</a></li> + <li><a href="/rest/xml">XML Summary</a></li> + <li><a href="/rest/json">JSON Summary</a></li> </ul> </li> <li class="dropdown">