feat(configs): allow json log format for gunicorn
This commit is contained in:
parent
c9251167df
commit
0147b82c20
1 changed files with 28 additions and 3 deletions
|
|
@ -13,6 +13,7 @@ import traceback
|
|||
import random
|
||||
import socket
|
||||
import dataclasses
|
||||
import json
|
||||
from gunicorn.glogging import Logger
|
||||
|
||||
|
||||
|
|
@ -37,17 +38,41 @@ accesslog = '-'
|
|||
worker_tmp_dir = None
|
||||
tmp_upload_dir = None
|
||||
|
||||
# use re-use port logic
|
||||
#reuse_port = True
|
||||
# use re-use port logic to let linux internals load-balance the requests better.
|
||||
reuse_port = True
|
||||
|
||||
# Custom log format
|
||||
#access_log_format = (
|
||||
# '%(t)s %(p)s INFO [GNCRN] %(h)-15s rqt:%(L)s %(s)s %(b)-6s "%(m)s:%(U)s %(q)s" usr:%(u)s "%(f)s" "%(a)s"')
|
||||
|
||||
# loki format for easier parsing in grafana
|
||||
access_log_format = (
|
||||
loki_access_log_format = (
|
||||
'time="%(t)s" pid=%(p)s level="INFO" type="[GNCRN]" ip="%(h)-15s" rqt="%(L)s" response_code="%(s)s" response_bytes="%(b)-6s" uri="%(m)s:%(U)s %(q)s" user=":%(u)s" user_agent="%(a)s"')
|
||||
|
||||
# JSON format
|
||||
json_access_log_format = json.dumps({
|
||||
'time': r'%(t)s',
|
||||
'pid': r'%(p)s',
|
||||
'level': 'INFO',
|
||||
'ip': r'%(h)s',
|
||||
'request_time': r'%(L)s',
|
||||
'remote_address': r'%(h)s',
|
||||
'user_name': r'%(u)s',
|
||||
'status': r'%(s)s',
|
||||
'method': r'%(m)s',
|
||||
'url_path': r'%(U)s',
|
||||
'query_string': r'%(q)s',
|
||||
'protocol': r'%(H)s',
|
||||
'response_length': r'%(B)s',
|
||||
'referer': r'%(f)s',
|
||||
'user_agent': r'%(a)s',
|
||||
|
||||
})
|
||||
|
||||
access_log_format = loki_access_log_format
|
||||
if os.environ.get('RC_LOGGING_FORMATTER') == 'json':
|
||||
access_log_format = json_access_log_format
|
||||
|
||||
# self adjust workers based on CPU count, to use maximum of CPU and not overquota the resources
|
||||
# workers = get_workers()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue