NazerkeBS commented on code in PR #882:
URL: https://github.com/apache/solr/pull/882#discussion_r893229503


##########
solr/core/src/java/org/apache/solr/util/SolrLogPostTool.java:
##########
@@ -278,48 +279,71 @@ private void parseError(SolrInputDocument lineRecord, 
String line, String trace)
       if (this.cause != null) {
         lineRecord.setField("root_cause_t", cause.replace("Caused by:", 
"").trim());
       }
-
-      lineRecord.setField("collection_s", parseCollection(line));
-      lineRecord.setField("core_s", parseCore(line));
-      lineRecord.setField("shard_s", parseShard(line));
-      lineRecord.setField("replica_s", parseReplica(line));
     }
 
-    private void parseQueryRecord(SolrInputDocument lineRecord, String line) {
-      lineRecord.setField("qtime_i", parseQTime(line));
-      lineRecord.setField("status_s", parseStatus(line));
+    private Map<String, Object> extractJsonFormattedMessage(String line) {
+      int startPos = line.indexOf('{'); // '{' starts at
+      int endPos = line.lastIndexOf('}'); // '}' ends at
+      if (startPos != -1 && endPos != -1) {
+        String json = line.substring(startPos, endPos + 1);
+        @SuppressWarnings("unchecked")
+        Map<String, Object> fromJSON = (Map<String, Object>) 
Utils.fromJSONString(json);
+        return fromJSON;
+      }
+      return null;
+    }
 
-      String path = parsePath(line);
-      lineRecord.setField("path_s", path);
+    private void parseRecord(SolrInputDocument lineRecord, String line) {
+      Map<String, Object> keyValuePairs = extractJsonFormattedMessage(line);
+      if (keyValuePairs != null) {
+        // query request record
+        if (keyValuePairs.containsKey("QTime")) {
+          lineRecord.setField("qtime_i", keyValuePairs.get("QTime"));
+          lineRecord.setField("status_s", keyValuePairs.get("status"));
+          lineRecord.setField("path_s", keyValuePairs.get("path"));
+          if (keyValuePairs.containsKey("hits")) {
+            lineRecord.setField("hits_l", keyValuePairs.get("hits"));
+          }
+          lineRecord.setField("params_t", keyValuePairs.get("params"));
+          addParams(lineRecord, keyValuePairs.get("params").toString());
 
-      if (line.contains("hits=")) {
-        lineRecord.setField("hits_l", parseHits(line));
-      }
+          lineRecord.setField("node_s", keyValuePairs.get("node_name"));
 
-      String params = parseParams(line);
-      lineRecord.setField("params_t", params);
-      addParams(lineRecord, params);
+          if (keyValuePairs.containsKey("prefix") && 
keyValuePairs.get("prefix").equals("admin")) {
+            lineRecord.setField("type_s", "admin");
+          } else if 
(keyValuePairs.get("params").toString().contains("/replication")) {
+            lineRecord.setField("type_s", "replication");
+          } else if (keyValuePairs.get("path").equals("/get")) {

Review Comment:
   I assumed `path=/get`. If I am wrong , then wondering if we can get 
something like `/get/subpath` ?



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to