Skip to content

Commit

Permalink
Merge pull request #90 from deep-compute/update_changes_haproxy
Browse files Browse the repository at this point in the history
update haproxy handler code of logagg ref #87
  • Loading branch information
deepcompute-agent authored May 10, 2019
2 parents 46a24e5 + 2ed04c4 commit bada9cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions logagg/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ def haproxy(line):
else:
_headers = []

http_version = re.findall(r'(HTTP.*)"', line)
if http_version:
http_version = http_version[0].strip('"').strip()
else:
http_version = ''

line = re.sub(r'(HTTP.*)', '', line).strip()

_line = HAPROXY_HEADERS.sub('', line).strip().split()

_, _, _, haproxy_server, _, client_server_info, timestamp, front_end, \
backend, resp_timings, status, bytes_read, \
_, _, _, conn_stats, inqueue_stats, method, url, http_version = _line
_, _, _, conn_stats, inqueue_stats, method, url = _line

keys = [
'_headers', 'haproxy_server', 'client_server',
Expand Down Expand Up @@ -102,11 +110,22 @@ def haproxy(line):
method = method.strip('"').strip()

_url = url.strip().split('?')
url_path, url_params = [u.strip() for u in _url]
url_params = ''
if len(_url) == 2:
url_path, url_params = [u.strip() for u in _url]
else:
url_path = _url[0]

_url_params = {}
for params in url_params.split('&'):
key, val = params.strip().split('=')
if not params:
continue

_p = params.strip().split('=')
if not len(_p) == 2:
continue

key, val = _p
_url_params[key.strip()] = val.strip()

http_version = http_version.strip('"').strip()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="logagg",
version="0.3.4",
version="0.3.5",
description="logs aggregation framework",
keywords="logagg",
author="Deep Compute, LLC",
Expand Down

0 comments on commit bada9cc

Please sign in to comment.