You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/09/28 07:44:24 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #6048: [INLONG-6047][Agent] Fix file could not be matched in the k8s

healchow commented on code in PR #6048:
URL: https://github.com/apache/inlong/pull/6048#discussion_r982058197


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/utils/MetaDataUtils.java:
##########
@@ -47,16 +49,17 @@ public class MetaDataUtils {
     private static final String LOG_MARK = ".log";
 
     // standard log path for k8s
-    private static final String STANDARD_OUT = "/var/log/containers";
+    private static final String FILE_NAME_PATTERN = "(^[-a-zA-Z0-9]+)_([a-zA-Z0-9-]+)_([a-zA-Z0-9-]+)(.log)";
 
     /**
      * standard log for k8s
      *
      * get pod_name,namespace,container_name,container_id
      */
     public static Map<String, String> getLogInfo(String fileName) {
+        Matcher matcher = Pattern.compile(FILE_NAME_PATTERN).matcher(fileName);

Review Comment:
   Suggested extracting the `Pattern.compile` to a static final field, it is more efficient.



-- 
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: commits-unsubscribe@inlong.apache.org

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