@cryptotaxi247 / netdata-1 / commits / aa27c1f95

web_log Virtual host enhancement and http/https (#4076)

* Added graphs in web_log to track the virtual hosts and the port number (http vs https) * Corrections following 1st PR * Fixed contributors * Removed initialization if port_80 & port_443

Julien Grossiord committed Sep 14, 2018 at 19:59 UTC aa27c1f95aaddfcdb09419da81e0fb20e925e782
3 files changed +42 -1
CONTRIBUTORS.md
+1
@@ -111,3 +111,4 @@ username|name|email (optional)
111 @plasticrake|Patrick Seal
112 @jonfairbanks|Jon Fairbanks
113 @pjz|Paul Jimenez|pj@place.org
114 +@jgrossiord|Julien Grossiord|julien@grossiord.net
conf.d/python.d/web_log.conf
+11
@@ -108,6 +108,17 @@
108 # LogFormat "%h %l %u %t \"%r\" %>s %O %I %D \"%{Referer}i\" \"%{User-Agent}i\"" netdata
109 # CustomLog "/var/log/apache2/access.log" netdata
110
111 +# ----------------------------------------------------------------------
112 +# VHOST AND PORT
113 +# if your want to graph the request/sec per virtual host and per port (to check the number of requests in http vs https)
114 +
115 +# in apache : (%v gives the hostname, %p the port number)
116 +# LogFormat "%v %p %h %t \"%r\" %>s %O %I %D \"%{Referer}i\" \"%{User-Agent}i\"" vhost_netdata
117 +#
118 +# and in this file in apache_vhosts_log section, add :
119 +# custom_log_format:
120 +# pattern: '(?P<vhost>[a-zA-Z\d.-_]+) (?P<port>\d+) (?P<address>[\da-f.:]+) \[.*\] "(?P<method>[A-Z]+)[^"]*" (?P<code>[1-9]\d{2}) (?P<bytes_sent>\d+) (?P<resp_length>\d+) (?P<resp_time>\d+)'
121 +
122 # ----------------------------------------------------------------------
123 # AUTO-DETECTION JOBS
124 # only one of them per web server will run (when they have the same name)
python.d/web_log.chart.py
+30 -1
@@ -29,7 +29,7 @@ ORDER_APACHE_CACHE = ['apache_cache']
29
30 ORDER_WEB = ['response_statuses', 'response_codes', 'bandwidth',
31 'response_time', 'response_time_hist', 'response_time_upstream', 'response_time_upstream_hist',
32 - 'requests_per_url', 'requests_per_user_defined', 'http_method', 'http_version',
32 + 'requests_per_url', 'requests_per_user_defined', 'http_method', 'vhost', 'port', 'http_version',
33 'requests_per_ipproto', 'clients', 'clients_all']
34
35 ORDER_SQUID = ['squid_response_statuses', 'squid_response_codes', 'squid_detailed_response_codes',
@@ -128,6 +128,18 @@ CHARTS_WEB = {
128 'web_log.requests_per_user_defined', 'stacked'],
129 'lines': [
130 ['user_pattern_other', 'other', 'incremental', 1, 1]
131 + ]},
132 + 'port': {
133 + 'options': [None, 'Requests Per Port', 'requests/s', 'port',
134 + 'web_log.port', 'stacked'],
135 + 'lines': [
136 + ['port_80', 'http', 'incremental', 1, 1],
137 + ['port_443', 'https', 'incremental', 1, 1]
138 + ]},
139 + 'vhost': {
140 + 'options': [None, 'Requests Per Vhost', 'requests/s', 'vhost',
141 + 'web_log.vhost', 'stacked'],
142 + 'lines': [
143 ]}
144 }
145
@@ -707,6 +719,23 @@ class Web:
719 'incremental'])
720 self.data[dim_id] = 0
721 self.data[dim_id] += 1
722 + # requests per port number
723 + if match_dict.get('port'):
724 + if match_dict['port'] not in self.data:
725 + self.charts['port'].add_dimension([match_dict['port'],
726 + match_dict['port'],
727 + 'incremental'])
728 + self.data[match_dict['port']] = 0
729 + self.data[match_dict['port']] += 1
730 + # requests per vhost
731 + if match_dict.get('vhost'):
732 + dim_id = match_dict['vhost'].replace('.', '_')
733 + if dim_id not in self.data:
734 + self.charts['vhost'].add_dimension([dim_id,
735 + match_dict['vhost'],
736 + 'incremental'])
737 + self.data[dim_id] = 0
738 + self.data[dim_id] += 1
739
740 def get_data_per_response_codes_detailed(self, code):
741 """