diff --git a/config.py b/config.py
index b3484337f..9a15763db 100644
--- a/config.py
+++ b/config.py
@@ -318,6 +318,7 @@ class DefaultConfig(ImmutableConfig):
# Action logs archive
ACTION_LOG_ARCHIVE_LOCATION = 'local_us'
ACTION_LOG_ARCHIVE_PATH = 'actionlogarchive/'
+ ACTION_LOG_ROTATION_THRESHOLD = '30d'
# System logs.
SYSTEM_LOGS_PATH = "/var/log/"
diff --git a/config_app/js/core-config-setup/config-setup-tool.html b/config_app/js/core-config-setup/config-setup-tool.html
index a1fb25e75..520e849d9 100644
--- a/config_app/js/core-config-setup/config-setup-tool.html
+++ b/config_app/js/core-config-setup/config-setup-tool.html
@@ -386,6 +386,23 @@
+
+ Log Rotation Threshold: |
+
+
+
+ The number of days after which to archive action logs to storage. Must be expressed in a duration string form: 30m , 1h , 1d , 2w .
+
+
+ Note: The rotation threshold should be considered a balancing act between user history and size of database.
+
+
+ Larger time windows will result in more logs, but give users more history to view.
+ Anything less than 2w is not recommended.
+
+ |
+
diff --git a/util/config/schema.py b/util/config/schema.py
index 8c425dc83..de109e38e 100644
--- a/util/config/schema.py
+++ b/util/config/schema.py
@@ -330,6 +330,12 @@ CONFIG_SCHEMA = {
'archived data.',
'x-example': 'archives/actionlogs',
},
+ 'ACTION_LOG_ROTATION_THRESHOLD': {
+ 'type': 'string',
+ 'description': 'If action log archiving is enabled, the time interval after which to ' +
+ 'archive data.',
+ 'x-example': '30d',
+ },
'LOG_ARCHIVE_LOCATION': {
'type': 'string',
'description': 'If builds are enabled, the storage engine in which to place the ' +
diff --git a/workers/logrotateworker.py b/workers/logrotateworker.py
index b81279c7b..ddf4f9ad0 100644
--- a/workers/logrotateworker.py
+++ b/workers/logrotateworker.py
@@ -15,16 +15,17 @@ from data.userfiles import DelegateUserfiles
from util.locking import GlobalLock, LockNotAcquiredException
from util.log import logfile_path
from util.streamingjsonencoder import StreamingJSONEncoder
+from util.timedeltastring import convert_to_timedelta
from workers.worker import Worker
logger = logging.getLogger(__name__)
JSON_MIMETYPE = 'application/json'
-STALE_AFTER = timedelta(days=30)
MIN_LOGS_PER_ROTATION = 10000
MEMORY_TEMPFILE_SIZE = 12 * 1024 * 1024
WORKER_FREQUENCY = app.config.get('ACTION_LOG_ROTATION_FREQUENCY', 60 * 60 * 12)
+STALE_AFTER = convert_to_timedelta(app.config.get('ACTION_LOG_ROTATION_THRESHOLD', '30d'))
SAVE_PATH = app.config.get('ACTION_LOG_ARCHIVE_PATH')
SAVE_LOCATION = app.config.get('ACTION_LOG_ARCHIVE_LOCATION')