diff --git a/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py b/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py index e6c64700..f5feb0d0 100644 --- a/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py +++ b/lib/charms/prometheus_k8s/v0/prometheus_remote_write.py @@ -518,7 +518,7 @@ def add_path(self, path: str, *, recursive: bool = False) -> None: elif path.is_file(): self.alert_groups.extend(self._from_file(path.parent, path)) else: - logger.warning("path does not exist: %s", path) + logger.debug("Alert rules path does not exist: %s", path) def as_dict(self) -> dict: """Return standard alert rules file in dict representation. @@ -1052,7 +1052,7 @@ def alerts(self) -> dict: continue if "groups" not in alert_rules: - logger.warning("No alert groups were found in relation data") + logger.debug("No alert groups were found in relation data") continue # Construct an ID based on what's in the alert rules for group in alert_rules["groups"]: diff --git a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py index 3d86cc0d..4e27f238 100644 --- a/lib/charms/prometheus_k8s/v0/prometheus_scrape.py +++ b/lib/charms/prometheus_k8s/v0/prometheus_scrape.py @@ -923,7 +923,7 @@ def add_path(self, path: str, *, recursive: bool = False) -> None: elif path.is_file(): self.alert_groups.extend(self._from_file(path.parent, path)) else: - logger.warning("path does not exist: %s", path) + logger.debug("Alert rules path does not exist: %s", path) def as_dict(self) -> dict: """Return standard alert rules file in dict representation. @@ -1130,7 +1130,7 @@ def _get_identifier_by_alert_rules(self, rules: dict) -> Union[str, None]: rules: a dict of alert rules """ if "groups" not in rules: - logger.warning("No alert groups were found in relation data") + logger.debug("No alert groups were found in relation data") return None # Construct an ID based on what's in the alert rules if they have labels @@ -1543,7 +1543,7 @@ def __init__( try: alert_rules_path = _resolve_dir_against_charm_path(charm, alert_rules_path) except InvalidAlertRulePathError as e: - logger.warning( + logger.debug( "Invalid Prometheus alert rules folder at %s: %s", e.alert_rules_absolute_path, e.message, @@ -1705,7 +1705,7 @@ def __init__( try: dir_path = _resolve_dir_against_charm_path(charm, dir_path) except InvalidAlertRulePathError as e: - logger.warning( + logger.debug( "Invalid Prometheus alert rules folder at %s: %s", e.alert_rules_absolute_path, e.message, diff --git a/tests/unit/test_endpoint_consumer.py b/tests/unit/test_endpoint_consumer.py index 35be61a6..7aeb27bd 100644 --- a/tests/unit/test_endpoint_consumer.py +++ b/tests/unit/test_endpoint_consumer.py @@ -436,9 +436,9 @@ def test_consumer_logs_an_error_on_missing_alerting_data(self): with self.assertLogs(level="WARNING") as logger: _ = self.harness.charm.prometheus_consumer.alerts() messages = logger.output - self.assertEqual(len(messages), 2) + self.assertEqual(len(messages), 1) self.assertIn( - "Alert rules were found but no usable group or identifier was present", messages[1] + "Alert rules were found but no usable group or identifier was present", messages[0] ) def test_consumer_accepts_rules_with_no_identifier(self):