From 75fd1a31adf93bc8f986b2238f443ca617c1ad34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Sun, 13 Nov 2022 20:20:22 +0200 Subject: [PATCH] Fix file path include/exclude handling --- README.md | 3 --- log_shipper.py | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 45b6d16..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,3 +0,0 @@ - -* Unlike Filebeat it sports embedded Prometheus metric exporter - diff --git a/log_shipper.py b/log_shipper.py index ce74f5c..9d110fc 100755 --- a/log_shipper.py +++ b/log_shipper.py @@ -439,7 +439,6 @@ async def watcher(queue, coll): if path in log_files: log_files[path].finished = finished return log_files[path] - print("Adding file: %s" % path) m = re.match("/var/log/pods/(.*)_(.*)_.*/(.*)/[0-9]+\\.log$", path) @@ -448,13 +447,14 @@ async def watcher(queue, coll): counter_unexpected_filenames.inc() return namespace_name, pod_name, container_name = m.groups() - if args.namespace and args.namespace == namespace_name: + if args.namespace and args.namespace != namespace_name: + print("Skipping due to namespace mismatch:", path) return for prefix in args.exclude_pod_prefixes: if pod_name.startswith(prefix): + print("Skipping due to pod prefix mismatch:", path) return - if args.namespace and namespace_name != args.namespace: - return + print("Adding file: %s" % path) lf = log_files[path] = LogFile(coll, queue, path, namespace_name, pod_name, container_name, start, lookup_offset) lf.finished = finished