Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

fix: Added log expiry env to runner and prompt-service, (#1166)

Chandrasekharan M2b221612d738
diff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.py
index ea64d63a8..33b301dd5 100644
--- a/backend/backend/settings/base.py
+++ b/backend/backend/settings/base.py
@@ -130,7 +130,7 @@ LOG_HISTORY_CONSUMER_INTERVAL = int(
)
LOGS_BATCH_LIMIT = int(get_required_setting("LOGS_BATCH_LIMIT", "30"))
LOGS_EXPIRATION_TIME_IN_SECOND = int(
- get_required_setting("LOGS_EXPIRATION_TIME_IN_SECOND")
+ get_required_setting("LOGS_EXPIRATION_TIME_IN_SECOND", "86400")
)
INDEXING_FLAG_TTL = int(get_required_setting("INDEXING_FLAG_TTL"))
diff --git a/prompt-service/sample.env b/prompt-service/sample.env
index 8f9d92af5..f31edd9f7 100644
--- a/prompt-service/sample.env
+++ b/prompt-service/sample.env
@@ -22,6 +22,9 @@ LOG_LEVEL=INFO
#Celery for PublishLogs
CELERY_BROKER_URL="redis://unstract-redis:6379"
+# Logs Expiry of 24 hours
+LOGS_EXPIRATION_TIME_IN_SECOND=86400
+
# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
EVALUATION_SERVER_PORT=9000
diff --git a/runner/sample.env b/runner/sample.env
index 26aa344e5..628070ec7 100644
--- a/runner/sample.env
+++ b/runner/sample.env
@@ -17,6 +17,8 @@ REMOVE_CONTAINER_ON_EXIT=True
# Client module path of the container engine to be used.
CONTAINER_CLIENT_PATH=unstract.runner.clients.docker
+# Logs Expiry of 24 hours
+LOGS_EXPIRATION_TIME_IN_SECOND=86400
# Feature Flags
FLIPT_SERVICE_AVAILABLE=False
diff --git a/unstract/core/src/unstract/core/pubsub_helper.py b/unstract/core/src/unstract/core/pubsub_helper.py
index 0ea0a2523..602627705 100644
--- a/unstract/core/src/unstract/core/pubsub_helper.py
+++ b/unstract/core/src/unstract/core/pubsub_helper.py
@@ -150,17 +150,12 @@ class LogPublisher:
log_data = json.dumps(payload)
# Check if the payload type is "LOG"
if payload["type"] == "LOG":
- logs_expiration = os.environ.get("LOGS_EXPIRATION_TIME_IN_SECOND")
-
- # Extract timestamp from payload
+ logs_expiration = os.environ.get(
+ "LOGS_EXPIRATION_TIME_IN_SECOND", 86400
+ ) # Defaults to 1 day
timestamp = payload["timestamp"]
-
- # Construct Redis key using channel and timestamp
redis_key = f"{channel}:{timestamp}"
-
- # Store logs in Redis with expiration of 1 hour
cls.r.setex(redis_key, logs_expiration, log_data)
-
except Exception as e:
logging.error(f"Failed to publish '{channel_id}' <= {payload}: {e}")
return False