diff --git a/apm-webapp/pom.xml b/apm-webapp/pom.xml
new file mode 100644
index 000000000..b0dd76f69
--- /dev/null
+++ b/apm-webapp/pom.xml
@@ -0,0 +1,157 @@
+
+
+
+ apm
+ org.apache.skywalking
+ 5.0.0-alpha-SNAPSHOT
+
+ 4.0.0
+
+ apm-webapp
+ jar
+
+ 1.8
+ UTF-8
+ 1.5.10.RELEASE
+ 2.6.2
+ ${project.parent.basedir}/skywalking-ui
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Edgware.SR1
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ ${spring.boot.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+ ${spring.boot.version}
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ ${spring.boot.version}
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ ${spring.boot.version}
+
+
+ com.google.code.gson
+ gson
+ 2.8.2
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-zuul
+
+
+
+
+ skywalking-webapp
+
+
+
+
+
+ maven-compiler-plugin
+
+ ${compiler.version}
+ ${compiler.version}
+ ${project.build.sourceEncoding}
+
+
+
+ com.github.eirslett
+ frontend-maven-plugin
+ 1.6
+
+ ${ui.path}
+ v8.9.4
+
+
+
+ install node and npm
+
+ install-node-and-npm
+
+
+
+ npm install
+
+ npm
+
+
+ install --registry=http://registry.npmjs.org/
+
+
+
+ npm run build
+
+ npm
+
+
+ run build
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ ${project.build.sourceEncoding}
+ ${project.build.directory}
+
+
+ ${basedir}/target/classes/public
+ ${ui.path}/dist
+
+
+ ${basedir}/target/classes
+ src/main/resources
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring.boot.version}
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/ApplicationStartUp.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/ApplicationStartUp.java
new file mode 100644
index 000000000..5f3fe6102
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/ApplicationStartUp.java
@@ -0,0 +1,42 @@
+/*
+ * 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.skywalking.apm.webapp;
+
+import org.apache.skywalking.apm.webapp.config.UIConfig;
+import org.apache.skywalking.apm.webapp.tools.RewritePathFilter;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+
+@SpringBootApplication
+@EnableZuulProxy
+public class ApplicationStartUp extends SpringBootServletInitializer {
+
+ public static void main(String[] args) throws Exception {
+ ApplicationContext applicationContext = SpringApplication.run(ApplicationStartUp.class, args);
+ }
+
+ @Bean
+ public RewritePathFilter addWritePathFilter(UIConfig uiConfig) {
+ return new RewritePathFilter(uiConfig.getRewritePath());
+ }
+}
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/config/UIConfig.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/config/UIConfig.java
new file mode 100644
index 000000000..c5a1f298c
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/config/UIConfig.java
@@ -0,0 +1,36 @@
+/*
+ * 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.skywalking.apm.webapp.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author peng-yongsheng
+ */
+@Configuration
+public class UIConfig {
+
+ @Value("${collector.path}")
+ private String rewritePath;
+
+ public String getRewritePath() {
+ return rewritePath;
+ }
+}
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/CollectorServerList.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/CollectorServerList.java
new file mode 100644
index 000000000..95f3c2ecf
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/CollectorServerList.java
@@ -0,0 +1,89 @@
+/*
+ * 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.skywalking.apm.webapp.tools;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.netflix.client.config.CommonClientConfigKey;
+import com.netflix.client.config.IClientConfig;
+import com.netflix.loadbalancer.AbstractServerList;
+import com.netflix.loadbalancer.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+public class CollectorServerList extends AbstractServerList {
+ private static final Logger logger = LoggerFactory.getLogger(CollectorServerList.class);
+
+ private final CopyOnWriteArrayList servers = new CopyOnWriteArrayList<>();
+
+ private final Gson gson = new Gson();
+
+ private IClientConfig clientConfig;
+
+ public List getInitialListOfServers() {
+ return fetchServer();
+ }
+
+ public List getUpdatedListOfServers() {
+ return fetchServer();
+ }
+
+ public void initWithNiwsConfig(IClientConfig clientConfig) {
+ this.clientConfig = clientConfig;
+ }
+
+ protected List derive(String value) {
+ List list = Lists.newArrayList();
+ if (Strings.isNullOrEmpty(value)) {
+ return list;
+ }
+ String[] serverArray = value.split(",");
+ for (String s : serverArray) {
+ list.add(new Server(s.trim()));
+ }
+ return list;
+ }
+
+ private List fetchServer() {
+ for (Server server : derive(this.clientConfig.get(CommonClientConfigKey.ListOfServers))) {
+ try {
+ String uiServerResponse = HttpClientTools.INSTANCE.get("http://" + server.getHostPort() + "/ui/jetty", null);
+ logger.debug("uiServerResponse: {}", uiServerResponse);
+ JsonArray serverArray = gson.fromJson(uiServerResponse, JsonArray.class);
+ if (serverArray == null || serverArray.size() == 0) {
+ logger.warn("emtry grpc server array, skip : {}", server);
+ continue;
+ }
+ return Lists.newArrayList(StreamSupport.stream(serverArray.spliterator(), false).map(f -> new Server(f.getAsString())).collect(Collectors.toList()));
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ logger.warn("none agentstream server return available grpc server.");
+ return servers;
+ }
+}
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/HttpClientTools.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/HttpClientTools.java
new file mode 100644
index 000000000..da162a83b
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/HttpClientTools.java
@@ -0,0 +1,73 @@
+/*
+ * 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.skywalking.apm.webapp.tools;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.List;
+
+/**
+ * @author peng-yongsheng
+ */
+public enum HttpClientTools {
+ INSTANCE;
+
+ private Logger logger = LoggerFactory.getLogger(HttpClientTools.class);
+
+ public String get(String url, List params) throws IOException {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ try {
+ HttpGet httpget = new HttpGet(url);
+ if (params == null) {
+ httpget.setURI(new URI(httpget.getURI().toString()));
+ } else {
+ String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(params));
+ httpget.setURI(new URI(httpget.getURI().toString() + "?" + paramStr));
+ }
+ logger.debug("executing get request %s", httpget.getURI());
+
+ try (CloseableHttpResponse response = httpClient.execute(httpget)) {
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ return EntityUtils.toString(entity);
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("bad url=" + url, e);
+ } finally {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ logger.warn("bad url=" + url, e);
+ }
+ }
+ return null;
+ }
+}
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilter.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilter.java
new file mode 100644
index 000000000..e3303f821
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilter.java
@@ -0,0 +1,65 @@
+/*
+ * 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.skywalking.apm.webapp.tools;
+
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+
+import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;
+
+/**
+ * Rewrite url to rewritePath
+ *
+ * @author gaohongtao
+ */
+public class RewritePathFilter extends ZuulFilter {
+
+ private static final String REQUEST_URI = "requestURI";
+
+ private static final int ORDER = PRE_DECORATION_FILTER_ORDER + 1;
+
+ public RewritePathFilter(String rewritePath) {
+ this.rewritePath = rewritePath;
+ }
+
+ private final String rewritePath;
+
+ @Override
+ public int filterOrder() {
+ return ORDER;
+ }
+
+ @Override
+ public String filterType() {
+ return "pre";
+ }
+
+ @Override
+ public boolean shouldFilter() {
+ RequestContext ctx = RequestContext.getCurrentContext();
+ return ctx.containsKey(REQUEST_URI);
+ }
+
+ @Override
+ public Object run() {
+ RequestContext ctx = RequestContext.getCurrentContext();
+ ctx.set(REQUEST_URI, rewritePath);
+ return null;
+ }
+}
diff --git a/apm-webapp/src/main/resources/application.yml b/apm-webapp/src/main/resources/application.yml
new file mode 100644
index 000000000..b88a906e0
--- /dev/null
+++ b/apm-webapp/src/main/resources/application.yml
@@ -0,0 +1,14 @@
+server:
+ port: 8080
+zuul:
+ ignoredServices: '*'
+ routes:
+ api:
+ path: /api/**
+ serviceId: collector
+
+collector:
+ path: /graphql
+ ribbon:
+ listOfServers: 127.0.0.1:10800
+ NIWSServerListClassName: org.apache.skywalking.apm.webapp.tools.CollectorServerList
diff --git a/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilterTest.java b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilterTest.java
new file mode 100644
index 000000000..b856fb608
--- /dev/null
+++ b/apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/tools/RewritePathFilterTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.skywalking.apm.webapp.tools;
+
+import com.netflix.zuul.context.RequestContext;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.*;
+import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;
+
+public class RewritePathFilterTest {
+
+ private RewritePathFilter filter;
+
+ @Before
+ public void init() {
+ filter = new RewritePathFilter("/graphql");
+ }
+
+ @Test
+ public void filterOrder() {
+ assertThat(filter.filterOrder(), is(PRE_DECORATION_FILTER_ORDER + 1));
+ }
+
+ @Test
+ public void filterType() {
+ assertThat(filter.filterType(), is("pre"));
+ }
+
+ @Test
+ public void shouldFilter() {
+ assertFalse(filter.shouldFilter());
+ RequestContext.getCurrentContext().set("requestURI");
+ assertTrue(filter.shouldFilter());
+ }
+
+ @Test
+ public void run() {
+ filter.run();
+ assertThat(RequestContext.getCurrentContext().get("requestURI"), is("/graphql"));
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ba3e8bb78..08e93f514 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
apm-application-toolkitapm-collectorapm-protocol
+ apm-webapppom
diff --git a/skywalking-ui b/skywalking-ui
index d4e49aa05..73d211b10 160000
--- a/skywalking-ui
+++ b/skywalking-ui
@@ -1 +1 @@
-Subproject commit d4e49aa0581e510884e85cc145e647dcb179f5a1
+Subproject commit 73d211b10a4158190c0b8188e5ed8efb2499adfc