Hi Sandeep, In gateway.log I get this:
2018-08-17 04:49:38,760 DEBUG hadoop.gateway (GatewayFilter.java:doFilter(116)) - Received request: GET /grafana/api/datasources/proxy/1/ws/v1/timeline/metrics 2018-08-17 04:49:38,763 DEBUG hadoop.gateway (UrlRewriteProcessor.java:rewrite(166)) - Rewrote URL: https://192.168.134.214:8443/gateway/default/grafana/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs=300000.op=*.TotalCount&hostname=%&appId=namenode&instanceId=&startTime=1534470578&endTime=1534481378, direction: IN via explicit rule: GRAFANAUI/grafana/inbound/queryv to URL: http://platacc002-mgt-01.gvs.ggn:3000/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs%3D300000.op%3D*.TotalCount&hostname=%2525&appId=namenode&startTime=1534470578&endTime=1534481378 2018-08-17 04:49:38,764 DEBUG hadoop.gateway (UrlRewriteProcessor.java:rewrite(164)) - Rewrote URL: https://192.168.134.214:8443/gateway/default/grafana/dashboard/db/hdfs-topn, direction: IN via implicit rule: GRAFANAUI/grafana/inbound/query to URL: http://platacc002-mgt-01.gvs.ggn:3000/dashboard/db/hdfs-topn 2018-08-17 04:49:38,764 DEBUG hadoop.gateway (DefaultDispatch.java:executeOutboundRequest(121)) - Dispatch request: GET http://platacc002-mgt-01.gvs.ggn:3000/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames%3Ddfs.NNTopUserOpCounts.windowMs%3D300000.op%3D*.TotalCount%26hostname%3D%2525%26appId%3Dnamenode%26startTime%3D1534470578%26endTime%3D1534481378 2018-08-17 04:49:38,770 DEBUG hadoop.gateway (DefaultDispatch.java:executeOutboundRequest(134)) - Dispatch response status: 400 2018-08-17 04:49:38,771 DEBUG hadoop.gateway (DefaultDispatch.java:executeOutboundRequest(134)) - Dispatch response status: 400 There are some specific pattern of URLs that are breaking like these: https://192.168.134.214:8443/gateway/default/grafana/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs=300000.op=*.TotalCount&hostname=%&appId=namenode&instanceId=&startTime=1534470578&endTime=1534481378 https://192.168.134.214:8443/gateway/default/grafana/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs=1500000.op=*.TotalCount&hostname=%&appId=namenode&instanceId=&startTime=1534470578&endTime=1534481378 And there are many such patterns. If not URLDecodingDispatch , could you tell me which one is the right dispatcher for such URLs. Thanks Divya From: Sandeep Moré <moresand...@gmail.com<mailto:moresand...@gmail.com>> Reply-To: "user@knox.apache.org<mailto:user@knox.apache.org>" <user@knox.apache.org<mailto:user@knox.apache.org>> Date: Thursday, 16 August 2018 at 7:07 PM To: "user@knox.apache.org<mailto:user@knox.apache.org>" <user@knox.apache.org<mailto:user@knox.apache.org>> Subject: Re: Dispatcher class for Grafana Hello Divya, Looking at the URL you posted looks like you are using the wrong dispatch class, URLDecodingDispatch is used for URLs that are already encoded, looking at your example URL it looks like it is partially encoded (e.g. the query params &), in-fact looks like it is not properly encoded. What error are you getting in gateway.log corresponding to 400 (Bad Request) ? Best, Sandeep On Thu, Aug 16, 2018 at 6:06 AM Divya Narayan <divya.nara...@guavus.com<mailto:divya.nara...@guavus.com>> wrote: Hi , I tried to integrate grafana UI with knox gateway. I used URLDecodingDispatch class but there were some calls which were failing like: http://platacc002-mgt-01.gvs.ggn:3000/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs=1500000.op=__%.user=%&hostname=%25&appId=namenode&startTime=1534390641&endTime=1534401441 The above call on grafana UI failed with below error: Caused by: java.lang.IllegalArgumentException: Malformed escape pair at index 141: http://platacc002-mgt-01.gvs.ggn:3000/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames=dfs.NNTopUserOpCounts.windowMs=1500000.op=__%.user=%&hostname=%25&appId=namenode&startTime=1534390641&endTime=1534401441 at java.net.URI.create(URI.java:852) at knoxdisp.URLDecodingDispatch.getDispatchUrl(URLDecodingDispatch.java:49) at org.apache.hadoop.gateway.dispatch.GatewayDispatchFilter$GetAdapter.doMethod(GatewayDispatchFilter.java:132) at org.apache.hadoop.gateway.dispatch.GatewayDispatchFilter.doFilter(GatewayDispatchFilter.java:115) at org.apache.hadoop.gateway.filter.AbstractGatewayFilter.doFilter(AbstractGatewayFilter.java:61) ... 76 more Now instead of making rewrite rules for each of such URL, I decided to change the dispatcher class itself to handle requests with special characters. In dispatcher class I added URL encoding to encode all the special characters. Below is the code that I tried: @Override public URI getDispatchUrl(final HttpServletRequest request) { String decoded; String encodedURL = null; try { decoded = URLDecoder.decode(request.getRequestURL().toString(), "UTF-8" ); } catch (final Exception e) { /* fall back in case of exception */ decoded = request.getRequestURL().toString(); } final StringBuffer str = new StringBuffer(decoded); final String query = request.getQueryString(); if ( query != null ) { try { encodedURL = URLEncoder.encode(query,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } str.append('?'); str.append(encodedURL); } final URI url = URI.create(str.toString()); return url; } } Now after making these changes, malformed error is resolved and all URLs gets encoded like : Dispatch request: GET http://platacc002-mgt-01.gvs.ggn:3000/api/datasources/proxy/1/ws/v1/timeline/metrics?metricNames%3Ddfs.NNTopUserOpCounts.windowMs%3D1500000.op%3D__%25.user%3D%25%26hostname%3D%2525%26appId%3Dnamenode%26startTime%3D1534400120%26endTime%3D1534410920 But the calls still doesn’t work. It throws HTTP Error code: 400 (Bad Request). Can anyone help me to resolve these calls. Thanks Divya