Skip to content

Commit

Permalink
fix Alertmanager settings to use proper scheme (#291)
Browse files Browse the repository at this point in the history
* fix Alertmanager settings to use proper scheme

* update grafana_source lib
  • Loading branch information
Abuelodelanada authored Jul 26, 2023
1 parent 5a826f1 commit efb4261
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ def _alerting_config(self) -> str:
to send notifications to.
"""
alerting_config = ""
alertmanagers = self.alertmanager_consumer.get_cluster_info()
alertmanagers = self.alertmanager_consumer.get_cluster_info_with_scheme()

if not alertmanagers:
logger.debug("No alertmanagers available")
return alerting_config

return ",".join([f"http://{am}" for am in alertmanagers])
return ",".join(alertmanagers)

def _running_config(self) -> Dict[str, Any]:
"""Get the on-disk Loki config."""
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ def setUp(self, *_):

def test__alerting_config(self):
self.harness.charm.alertmanager_consumer = Mock()
self.harness.charm.alertmanager_consumer.get_cluster_info.return_value = [
"10.1.2.52",
"10.1.3.52",
self.harness.charm.alertmanager_consumer.get_cluster_info_with_scheme.return_value = [
"http://10.1.2.52",
"http://10.1.3.52",
]
expected_value = "http://10.1.2.52,http://10.1.3.52"
self.assertEqual(self.harness.charm._alerting_config(), expected_value)

self.harness.charm.alertmanager_consumer.get_cluster_info.return_value = []
self.harness.charm.alertmanager_consumer.get_cluster_info_with_scheme.return_value = []
expected_value = ""
self.assertEqual(self.harness.charm._alerting_config(), expected_value)

Expand Down

0 comments on commit efb4261

Please sign in to comment.