-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: Alerts From Kafka Provider Failed #2823
Comments
Hey @Riete! I'm here to help with any bugs, questions, or contributions you have. Let's tackle this issue together! To resolve the issue where alerts are not generated due to a missing "lastReceived" key in a JSON message sent to a Kafka topic, you can modify the code to ensure that the # Make sure the lastReceived is a valid date string
# tb: we do this because `AlertDto` object lastReceived is a string and not a datetime object
# TODO: `AlertDto` object `lastReceived` should be a datetime object so we can easily validate with pydantic
if not formatted_event.lastReceived:
formatted_event.lastReceived = datetime.datetime.now(
tz=datetime.timezone.utc
).isoformat()
else:
try:
dateutil.parser.isoparse(formatted_event.lastReceived)
except ValueError:
logger.warning("Invalid lastReceived date, setting to now")
formatted_event.lastReceived = datetime.datetime.now(
tz=datetime.timezone.utc
).isoformat() This code snippet checks if the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Thanks for opening the issue @Riete! We will fix it right away |
@Riete Pushed a quick fix for this one. It should be fine now, if you pull the latest version. Let me know if it still occurs somehow. |
Describe the bug
if json message which missing "lastReceived" key sent to kafka topic, the alerts will not generated
To Reproduce
Steps to reproduce the behavior:
Expected behavior
can receive alerts
Screenshots
N/A
Additional context
After some research and add trace code, I found when the messages sent to kafka topic missing " lastReceived" key, it will report "Error pushing alert to API", and trace is as following:
if sent messsage contains "lastReceived" key, the alerts will generate normally
The text was updated successfully, but these errors were encountered: