diff --git a/collector/server/pom.xml b/collector/server/pom.xml
index 2e2fca9..4d000a9 100644
--- a/collector/server/pom.xml
+++ b/collector/server/pom.xml
@@ -52,6 +52,12 @@
httpclient
4.5.13
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.6.0
+
com.googlecode.concurrentlinkedhashmap
diff --git a/collector/server/src/main/java/com/usthe/collector/collect/http/HttpCollectImpl.java b/collector/server/src/main/java/com/usthe/collector/collect/http/HttpCollectImpl.java
index a59ab9e..54f7006 100644
--- a/collector/server/src/main/java/com/usthe/collector/collect/http/HttpCollectImpl.java
+++ b/collector/server/src/main/java/com/usthe/collector/collect/http/HttpCollectImpl.java
@@ -1,11 +1,21 @@
package com.usthe.collector.collect.http;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.Option;
+import com.jayway.jsonpath.spi.cache.CacheProvider;
+import com.jayway.jsonpath.spi.cache.LRUCache;
import com.usthe.collector.collect.AbstractCollect;
import com.usthe.collector.common.http.HttpClientPool;
import com.usthe.collector.dispatch.DispatchConstants;
+import com.usthe.collector.util.JsonPathParser;
import com.usthe.common.entity.job.Metrics;
import com.usthe.common.entity.job.protocol.HttpProtocol;
import com.usthe.common.entity.message.CollectRep;
+import com.usthe.common.util.CommonConstants;
import com.usthe.common.util.IpDomainUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHeaders;
@@ -82,20 +92,20 @@ public class HttpCollectImpl extends AbstractCollect {
String parseType = metrics.getHttp().getParseType();
try {
if (DispatchConstants.PARSE_DEFAULT.equals(parseType)) {
- parseResponseByDefault(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
- } else if (DispatchConstants.PARSE_PROMETHEUS.equals(parseType)) {
- parseResponseByPrometheus(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
+ parseResponseByDefault(resp, metrics.getAliasFields(), builder);
} else if (DispatchConstants.PARSE_JSON_PATH.equals(parseType)) {
parseResponseByJsonPath(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
+ } else if (DispatchConstants.PARSE_PROMETHEUS.equals(parseType)) {
+ parseResponseByPrometheus(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
} else if (DispatchConstants.PARSE_XML_PATH.equals(parseType)) {
parseResponseByXmlPath(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
} else {
- parseResponseByDefault(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
+ parseResponseByDefault(resp, metrics.getAliasFields(), builder);
}
} catch (Exception e) {
log.info("parse error: {}.", e.getMessage(), e);
builder.setCode(CollectRep.Code.FAIL);
- builder.setMsg("parse response data error.");
+ builder.setMsg("parse response data error:" + e.getMessage());
return;
}
}
@@ -135,23 +145,73 @@ public class HttpCollectImpl extends AbstractCollect {
}
}
- private void parseResponseByXmlPath(String resp, List preFields, HttpProtocol http, CollectRep.MetricsData.Builder builder) {
-
- }
-
- private void parseResponseByJsonPath(String resp, List preFields, HttpProtocol http, CollectRep.MetricsData.Builder builder) {
-
- }
-
- private void parseResponseByPrometheus(String resp, List preFields, HttpProtocol http, CollectRep.MetricsData.Builder builder) {
-
- }
-
- private void parseResponseByDefault(String resp, List preFields, HttpProtocol http,
+ private void parseResponseByXmlPath(String resp, List aliasFields, HttpProtocol http,
CollectRep.MetricsData.Builder builder) {
}
+ private void parseResponseByJsonPath(String resp, List aliasFields, HttpProtocol http,
+ CollectRep.MetricsData.Builder builder) {
+ List