diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/python.d.plugin/traefik/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/python.d.plugin/traefik/README.md | 54 | ||||
-rw-r--r-- | collectors/python.d.plugin/traefik/traefik.chart.py (renamed from python.d/traefik.chart.py) | 40 | ||||
-rw-r--r-- | collectors/python.d.plugin/traefik/traefik.conf (renamed from conf.d/python.d/traefik.conf) | 0 |
4 files changed, 94 insertions, 13 deletions
diff --git a/collectors/python.d.plugin/traefik/Makefile.inc b/collectors/python.d.plugin/traefik/Makefile.inc new file mode 100644 index 000000000..926d56dda --- /dev/null +++ b/collectors/python.d.plugin/traefik/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_python_DATA += traefik/traefik.chart.py +dist_pythonconfig_DATA += traefik/traefik.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += traefik/README.md traefik/Makefile.inc + diff --git a/collectors/python.d.plugin/traefik/README.md b/collectors/python.d.plugin/traefik/README.md new file mode 100644 index 000000000..9b4a18208 --- /dev/null +++ b/collectors/python.d.plugin/traefik/README.md @@ -0,0 +1,54 @@ +# traefik + +Module uses the `health` API to provide statistics. + +It produces: + +1. **Responses** by statuses + * success (1xx, 2xx, 304) + * error (5xx) + * redirect (3xx except 304) + * bad (4xx) + * other (all other responses) + +2. **Responses** by codes + * 2xx (successful) + * 5xx (internal server errors) + * 3xx (redirect) + * 4xx (bad) + * 1xx (informational) + * other (non-standart responses) + +3. **Detailed Response Codes** requests/s (number of responses for each response code family individually) + +4. **Requests**/s + * request statistics + +5. **Total response time** + * sum of all response time + +6. **Average response time** + +7. **Average response time per iteration** + +8. **Uptime** + * Traefik server uptime + +### configuration + +Needs only `url` to server's `health` + +Here is an example for local server: + +```yaml +update_every : 1 +priority : 60000 + +local: + url : 'http://localhost:8080/health' + retries : 10 +``` + +Without configuration, module attempts to connect to `http://localhost:8080/health`. + +--- diff --git a/python.d/traefik.chart.py b/collectors/python.d.plugin/traefik/traefik.chart.py index f7c3e223b..dc8933220 100644 --- a/python.d/traefik.chart.py +++ b/collectors/python.d.plugin/traefik/traefik.chart.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Description: traefik netdata python.d module # Author: Alexandre Menezes (@ale_menezes) +# SPDX-License-Identifier: GPL-3.0-or-later from json import loads from collections import defaultdict @@ -32,7 +33,8 @@ CHARTS = { ['redirects', 'redirect', 'incremental'], ['bad_requests', 'bad', 'incremental'], ['other_requests', 'other', 'incremental'] - ]}, + ] + }, 'response_codes': { 'options': [None, 'Responses by codes', 'requests/s', 'responses', 'traefik.response_codes', 'stacked'], 'lines': [ @@ -42,37 +44,45 @@ CHARTS = { ['4xx', None, 'incremental'], ['1xx', None, 'incremental'], ['other', None, 'incremental'] - ]}, + ] + }, 'detailed_response_codes': { - 'options': [None, 'Detailed response codes', 'requests/s', 'responses', 'traefik.detailed_response_codes', 'stacked'], - 'lines': [ - ]}, + 'options': [None, 'Detailed response codes', 'requests/s', 'responses', 'traefik.detailed_response_codes', + 'stacked'], + 'lines': [] + }, 'requests': { 'options': [None, 'Requests', 'requests/s', 'requests', 'traefik.requests', 'line'], 'lines': [ ['total_count', 'requests', 'incremental'] - ]}, + ] + }, 'total_response_time': { 'options': [None, 'Total response time', 'seconds', 'timings', 'traefik.total_response_time', 'line'], 'lines': [ ['total_response_time_sec', 'response', 'absolute', 1, 10000] - ]}, + ] + }, 'average_response_time': { 'options': [None, 'Average response time', 'milliseconds', 'timings', 'traefik.average_response_time', 'line'], 'lines': [ ['average_response_time_sec', 'response', 'absolute', 1, 1000] - ]}, + ] + }, 'average_response_time_per_iteration': { - 'options': [None, 'Average response time per iteration', 'milliseconds', 'timings', 'traefik.average_response_time_per_iteration', 'line'], + 'options': [None, 'Average response time per iteration', 'milliseconds', 'timings', + 'traefik.average_response_time_per_iteration', 'line'], 'lines': [ ['average_response_time_per_iteration_sec', 'response', 'incremental', 1, 10000] - ]}, + ] + }, 'uptime': { 'options': [None, 'Uptime', 'seconds', 'uptime', 'traefik.uptime', 'line'], 'lines': [ ['uptime_sec', 'uptime', 'absolute'] - ]} + ] } +} HEALTH_STATS = [ 'uptime_sec', @@ -82,6 +92,7 @@ HEALTH_STATS = [ 'total_status_code_count' ] + class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) @@ -116,9 +127,11 @@ class Service(UrlService): self.data['average_response_time_sec'] *= 1000000 self.data['total_response_time_sec'] *= 10000 if data['total_count'] != self.last_total_count: - self.data['average_response_time_per_iteration_sec'] = (data['total_response_time_sec'] - self.last_total_response_time) * 1000000 / (data['total_count'] - self.last_total_count) + self.data['average_response_time_per_iteration_sec'] = \ + (data['total_response_time_sec'] - self.last_total_response_time) * \ + 1000000 / (data['total_count'] - self.last_total_count) else: - self.data['average_response_time_per_iteration_sec'] = 0 + self.data['average_response_time_per_iteration_sec'] = 0 self.last_total_response_time = data['total_response_time_sec'] self.last_total_count = data['total_count'] @@ -165,6 +178,7 @@ class Service(UrlService): self.charts['detailed_response_codes'].add_dimension([code, code, 'incremental']) self.data[code] = value + def fetch_data_(raw_data, metrics): data = dict() diff --git a/conf.d/python.d/traefik.conf b/collectors/python.d.plugin/traefik/traefik.conf index 909b9e549..909b9e549 100644 --- a/conf.d/python.d/traefik.conf +++ b/collectors/python.d.plugin/traefik/traefik.conf |