File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,20 +33,18 @@ module PlaceOS::Triggers
3333 result.response_data.result.as(Loki ::Model ::Streams ).each do |resp_stream |
3434 map = resp_stream.labels.map
3535
36- # Nil-safe extraction
36+ # Extract module ID from stream labels
3737 mod_id = map[" source" ]?
38- time_str = map[ " time " ]?
39-
40- next unless mod_id && time_str
41-
42- begin
43- err_time = Time :: Format :: RFC_3339 .parse(time_str)
44- # Keep only the latest error per module
45- if ! module_errors.has_key?(mod_id) || err_time > module_errors[mod_id]
46- module_errors[mod_id] = err_time
38+ next unless mod_id
39+
40+ # Iterate through entries to find the latest error timestamp
41+ resp_stream.entries.each do | entry |
42+ if err_time = entry.timestamp
43+ # Keep only the latest error per module
44+ if ! module_errors.has_key?(mod_id) || err_time > module_errors[mod_id]
45+ module_errors[mod_id] = err_time
46+ end
4747 end
48- rescue ex
49- Log .error(exception: ex) { {message: " Failed to parse timestamp" , module: mod_id, timestamp: time_str} }
5048 end
5149 end
5250
You can’t perform that action at this time.
0 commit comments