Skip to content

Commit

Permalink
fix both libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabello committed Feb 5, 2025
1 parent cd6dd4c commit 6ce1c1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/charms/prometheus_k8s/v0/prometheus_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ def set_scrape_job_spec(self, _=None):
if not self._disable_alerts:
alert_rules.add_path(self._alert_rules_path, recursive=True)
alert_rules_as_dict = alert_rules.as_dict()
logger.info(f"+++ alert_rules_as_dict: {alert_rules_as_dict}") # TODO: remove, debug

for relation in self._charm.model.relations[self._relation_name]:
relation.data[self._charm.app]["scrape_metadata"] = json.dumps(self._scrape_metadata)
Expand Down
5 changes: 4 additions & 1 deletion lib/charms/prometheus_k8s/v1/prometheus_remote_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ def __init__(
self.framework.observe(
self._charm.on.upgrade_charm, self._push_alerts_to_all_relation_databags
)
self.framework.observe(
self._charm.on.config_changed, self._push_alerts_to_all_relation_databags
)

def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
self.on.endpoints_changed.emit(relation_id=event.relation.id)
Expand Down Expand Up @@ -492,7 +495,7 @@ def _push_alerts_to_relation_databag(self, relation: Relation) -> None:

alert_rules_as_dict = alert_rules.as_dict()

if alert_rules_as_dict:
if alert_rules_as_dict or self._disable_alerts:
relation.data[self._charm.app]["alert_rules"] = json.dumps(alert_rules_as_dict)

def reload_alerts(self) -> None:
Expand Down

0 comments on commit 6ce1c1b

Please # to comment.