From 5c1693994e822728712cb10859d7ac5b79aa7fd7 Mon Sep 17 00:00:00 2001 From: Chris Christiansen Date: Wed, 27 May 2026 17:29:22 +0000 Subject: [PATCH] feat(cg6): publish anomalies to Pub/Sub topic --- ml/anomaly_detector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ml/anomaly_detector.py b/ml/anomaly_detector.py index d2a14c0..5d4ce62 100644 --- a/ml/anomaly_detector.py +++ b/ml/anomaly_detector.py @@ -14,7 +14,7 @@ class AnomalyDetector: if not self.billing_table: raise ValueError("BILLING_TABLE environment variable not set.") - self.pubsub_topic_name = os.environ.get("PUBSUB_TOPIC", "billing_alerts") + self.pubsub_topic_name = os.environ.get("ANOMALY_TOPIC", "osvauco-billing-anomalies") self.bq_client = bigquery.Client(project=self.project_id) self.publisher = pubsub_v1.PublisherClient() self.topic_path = self.publisher.topic_path(self.project_id, self.pubsub_topic_name) @@ -77,7 +77,7 @@ class AnomalyDetector: "today_cost": anomaly["today_cost"], "avg_7d": anomaly["avg_7d"], "ratio": anomaly["ratio"], - "timestamp": datetime.datetime.now().isoformat() + "timestamp_utc": datetime.datetime.utcnow().isoformat() } message_bytes = json.dumps(message_data).encode("utf-8") self.publisher.publish(self.topic_path, data=message_bytes)