diff --git a/services/node-agent/src/node_agent.py b/services/node-agent/src/node_agent.py index b14d8fc..d49c006 100644 --- a/services/node-agent/src/node_agent.py +++ b/services/node-agent/src/node_agent.py @@ -27,6 +27,7 @@ NEVER TOUCHED on any node: import json import logging import os +import re import shutil import socket import subprocess @@ -153,7 +154,11 @@ class NodeAgent: def emit_event(self, event_type: str, severity: str, service, message: str, payload: dict = None): ts = int(time.time()) - event_id = f"evt-{self.node_name}-{ts}-{event_type}" + # Include service slug in the ID so that multiple events of the same type + # emitted within the same second (e.g. service_healthy for N containers) + # don't overwrite each other — each gets a unique filename. + svc_slug = re.sub(r"[^a-z0-9]", "-", (service or "node").lower())[:32].strip("-") + event_id = f"evt-{self.node_name}-{ts}-{event_type}-{svc_slug}" event = { "id": event_id, "timestamp": ts,