Add log rotation threshold configuration

This commit is contained in:
Sam Chow 2018-06-29 16:07:51 -04:00
parent 31e4c6d380
commit 84f604739f
4 changed files with 26 additions and 1 deletions

View file

@ -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/"

View file

@ -386,6 +386,23 @@
</div>
</td>
</tr>
<tr>
<td>Log Rotation Threshold:</td>
<td>
<span class="config-string-field" binding="config.ACTION_LOG_ROTATION_THRESHOLD"
pattern="[0-9]+(m|w|h|d|s)"></span>
<div class="help-text">
The number of days after which to archive action logs to storage. Must be expressed in a duration string form: <code>30m</code>, <code>1h</code>, <code>1d</code>, <code>2w</code>.
</div>
<div class="help-text">
Note: The rotation threshold should be considered a balancing act between user history and size of database.
</div>
<div class="help-text">
Larger time windows will result in more logs, but give users more history to view.
Anything less than <code>2w</code> is not recommended.
</div>
</td>
</tr>
</table>
</div>

View file

@ -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 ' +

View file

@ -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')