From f1e69bf39b685afd5624f54562bfab5dbd4884e5 Mon Sep 17 00:00:00 2001 From: Patrick Fruh Date: Mon, 25 Feb 2019 06:59:02 +0100 Subject: [PATCH] Fixed metric latency unit and logging (#49) * move latency_unit into cachet dictionary * log actual metric latency_unit * also update config in readme * also update config description in readme --- README.md | 4 ++-- cachet_url_monitor/configuration.py | 2 +- config.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e89bc7..38f68a3 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ cachet: - CREATE_INCIDENT - UPDATE_STATUS public_incidents: true + latency_unit: ms frequency: 30 -latency_unit: ms ``` - **endpoint**, the configuration about the URL that will be monitored. @@ -59,8 +59,8 @@ latency_unit: ms - **CREATE_INCIDENT**, we will create an incident when the expectation fails. - **UPDATE_STATUS**, updates the component status - **public_incidents**, boolean to decide if created incidents should be visible to everyone or only to logged in users. Important only if `CREATE_INCIDENT` or `UPDATE_STATUS` are set. + - **latency_unit**, the latency unit used when reporting the metrics. It will automatically convert to the specified unit. It's not mandatory and it will default to **seconds**. Available units: `ms`, `s`, `m`, `h`. - **frequency**, how often we'll send a request to the given URL. The unit is in seconds. -- **latency_unit**, the latency unit used when reporting the metrics. It will automatically convert to the specified unit. It's not mandatory and it will default to **seconds**. Available units: `ms`, `s`, `m`, `h`. ## Setting up diff --git a/cachet_url_monitor/configuration.py b/cachet_url_monitor/configuration.py index 94730a5..3e3e695 100644 --- a/cachet_url_monitor/configuration.py +++ b/cachet_url_monitor/configuration.py @@ -264,7 +264,7 @@ class Configuration(object): if metrics_request.ok: # Successful metrics upload - self.logger.info('Metric uploaded: %.6f seconds' % (value,)) + self.logger.info('Metric uploaded: %.6f %s' % (value, self.latency_unit)) else: self.logger.warning('Metric upload failed with status [%d]' % (metrics_request.status_code,)) diff --git a/config.yml b/config.yml index 44bb471..7b52bd6 100644 --- a/config.yml +++ b/config.yml @@ -19,5 +19,5 @@ cachet: - CREATE_INCIDENT - UPDATE_STATUS public_incidents: true + latency_unit: ms frequency: 30 -latency_unit: ms