web_log plugin: localhost added to the "address" regex"
Ilya committed
Sep 6, 2017 at 16:15 UTC
b1e5ccc2ac74149a62d4168ec15da8c984266e62
1 file changed
+5
-5
python.d/web_log.chart.py
+5
-5
@@ -528,7 +528,7 @@ class Web(Mixin):
528
get_timings(timings=timings['resp_time_upstream'],
529
time=self.storage['func_resp_time'](float(match_dict['resp_time_upstream'])))
530
# requests per ip proto
531
- proto = 'ipv4' if '.' in match_dict['address'] else 'ipv6'
531
+ proto = 'ipv6' if ':' in match_dict['address'] else 'ipv4'
532
self.data['req_' + proto] += 1
533
# unique clients ips
534
if self.conf.get('all_time', True):
@@ -561,14 +561,14 @@ class Web(Mixin):
561
"""
562
# REGEX: 1.IPv4 address 2.HTTP method 3. URL 4. Response code
563
# 5. Bytes sent 6. Response length 7. Response process time
564
- default = re.compile(r'(?P<address>[\da-f.:]+)'
564
+ default = re.compile(r'(?P<address>[\da-f.:]+|localhost)'
565
r' -.*?"(?P<method>[A-Z]+)'
566
r' (?P<url>[^ ]+)'
567
r' [A-Z]+/(?P<http_version>\d\.\d)"'
568
r' (?P<code>[1-9]\d{2})'
569
r' (?P<bytes_sent>\d+|-)')
570
571
- apache_ext_insert = re.compile(r'(?P<address>[\da-f.:]+)'
571
+ apache_ext_insert = re.compile(r'(?P<address>[\da-f.:]+|localhost)'
572
r' -.*?"(?P<method>[A-Z]+)'
573
r' (?P<url>[^ ]+)'
574
r' [A-Z]+/(?P<http_version>\d\.\d)"'
@@ -577,7 +577,7 @@ class Web(Mixin):
577
r' (?P<resp_length>\d+)'
578
r' (?P<resp_time>\d+) ')
579
580
- apache_ext_append = re.compile(r'(?P<address>[\da-f.:]+)'
580
+ apache_ext_append = re.compile(r'(?P<address>[\da-f.:]+|localhost)'
581
r' -.*?"(?P<method>[A-Z]+)'
582
r' (?P<url>[^ ]+)'
583
r' [A-Z]+/(?P<http_version>\d\.\d)"'
@@ -693,7 +693,7 @@ class Web(Mixin):
693
if match_dict is None:
694
return find_regex_return(msg='Custom log: search OK but contains no named subgroups'
695
' (you need to use ?P<subgroup_name>)')
696
- mandatory_dict = {'address': r'[\da-f.:]+',
696
+ mandatory_dict = {'address': r'[\da-f.:]+|localhost',
697
'code': r'[1-9]\d{2}',
698
'method': r'[A-Z]+',
699
'bytes_sent': r'\d+|-'}