Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to fix Knox HBASE UI?

avatar
Expert Contributor

In an Ambari HDP 2.6.5 install after configuring a Knox topology to expose Hbase UI with following tags:

  <service>
    <role>HBASEUI</role>
    <url>http://{{hbase_master_host}}:16010</url>
  </service>

you will able to access the HBase UI in the URL

https://knoxserver:8443/gateway/ui/hbase/webui/

but many of the links at the top menu bar, as for example "Procedures" or "Local Logs", will point to the wrong URL without the gateway prefix. For example the "Procedures" menu will point to "https://knoxserver:8443/procedures.jsp" and gives you a "Not Found" error.

How to fix this?

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Thank you very much @scharan for your response

I tried these steps and indeed posted an answer based on this to my own question because after some minor fixed (some trivial errors as duplicated slashes on rewrite patterns) these service definitions seemed to fix the header links problems.

But after some testing I found out that this version introduced many other problems with the internal links and realized that the new situation was worst than with the original HDP version so I reverted these changes and deleted my answer.

Then I decided to patch the service definition in HDP 2.6.5 adding the missing rewrite rules to the rewrite.xml file as follows:

   <rule dir="OUT" name="HBASEUI/hbase/outbound/tables" pattern="/tablesDetailed.jsp">
     <rewrite template="{$frontend[url]}/hbase/webui/tablesDetailed.jsp"/>
   </rule>
-  <rule dir="OUT" name="HBASEUI/hbase/outbound/logs" pattern="/logs/">
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/procedures" pattern="/procedures.jsp">
+    <rewrite template="{$frontend[url]}/hbase/webui/procedures.jsp"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/nohome" pattern="/rs-status/">
+    <rewrite template="{$frontend[url]}/hbase/webui/"/>
+  </rule>
+
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/logs" pattern="/logs">
     <rewrite template="{$frontend[url]}/hbase/webui/logs/"/>
   </rule>

This solved most of the problems but the links to the Home ("/") and Metric Dump ("/jmx") were still wrong, event when the outgoing rewrite rule for the "/jmx" was present in the rewrite.xml:

  <rule dir="OUT" name="HBASEUI/hbase/outbound/jmx" pattern="/jmx">
    <rewrite template="{$frontend[url]}/hbase/webui/jmx"/>
  </rule>

Some more testing showed me that Knox has a bug (or feature?) that prevents an outgoing implicit rule for matching when the length of the pattern has less than 4 chars! (ex. jmx)

To fix these problems I followed the article Proxying a UI using Knox to create a rewrite filter rule and apply this to the "response.body" to the "text/html" pages. These are the needed changes in service.xml:

     <routes>
         <route path="/hbase/webui/">
             <rewrite apply="HBASEUI/hbase/inbound/master/root" to="request.url"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/**">
             <rewrite apply="HBASEUI/hbase/inbound/master/path" to="request.url"/>                                                               
             <rewrite apply="HBASEUI/hbase/outbound/headers" to="response.headers"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/**?**">
             <rewrite apply="HBASEUI/hbase/inbound/master/query" to="request.url"/>
@@ -30,9 +32,11 @@
         </route>
         <route path="/hbase/webui/regionserver/**?{host}?{port}">
             <rewrite apply="HBASEUI/hbase/inbound/regionserver/home" to="request.url"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/master/**?{host}?{port}">
             <rewrite apply="HBASEUI/hbase/inbound/master/home" to="request.url"/>                                                               
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/logs?**">
             <rewrite apply="HBASEUI/hbase/outbound/headers" to="response.headers"/>

An then add these rules to the end of rewrite.xml:

   <rule dir="OUT" name="HBASEUI/hbase/outbound/master/filter/home">
    <rewrite template="{$frontend[path]}/hbase/webui/"/>
  </rule>
  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/filter/jmx">
    <rewrite template="{$frontend[path]}/hbase/webui/jmx"/>
  </rule>
  <filter name="HBASEUI/hbase/outbound/master/filter">
    <content type="text/html">
      <apply path="/jmx" rule="HBASEUI/hbase/outbound/master/filter/jmx"/>
      <apply path="/" rule="HBASEUI/hbase/outbound/master/filter/home"/>
    </content>
  </filter>

Now finally all the header links are OK in all the pages (including the internal ones to the RegionServer nodes status) and all the HBaseUI seems to be working as expected. The only remaining problem seems to be with some very internal and rarely used links at the "Regions" section inside the RegionServer nodes subpages (this will require more rewrite tweaks).

This worked for me and I hope this will help someone to make the HBaseUI usable through Knox.

View solution in original post

3 REPLIES 3

avatar
Master Collaborator

@Luis Vazquez

Try below steps

1. ssh to Knox gateway host and go to /var/lib/knox/data-2.6.5.X/services

2. download the configurations from https://github.com/apache/knox/tree/v0.11.0/gateway-service-definitions/src/main/resources/services/.../ URL.

3. make sure your folder structure should look alike /var/lib/knox/data-2.6.5.X/services/hbaseui/1.1.0 and should have rewrite.xml and service.xml files

4. change the owner/Group permissions to Knox for /var/lib/knox/data-2.6.5.X/services/hbaseui/ and subdirectory

5. Go to Knox configurations Modify "Advanced topology" with below service tag

  1. <service>
  2. <role>HBASEUI</role>
  3. <url>http://HBASEMANTERHOST:16010</url>
  4. </service>
  5. <service>

6. Restart Knox service.

7. You should be able to access HBase UI from the below URL

https://Knxo-host:8443/gateway/<topology-name>/hbase/webui/

Note: Hbase UI through knox is not supported in hdp 2.6.5, You can try above steps as a workaround.

Please accept answer if it helped.

avatar
Expert Contributor

Thank you very much @scharan for your response

I tried these steps and indeed posted an answer based on this to my own question because after some minor fixed (some trivial errors as duplicated slashes on rewrite patterns) these service definitions seemed to fix the header links problems.

But after some testing I found out that this version introduced many other problems with the internal links and realized that the new situation was worst than with the original HDP version so I reverted these changes and deleted my answer.

Then I decided to patch the service definition in HDP 2.6.5 adding the missing rewrite rules to the rewrite.xml file as follows:

   <rule dir="OUT" name="HBASEUI/hbase/outbound/tables" pattern="/tablesDetailed.jsp">
     <rewrite template="{$frontend[url]}/hbase/webui/tablesDetailed.jsp"/>
   </rule>
-  <rule dir="OUT" name="HBASEUI/hbase/outbound/logs" pattern="/logs/">
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/procedures" pattern="/procedures.jsp">
+    <rewrite template="{$frontend[url]}/hbase/webui/procedures.jsp"/>
+  </rule>
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/regionserver/nohome" pattern="/rs-status/">
+    <rewrite template="{$frontend[url]}/hbase/webui/"/>
+  </rule>
+
+  <rule dir="OUT" name="HBASEUI/hbase/outbound/logs" pattern="/logs">
     <rewrite template="{$frontend[url]}/hbase/webui/logs/"/>
   </rule>

This solved most of the problems but the links to the Home ("/") and Metric Dump ("/jmx") were still wrong, event when the outgoing rewrite rule for the "/jmx" was present in the rewrite.xml:

  <rule dir="OUT" name="HBASEUI/hbase/outbound/jmx" pattern="/jmx">
    <rewrite template="{$frontend[url]}/hbase/webui/jmx"/>
  </rule>

Some more testing showed me that Knox has a bug (or feature?) that prevents an outgoing implicit rule for matching when the length of the pattern has less than 4 chars! (ex. jmx)

To fix these problems I followed the article Proxying a UI using Knox to create a rewrite filter rule and apply this to the "response.body" to the "text/html" pages. These are the needed changes in service.xml:

     <routes>
         <route path="/hbase/webui/">
             <rewrite apply="HBASEUI/hbase/inbound/master/root" to="request.url"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/**">
             <rewrite apply="HBASEUI/hbase/inbound/master/path" to="request.url"/>                                                               
             <rewrite apply="HBASEUI/hbase/outbound/headers" to="response.headers"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/**?**">
             <rewrite apply="HBASEUI/hbase/inbound/master/query" to="request.url"/>
@@ -30,9 +32,11 @@
         </route>
         <route path="/hbase/webui/regionserver/**?{host}?{port}">
             <rewrite apply="HBASEUI/hbase/inbound/regionserver/home" to="request.url"/>
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/master/**?{host}?{port}">
             <rewrite apply="HBASEUI/hbase/inbound/master/home" to="request.url"/>                                                               
+            <rewrite apply="HBASEUI/hbase/outbound/master/filter" to="response.body"/>
         </route>
         <route path="/hbase/webui/logs?**">
             <rewrite apply="HBASEUI/hbase/outbound/headers" to="response.headers"/>

An then add these rules to the end of rewrite.xml:

   <rule dir="OUT" name="HBASEUI/hbase/outbound/master/filter/home">
    <rewrite template="{$frontend[path]}/hbase/webui/"/>
  </rule>
  <rule dir="OUT" name="HBASEUI/hbase/outbound/master/filter/jmx">
    <rewrite template="{$frontend[path]}/hbase/webui/jmx"/>
  </rule>
  <filter name="HBASEUI/hbase/outbound/master/filter">
    <content type="text/html">
      <apply path="/jmx" rule="HBASEUI/hbase/outbound/master/filter/jmx"/>
      <apply path="/" rule="HBASEUI/hbase/outbound/master/filter/home"/>
    </content>
  </filter>

Now finally all the header links are OK in all the pages (including the internal ones to the RegionServer nodes status) and all the HBaseUI seems to be working as expected. The only remaining problem seems to be with some very internal and rarely used links at the "Regions" section inside the RegionServer nodes subpages (this will require more rewrite tweaks).

This worked for me and I hope this will help someone to make the HBaseUI usable through Knox.

avatar
Expert Contributor

WARNING: when doing the previous changes to the installed service.xml and rewrite.xml (under data/services/...) DO NOT create a backup copy (ex. rewrite.xml.orig) or move the original version to a "backup" sub-folder under this path!!

Knox will load ALL the xml files it finds under "/usr/hdp/current/knox-server/data/services" (weird but real!) and this will trigger many strange and confusing behaviors!!

I've wasted a few hours trying to make the above work, just because of this 😞