fix: never use parse time as event or collection time
Dump data is always historical. Parsers stamped undated events with time.Now() (Inspur component.log memory/fan status, IDL/H3C SEL with unparsable time, NVIDIA summary/bug-report, generic, XigmaNAS, Unraid, Redfish replay warnings), so an August dump opened in September showed DIMM warnings dated the day of analysis. - Events without a source time keep a zero timestamp. - Yearless syslog timestamps take the year from the collection time via parser.ParseYearlessInDefaultArchiveLocation; zero when unknown. - Archive/uploaded-snapshot collected_at is no longer defaulted to now; only live API collection uses the current time. ADL-070. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8794e0adec
commit
f2ad0aca96
19 files changed
+95
-85
No files matched your search
+6
-12
@@ -86,7 +86,7 @@ func (p *Parser) Parse(files []parser.ExtractedFile) (*models.AnalysisResult, er
|
||||
parseUptime(content, result)
|
||||
parseZFSState(content, result)
|
||||
parseStorageAndSMART(content, result)
|
||||
parseJournalLogSections(content, result)
|
||||
parseJournalLogSections(content, parser.InferCollectedAtFromExtractedFiles(files), result)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -195,7 +195,6 @@ func parseUptime(content string, result *models.AnalysisResult) {
|
||||
}
|
||||
|
||||
result.Events = append(result.Events, models.Event{
|
||||
Timestamp: time.Now(),
|
||||
Source: "System",
|
||||
EventType: "Uptime",
|
||||
Severity: models.SeverityInfo,
|
||||
@@ -216,7 +215,6 @@ func parseZFSState(content string, result *models.AnalysisResult) {
|
||||
severity = models.SeverityWarning
|
||||
}
|
||||
result.Events = append(result.Events, models.Event{
|
||||
Timestamp: time.Now(),
|
||||
Source: "ZFS",
|
||||
EventType: "Pool State",
|
||||
Severity: severity,
|
||||
@@ -296,7 +294,6 @@ func parseStorageAndSMART(content string, result *models.AnalysisResult) {
|
||||
}
|
||||
if info.health != "" && !strings.EqualFold(info.health, "PASSED") {
|
||||
result.Events = append(result.Events, models.Event{
|
||||
Timestamp: time.Now(),
|
||||
Source: "SMART",
|
||||
EventType: "Disk Health",
|
||||
Severity: models.SeverityWarning,
|
||||
@@ -338,7 +335,7 @@ func parseStorageAndSMART(content string, result *models.AnalysisResult) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseJournalLogSections(content string, result *models.AnalysisResult) {
|
||||
func parseJournalLogSections(content string, collectedAt time.Time, result *models.AnalysisResult) {
|
||||
sections := []struct {
|
||||
heading string
|
||||
eventType string
|
||||
@@ -367,7 +364,7 @@ func parseJournalLogSections(content string, result *models.AnalysisResult) {
|
||||
}
|
||||
|
||||
result.Events = append(result.Events, models.Event{
|
||||
Timestamp: parseEventTimestamp(line),
|
||||
Timestamp: parseEventTimestamp(line, collectedAt),
|
||||
Source: sec.source,
|
||||
EventType: sec.eventType,
|
||||
Severity: classifyEventSeverity(line),
|
||||
@@ -420,7 +417,7 @@ func isDashLine(s string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func parseEventTimestamp(line string) time.Time {
|
||||
func parseEventTimestamp(line string, collectedAt time.Time) time.Time {
|
||||
isoRe := regexp.MustCompile(`\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?[+-]\d{2}:\d{2}\b`)
|
||||
if iso := isoRe.FindString(line); iso != "" {
|
||||
if ts, err := time.Parse(time.RFC3339Nano, iso); err == nil {
|
||||
@@ -430,13 +427,10 @@ func parseEventTimestamp(line string) time.Time {
|
||||
|
||||
prefixRe := regexp.MustCompile(`^[A-Z][a-z]{2}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}`)
|
||||
if prefix := prefixRe.FindString(line); prefix != "" {
|
||||
year := time.Now().Year()
|
||||
if ts, err := parser.ParseInDefaultArchiveLocation("Jan 2 15:04:05 2006", prefix+" "+strconv.Itoa(year)); err == nil {
|
||||
return ts
|
||||
}
|
||||
return parser.ParseYearlessInDefaultArchiveLocation("Jan 2 15:04:05", prefix, collectedAt)
|
||||
}
|
||||
|
||||
return time.Now()
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func classifyEventSeverity(line string) models.Severity {
|
||||
|
||||
Reference in new issue
Block a user