feat(export): contract-conformant event_logs event_time and is_active
Reanimator contract v2.13 makes event_logs[].event_time optional
(Reanimator falls back to collection/ingest time) and defines is_active
("still active / not cleared").
- Omit event_time when the event has no source time instead of passing
collected_at off as the event time.
- is_active=true only from an authoritative active-alarm snapshot: Inspur
dev_status.log (IDL event ID / SEL sensor at the same instant) and
component.log fan state (new models.Event.Active). false for Deasserts,
superseded Asserts in a real Assert/Deassert lifecycle and Inspur
Warning/Critical Asserts missing from dev_status.log; unset otherwise.
A missing Deassert is not treated as active: AC loss and BMC resets drop
them (24C319575: PSU1 predictive failure).
- component.log fan events use source BMC instead of host.
- Request installed_at in the Reanimator contract to date component
installs from maintenance.log; follow-up in BACKLOG [installed_at].
ADL-072.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
693906ceba
commit
2ce60280c3
10 files changed
+423
-11
No files matched your search
@@ -51,7 +51,7 @@ func ConvertToReanimator(result *models.AnalysisResult) (*ReanimatorExport, erro
|
||||
PCIeDevices: dedupePCIe(convertPCIeFromDevices(devices, collectedAt)),
|
||||
PowerSupplies: disambiguatePSUSlots(dedupePSUs(convertPSUsFromDevices(devices, collectedAt))),
|
||||
Sensors: convertSensors(result.Sensors),
|
||||
EventLogs: convertEventLogs(result.Events, collectedAt),
|
||||
EventLogs: convertEventLogs(result.Events),
|
||||
Licenses: dedupeLicenses(convertLicenses(result.Hardware.Licenses, collectedAt)),
|
||||
},
|
||||
}
|
||||
@@ -1253,13 +1253,14 @@ func convertPSUsFromDevices(devices []models.HardwareDevice, collectedAt string)
|
||||
return result
|
||||
}
|
||||
|
||||
func convertEventLogs(events []models.Event, collectedAt string) []ReanimatorEventLog {
|
||||
func convertEventLogs(events []models.Event) []ReanimatorEventLog {
|
||||
if len(events) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
activeByIndex := deriveEventLogActive(events)
|
||||
out := make([]ReanimatorEventLog, 0, len(events))
|
||||
for _, event := range events {
|
||||
for i, event := range events {
|
||||
source := normalizeEventLogSource(event.Source)
|
||||
message := strings.TrimSpace(event.Description)
|
||||
if source == "" || message == "" {
|
||||
@@ -1268,11 +1269,12 @@ func convertEventLogs(events []models.Event, collectedAt string) []ReanimatorEve
|
||||
|
||||
item := ReanimatorEventLog{
|
||||
Source: source,
|
||||
EventTime: formatEventLogTime(event.Timestamp, collectedAt),
|
||||
EventTime: formatEventLogTime(event.Timestamp),
|
||||
Severity: normalizeEventLogSeverity(event.Severity),
|
||||
MessageID: strings.TrimSpace(event.ID),
|
||||
Message: message,
|
||||
ComponentRef: firstNonEmptyString(strings.TrimSpace(event.SensorName), strings.TrimSpace(event.SensorType)),
|
||||
IsActive: activeByIndex[i],
|
||||
}
|
||||
if raw := strings.TrimSpace(event.RawData); raw != "" {
|
||||
item.RawPayload = map[string]any{
|
||||
@@ -1494,11 +1496,94 @@ func normalizeEventLogSeverity(severity models.Severity) string {
|
||||
}
|
||||
}
|
||||
|
||||
func formatEventLogTime(ts time.Time, collectedAt string) string {
|
||||
if !ts.IsZero() {
|
||||
return ts.UTC().Format(time.RFC3339)
|
||||
// formatEventLogTime leaves event_time empty when the source gave no time:
|
||||
// the contract makes Reanimator fall back to collection/ingest time itself,
|
||||
// so the export must not pass collection time off as the event time.
|
||||
func formatEventLogTime(ts time.Time) string {
|
||||
if ts.IsZero() {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(collectedAt)
|
||||
return ts.UTC().Format(time.RFC3339)
|
||||
}
|
||||
|
||||
// deriveEventLogActive fills event_logs[].is_active. An explicit
|
||||
// models.Event.Active (set by a parser from an authoritative active-alarm
|
||||
// snapshot) wins. Otherwise only "inactive" is derived: within a condition
|
||||
// that has real Assert/Deassert lifecycle, every Deassert and every Assert
|
||||
// followed by a later record is inactive. The latest Assert stays unknown:
|
||||
// a missing Deassert does not prove the condition still holds (BMC resets
|
||||
// and AC loss drop Deasserts), and the contract forbids synthesizing it.
|
||||
func deriveEventLogActive(events []models.Event) map[int]*bool {
|
||||
out := make(map[int]*bool, len(events))
|
||||
groups := make(map[string][]int)
|
||||
for i, event := range events {
|
||||
if event.Active != nil {
|
||||
v := *event.Active
|
||||
out[i] = &v
|
||||
continue
|
||||
}
|
||||
key, ok := eventLifecycleKey(event)
|
||||
if !ok || event.Timestamp.IsZero() {
|
||||
continue
|
||||
}
|
||||
groups[key] = append(groups[key], i)
|
||||
}
|
||||
for _, idx := range groups {
|
||||
hasDeassert := false
|
||||
latest := idx[0]
|
||||
for _, i := range idx {
|
||||
if eventLifecyclePhase(events[i]) == "deassert" {
|
||||
hasDeassert = true
|
||||
}
|
||||
if !events[i].Timestamp.Before(events[latest].Timestamp) {
|
||||
latest = i
|
||||
}
|
||||
}
|
||||
if !hasDeassert {
|
||||
continue
|
||||
}
|
||||
for _, i := range idx {
|
||||
if i == latest && eventLifecyclePhase(events[i]) == "assert" {
|
||||
continue
|
||||
}
|
||||
inactive := false
|
||||
out[i] = &inactive
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func eventLifecycleKey(event models.Event) (string, bool) {
|
||||
if eventLifecyclePhase(event) == "" {
|
||||
return "", false
|
||||
}
|
||||
sensor := strings.ToLower(strings.TrimSpace(event.SensorName))
|
||||
if sensor == "" {
|
||||
return "", false
|
||||
}
|
||||
// IDL-style records keep the condition in the message ID and put the
|
||||
// phase in EventType; SEL-style records keep the condition in EventType.
|
||||
condition := strings.ToLower(strings.TrimSpace(event.EventType))
|
||||
if condition == "assert" || condition == "deassert" || condition == "asserted" || condition == "deasserted" {
|
||||
condition = strings.ToLower(strings.TrimSpace(event.ID))
|
||||
}
|
||||
if condition == "" {
|
||||
return "", false
|
||||
}
|
||||
return normalizeEventLogSource(event.Source) + "|" + strings.ToLower(strings.TrimSpace(event.SensorType)) + "|" + sensor + "|" + condition, true
|
||||
}
|
||||
|
||||
func eventLifecyclePhase(event models.Event) string {
|
||||
for _, s := range []string{event.EventType, event.RawData} {
|
||||
lower := strings.ToLower(s)
|
||||
switch {
|
||||
case strings.Contains(lower, "deassert"):
|
||||
return "deassert"
|
||||
case strings.Contains(lower, "assert"):
|
||||
return "assert"
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func manufacturedYearWeekFromDetails(details map[string]any) string {
|
||||
|
||||
Reference in new issue
Block a user