- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.4k
 
HBASE-27814 Add support for dump and process metrics servlet in REST … #5215
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            80 changes: 80 additions & 0 deletions
          
          80 
        
  hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTDumpServlet.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.hadoop.hbase.rest; | ||
| 
     | 
||
| import java.io.IOException; | ||
| import java.io.OutputStream; | ||
| import java.io.PrintStream; | ||
| import java.io.PrintWriter; | ||
| import java.util.Date; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.servlet.http.HttpServletResponse; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.http.HttpServer; | ||
| import org.apache.hadoop.hbase.monitoring.StateDumpServlet; | ||
| import org.apache.hadoop.hbase.util.LogMonitoring; | ||
| import org.apache.hadoop.hbase.util.Threads; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
| 
     | 
||
| @InterfaceAudience.Private | ||
| public class RESTDumpServlet extends StateDumpServlet { | ||
| private static final long serialVersionUID = 1L; | ||
| private static final String LINE = "==========================================================="; | ||
| 
     | 
||
| @Override | ||
| public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
| if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) { | ||
| return; | ||
| } | ||
| 
     | 
||
| RESTServer restServer = (RESTServer) getServletContext().getAttribute(RESTServer.REST_SERVER); | ||
| assert restServer != null : "No REST Server in context!"; | ||
                
      
                  NihalJain marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| response.setContentType("text/plain"); | ||
| OutputStream os = response.getOutputStream(); | ||
| try (PrintWriter out = new PrintWriter(os)) { | ||
| 
     | 
||
| out.println("REST Server status for " + restServer.getServerName() + " as of " + new Date()); | ||
| 
     | 
||
| out.println("\n\nVersion Info:"); | ||
| out.println(LINE); | ||
| dumpVersionInfo(out); | ||
| 
     | 
||
| out.println("\n\nStacks:"); | ||
| out.println(LINE); | ||
| out.flush(); | ||
| PrintStream ps = new PrintStream(response.getOutputStream(), false, "UTF-8"); | ||
| Threads.printThreadInfo(ps, ""); | ||
| ps.flush(); | ||
| 
     | 
||
| out.println("\n\nREST Server configuration:"); | ||
| out.println(LINE); | ||
| Configuration conf = restServer.conf; | ||
| out.flush(); | ||
| conf.writeXml(os); | ||
| os.flush(); | ||
| 
     | 
||
| out.println("\n\nLogs"); | ||
| out.println(LINE); | ||
| long tailKb = getTailKbParam(request); | ||
| LogMonitoring.dumpTailOfLogs(out, tailKb); | ||
| 
     | 
||
| out.flush(); | ||
| } | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            32 changes: 32 additions & 0 deletions
          
          32 
        
  hbase-rest/src/main/resources/hbase-webapps/rest/footer.jsp
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <%-- | ||
| /** | ||
| * 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. | ||
| */ | ||
| --%> | ||
| 
     | 
||
| <script src="/static/js/jquery.min.js" type="text/javascript"></script> | ||
| <script src="/static/js/bootstrap.min.js" type="text/javascript"></script> | ||
| <script src="/static/js/tab.js" type="text/javascript"></script> | ||
| <script type="text/javascript"> | ||
| $(document).ready(function() { | ||
| $('div.navbar li.active').removeClass('active'); | ||
| $('a[href="' + location.pathname + '"]').closest('li').addClass('active'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
| 
     | 
        
          
          
            74 changes: 74 additions & 0 deletions
          
          74 
        
  hbase-rest/src/main/resources/hbase-webapps/rest/header.jsp
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <%-- | ||
| /** | ||
| * 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. | ||
| */ | ||
| --%> | ||
| <%@ page contentType="text/html;charset=UTF-8" | ||
| import="org.apache.hadoop.hbase.HBaseConfiguration"%> | ||
| 
     | 
||
| <!DOCTYPE html> | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title><%= request.getParameter("pageTitle")%></title> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta name="description" content=""> | ||
| 
     | 
||
| <link href="/static/css/bootstrap.min.css" rel="stylesheet"> | ||
| <link href="/static/css/bootstrap-theme.min.css" rel="stylesheet"> | ||
| <link href="/static/css/hbase.css" rel="stylesheet"> | ||
| </head> | ||
| 
     | 
||
| <body> | ||
| <div class="navbar navbar-fixed-top navbar-default"> | ||
| <div class="container-fluid"> | ||
| <div class="navbar-header"> | ||
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| <span class="icon-bar"></span> | ||
| </button> | ||
| <a class="navbar-brand" href="/rest.jsp"><img src="/static/hbase_logo_small.png" alt="HBase Logo"/></a> | ||
| </div> | ||
| <div class="collapse navbar-collapse"> | ||
| <ul class="nav navbar-nav"> | ||
| <li class="active"><a href="/rest.jsp">Home</a></li> | ||
| <li><a href="/logs/">Local logs</a></li> | ||
| <li><a href="/processRest.jsp">Process Metrics</a></li> | ||
| <li><a href="/logLevel">Log Level</a></li> | ||
| <li><a href="/dump">Debug Dump</a></li> | ||
| <li class="nav-item dropdown"> | ||
| <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
| Metrics <span class="caret"></span> | ||
| </a> | ||
| <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> | ||
| <li><a target="_blank" href="/jmx">JMX</a></li> | ||
| <li><a target="_blank" href="/jmx?description=true">JMX with description</a></li> | ||
| <li><a target="_blank" href="/prometheus">Prometheus</a></li> | ||
| <li><a target="_blank" href="/prometheus?description=true">Prometheus with description</a></li> | ||
| </ul> | ||
| </li> | ||
| <li><a href="/prof">Profiler</a></li> | ||
| <% if (HBaseConfiguration.isShowConfInServlet()) { %> | ||
| <li><a href="/conf">HBase Configuration</a></li> | ||
| <% } %> | ||
| </ul> | ||
| </div><!--/.nav-collapse --> | ||
| </div> | ||
| </div> | ||
| 
     | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.