You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2019/05/24 15:56:01 UTC

[GitHub] [knox] risdenk commented on a change in pull request #94: KNOX-1866 Fix HBase UI proxying.

risdenk commented on a change in pull request #94: KNOX-1866 Fix HBase UI proxying.
URL: https://github.com/apache/knox/pull/94#discussion_r287420459
 
 

 ##########
 File path: gateway-service-definitions/src/main/resources/services/hbaseui/2.1.0/rewrite.xml
 ##########
 @@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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.
+-->
+<rules>
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/root" pattern="*://*:*/**/hbase/webui/">
+    <!-- Visiting http://master-host:16010/ triggers a meta-refresh to /master-status
+         which doesn't work when inside the proxy. Just avoid hitting that endpoint. -->
+    <rewrite template="{$serviceUrl[HBASEUI]}/master-status"/>
+  </rule>
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/root/qualified" pattern="*://*:*/**/hbase/webui/?{host}?port}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/master-status"/>
+  </rule>
+  <!-- Make sure that redirects back to the master landing page work -->
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/root" pattern="/">
+    <rewrite template="{gateway.url}/hbase/webui/"/>
+  </rule>
+  <!-- Generic pages on the default serviceUrl -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/home" pattern="*://*:*/**//hbase/webui/master?{host}?{port}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/master-status"/>
+  </rule>
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/home" pattern="*://*:*/**//hbase/webui/master?{host}?{port}?{**}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/master-status?{**} "/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/home" pattern="//{host}:{port}/master-status?{**}">
+    <rewrite template="{gateway.url}/hbase/webui/master/master-status?host={$hostmap(host)}?{port}?{**}"/>
+  </rule>
+
+  <!-- Load a RegionServer's status page -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/regionserver/home" pattern="*://*:*/**//hbase/webui/regionserver?{host}?{port}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/rs-status"/>
+  </rule>
+  <!-- Yes, we have both explicit and implicit scheme for rs-status outbound links. Need these both -->
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/home" pattern="*://{host}:{port}/rs-status/">
+    <rewrite template="{gateway.url}/hbase/webui/regionserver/rs-status?host={$hostmap(host)}?{port}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/home" pattern="//{host}:{port}/rs-status/">
+    <rewrite template="{gateway.url}/hbase/webui/regionserver/rs-status?host={$hostmap(host)}?{port}"/>
+  </rule>
+
+  <!-- region.jsp -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/regions" pattern="*://*:*/**/hbase/webui/regionserver/region.jsp?{host}?{port}?{name}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/region.jsp?{name}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regions" pattern="/region.jsp?{name}?{**}">
+    <rewrite template="{gateway.url}/hbase/webui/regionserver/region.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/regions" pattern="//{host}:{port}/region.jsp?{name}">
+    <rewrite template="{gateway.url}/hbase/webui/region.jsp?host={host}?{port}?{name}"/>
+  </rule>
+
+  <!-- storeFile.jsp -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/storefile" pattern="*://*:*/**/hbase/webui/regionserver/storeFile.jsp?{host}?{port}?{name}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/storeFile.jsp?{name}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/storefile" pattern="/storeFile.jsp?{name}">
+    <rewrite template="{gateway.url}/hbase/webui/regionserver/storeFile.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{name}"/>
+  </rule>
+
+  <rule dir="IN" name="HBASEUI/hbase/inbound/processMaster" pattern="*://*:*/**/hbase/webui/processMaster.jsp">
+    <rewrite template="{$serviceUrl[HBASEUI]}/processMaster.jsp"/>
+  </rule>
+
+  <!-- LogLevel servlet -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/loglevel" pattern="*://*:*/**/hbase/webui/logLevel?{host}?{port}?{**}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/logLevel?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/loglevel" pattern="/logLevel?{**}">
+    <rewrite template="{gateway.url}/hbase/webui/logLevel?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+
+  <!-- Profiler servlet -->
+  <!-- prof-output sets the Refresh header to render the SVG after the profiler finishes.
+       This sets up a filter to catch that Refresh header and rewrite it to point to the
+       proxied location instead of the original.
+  -->
+  <filter name="HBASEUI/hbase/webui/outbound/headers/prof-output">
+    <content type="application/x-http-headers">
+      <apply path="Refresh" rule="HBASEUI/hbase/webui/outbound/headers/prof-output/refresh"/>
+    </content>
+  </filter>
+  <rule dir="OUT" name="HBASEUI/hbase/webui/outbound/headers/prof-output/refresh" pattern="*;/prof-output/{**}?{**}">
+    <!-- Can we somehow parse the literal number to wait before redirect instead of picking the constant 5s? -->
+    <rewrite template="{$prefix[5;,url]}{gateway.url}/hbase/webui/master/prof-output/{**}?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+
+  <!-- zk.jsp on the Master page -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/zkdump" pattern="*://*:*/**/hbase/webui/master/zk.jsp?{host}?{port}?{**}">
+    <rewrite template="{$servicScheme[HBASEUI]}://{host}:{port}/zk.jsp?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/webui/outbound/zkdump" pattern="//{host}:{port}/zk.jsp?{**}">
+    <rewrite template="{gateway.url}/hbase/webui/master/zk.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/webui/outbound/zkdump2" pattern="/zk.jsp?{**}">
+    <rewrite template="{gateway.url}/hbase/webui/master/zk.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+
+  <!-- table.jsp, the IN is handled by master/all_children -->
+  <rule dir="OUT" name="HBASEUI/table" pattern="/table.jsp?{name}">
+    <rewrite template="{gateway.url}/hbase/webui/master/table.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{name}"/>
+  </rule>
+
+
+  <!-- WIP of master UI using query string to carry host and port -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/all_children" pattern="*://*:*/**/hbase/webui/master/{**}?{host}?{port}?{**}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/{**}?{**}"/>
+  </rule>
+  <rule dir="IN" name="HBASEUI/hbase/inbound/master/prof_output" pattern="*://*:*//**/hbase/webui/master/prof-output/{**}?{host}?{port}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/prof-output/{**}?host={host}?port={port}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/master-status?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/master-status?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/conf?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/conf?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/tablesDetailed.jsp?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/tablesDetailed.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/procedures.jsp?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/procedures.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/processMaster.jsp?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/processMaster.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/dump?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/dump?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/jmx?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/jmx?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/children" pattern="/prof?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/master/prof?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+
+  <!-- RegionServer UI proxying -->
+  <rule dir="IN" name="HBASEUI/hbase/inbound/regionserver/root/qualified" pattern="*://*:*/**/hbase/webui/regionserver?{host}?port}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/rs-status"/>
+  </rule>
+  <rule dir="IN" name="HBASEUI/hbase/inbound/regionserver/all_children" pattern="*://*:*/**/hbase/webui/regionserver/{**}?{host}?{port}?{**}">
+    <rewrite template="{$serviceScheme[HBASEUI]}://{host}:{port}/{**}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/rs-status?{**}">
+    <rewrite template="{$frontend[url]}/hbase/webui/regionserver/rs-status?host={$inboundurl[host]}?port={$inboundurl[port]}?{**}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/processRS.jsp">
+    <rewrite template="{$frontend[url]}/hbase/webui/regionserver/processRS.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/conf">
+    <rewrite template="{$frontend[url]}/hbase/webui/regionserver/conf?host={$inboundurl[host]}?port={$inboundurl[port]}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/tablesDetailed.jsp">
+    <rewrite template="{$frontend[url]}/hbase/webui/regionserver/tablesDetailed.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/procedures.jsp">
+    <rewrite template="{$frontend[url]}/hbase/webui/regionserver/procedures.jsp?host={$inboundurl[host]}?port={$inboundurl[port]}"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/children" pattern="/dump">
 
 Review comment:
   So `/conf`, `/dump`, `/jmx`, and `/prof` (there might be others) all match both the regionserver and master handling. The redirect urls are written from a RS url back to a master url. It looks like the right data (since the host/port) is on the end - so it might make sense to make these rules not master/regionserver specific?
   
   Starting from:
   
   https://KNOX_HOST:8443/gateway/cluster_1/hbase/webui/regionserver/rs-status?host=HBASE_REGIONSERVER_HOST&port=22102
   
   and clicking "Metrics Dump", I end up with the url:
   
   https://KNOX_HOST:8443/gateway/cluster_1/hbase/webui/master/jmx?host=HBASE_REGIONSERVER_HOST&port=22102
   
   The data coming back starts with 
   ```
   {"beans":[{"name":"Hadoop:service=HBase,name=RegionServer,
   ```
   
   so it looks like it is pulling the JMX metrics from the RegionServer, but the url is definitely `/hbase/webui/master/jmx`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services