Skip to content

Commit 200109c

Browse files
authored
Aded django-resilient-logger configurations (#378)
1 parent 1d9dd8b commit 200109c

File tree

3 files changed

+487
-337
lines changed

3 files changed

+487
-337
lines changed

kaavapino/settings.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
ELASTIC_APM_SERVER_URL=(str, ""),
5959
ELASTIC_APM_SERVICE_NAME=(str, ""),
6060
ELASTIC_APM_SECRET_TOKEN=(str, ""),
61+
AUDIT_LOG_ENV=(str, ""),
62+
AUDIT_LOG_ES_URL=(str, ""),
63+
AUDIT_LOG_ES_USERNAME=(str, ""),
64+
AUDIT_LOG_ES_PASSWORD=(str, ""),
65+
AUDIT_LOG_ES_INDEX=(str, ""),
6166
)
6267

6368
env_file = project_root(".env")
@@ -190,6 +195,7 @@
190195
"django_q",
191196
"drf_spectacular",
192197
"auditlog",
198+
"resilient_logger"
193199
]
194200

195201
if env.str("ELASTIC_APM_SERVER_URL") and env.str("ELASTIC_APM_SECRET_TOKEN"):
@@ -259,6 +265,9 @@
259265
'version': 1,
260266
'disable_existing_loggers': False,
261267
'handlers': {
268+
'resilient': {
269+
"class": "resilient_logger.handlers.ResilientLogHandler",
270+
},
262271
'stdout': {
263272
'level': 'INFO',
264273
'class': 'logging.StreamHandler',
@@ -353,3 +362,26 @@
353362
# Auditlog
354363
AUDITLOG_DISABLE_REMOTE_ADDR = False
355364
AUDITLOG_DISABLE_ON_RAW_SAVE = True
365+
366+
# Resilient logger
367+
if env.str("AUDIT_LOG_ES_URL") and env.str("AUDIT_LOG_ES_USERNAME") and env.str("AUDIT_LOG_ES_PASSWORD") and env.str("AUDIT_LOG_ES_INDEX"):
368+
RESILIENT_LOGGER = {
369+
"origin": "Kaavapino",
370+
"environment": env("AUDIT_LOG_ENV"),
371+
"sources": [
372+
{ "class": "resilient_logger.sources.ResilientLogSource" },
373+
{ "class": "resilient_logger.sources.DjangoAuditLogSource" },
374+
],
375+
"targets": [{
376+
"class": "resilient_logger.targets.ElasticsearchLogTarget",
377+
"es_url": env("AUDIT_LOG_ES_URL"),
378+
"es_username": env("AUDIT_LOG_ES_USERNAME"),
379+
"es_password": env("AUDIT_LOG_ES_PASSWORD"),
380+
"es_index": env("AUDIT_LOG_ES_INDEX"),
381+
"required": True
382+
}],
383+
"batch_limit": 5000,
384+
"chunk_size": 500,
385+
"submit_unsent_entries": True,
386+
"clear_sent_entries": True,
387+
}

0 commit comments

Comments
 (0)