Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,25 @@ The RedfishEndpointPlugin collects Redfish URIs (GET responses) and optionally r

**`analysis_args`**
- **`checks`**: Optional. Map of URI to expected values or constraints for analysis. Supports exact match (e.g. `"PowerState": "On"`), `anyOf`, `min`/`max`, etc.
#### **RedfishEventLogPlugin**

The RedfishEventLogPlugin reads every entry from a Redfish LogService (for example an EventLog) and reports Critical and Warning entries. It requires a Redfish connection config and supports [Redfish multi-target](#redfish-multi-target). Use `AmcRedfishEventLogPlugin` for the AMC EventLog via the SSH proxy.

The collector reads `<log_service_path>/Entries` and pages with `$skip` until `Members@odata.count` is reached. Each page is saved as an artifact, and entries are stored newest first by `Created`. It uses `$skip` instead of `Members@odata.nextLink` because some services return the same `nextLink` on every page.

The analyzer reports Critical entries as errors and Warning entries as warnings. Entries with the same `Severity` and `MessageId` are reported once, with a count and the newest message.

**`collection_args`**
- **`log_service_path`**: Redfish path to the LogService. Entries are read from `<log_service_path>/Entries`.
- **`max_entries`**: Optional. Keep only the newest N entries. All pages are still read.
- **`max_pages`**: Optional (default `100`). Safety cap on the number of `$skip` pages requested.
- **`clear_logs_after_collection`**: Optional (default `false`). POST `LogService.ClearLog` after a successful collection.

**`analysis_args`**
- **`since`**: Optional ISO 8601 time. Only entries created at or after it are analyzed.
- **`message_id_include`**: Optional list of regexes. Only entries whose `MessageId` matches one are analyzed.
- **`message_id_exclude`**: Optional list of regexes. Entries whose `MessageId` matches any are skipped.


#### **'summary' sub command**
The 'summary' subcommand can be used to combine results from multiple runs of node-scraper to a
Expand Down
24 changes: 24 additions & 0 deletions nodescraper/plugins/ooband/redfish_event_log/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
###############################################################################
from .analyzer_args import RedfishEventLogAnalyzerArgs
from .collector_args import RedfishEventLogCollectorArgs
from .event_log_analyzer import RedfishEventLogAnalyzer
from .event_log_collector import RedfishEventLogCollector
from .event_log_data import EventLogEntry, RedfishEventLogDataModel
from .event_log_plugin import AmcRedfishEventLogPlugin, RedfishEventLogPlugin

__all__ = [
"AmcRedfishEventLogPlugin",
"EventLogEntry",
"RedfishEventLogAnalyzer",
"RedfishEventLogAnalyzerArgs",
"RedfishEventLogCollector",
"RedfishEventLogCollectorArgs",
"RedfishEventLogDataModel",
"RedfishEventLogPlugin",
]
69 changes: 69 additions & 0 deletions nodescraper/plugins/ooband/redfish_event_log/analyzer_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
import re
from datetime import datetime, timezone
from typing import Optional

from pydantic import Field, field_validator

from nodescraper.models import AnalyzerArgs


class RedfishEventLogAnalyzerArgs(AnalyzerArgs):
"""Analyzer args for Redfish LogService entries."""

since: Optional[datetime] = Field(
default=None,
description=(
"Only analyze entries created at or after this ISO 8601 time (naive values are UTC). "
"Entries without a parseable Created time are always analyzed."
),
)
message_id_include: Optional[list[str]] = Field(
default=None,
description="If set, only analyze entries whose MessageId matches one of these regexes.",
)
message_id_exclude: list[str] = Field(
default_factory=list,
description="Skip entries whose MessageId matches any of these regexes.",
)

@field_validator("since")
@classmethod
def _since_utc(cls, value: Optional[datetime]) -> Optional[datetime]:
if value is not None and value.tzinfo is None:
return value.replace(tzinfo=timezone.utc)
return value

@field_validator("message_id_include", "message_id_exclude")
@classmethod
def _valid_patterns(cls, patterns: Optional[list[str]]) -> Optional[list[str]]:
for pattern in patterns or []:
try:
re.compile(pattern)
except re.error as exc:
raise ValueError(f"invalid regex {pattern!r}: {exc}") from exc
return patterns
57 changes: 57 additions & 0 deletions nodescraper/plugins/ooband/redfish_event_log/collector_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
from typing import Optional

from pydantic import Field

from nodescraper.models import CollectorArgs


class RedfishEventLogCollectorArgs(CollectorArgs):
"""Collector args for reading a Redfish LogService's Entries collection."""

log_service_path: str = Field(
default="redfish/v1/Systems/system/LogServices/EventLog",
description="Redfish path to the LogService; entries are read from <log_service_path>/Entries.",
)
max_entries: Optional[int] = Field(
default=None,
ge=1,
description="Keep only the newest N entries (by Created). All pages are still read.",
)
max_pages: int = Field(
default=100,
ge=1,
le=10000,
description="Safety cap on the number of $skip pages requested.",
)
clear_logs_after_collection: bool = Field(
default=False,
description=(
"If True, POST LogService.ClearLog to log_service_path after a successful "
"collection. Requires system_interaction_level >= INTERACTIVE."
),
)
119 changes: 119 additions & 0 deletions nodescraper/plugins/ooband/redfish_event_log/event_log_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
import re
from typing import Optional

from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus
from nodescraper.interfaces import DataAnalyzer
from nodescraper.models import TaskResult

from .analyzer_args import RedfishEventLogAnalyzerArgs
from .event_log_data import EventLogEntry, RedfishEventLogDataModel, parse_created

SEVERITY_PRIORITY: dict[str, EventPriority] = {
"critical": EventPriority.ERROR,
"warning": EventPriority.WARNING,
}
MAX_IDS_PER_EVENT = 20


def _selected(entry: EventLogEntry, args: RedfishEventLogAnalyzerArgs) -> bool:
if args.since is not None:
created = parse_created(entry.created)
if created is not None and created < args.since:
return False
message_id = entry.message_id or ""
if args.message_id_include is not None and not any(
re.search(p, message_id) for p in args.message_id_include
):
return False
return not any(re.search(p, message_id) for p in args.message_id_exclude)


class RedfishEventLogAnalyzer(DataAnalyzer[RedfishEventLogDataModel, RedfishEventLogAnalyzerArgs]):
"""Reports Critical and Warning LogService entries as events."""

DATA_MODEL = RedfishEventLogDataModel

DOCUMENTATION_ANALYSIS_ITEMS: tuple[str, ...] = (
"Critical entries are reported as ERROR events and Warning entries as WARNING events; "
"OK and other severities are ignored.",
"Entries with the same Severity and MessageId are reported once with a count and the newest message.",
"analysis_args.since, message_id_include and message_id_exclude limit which entries are analyzed.",
)

def analyze_data(
self,
data: RedfishEventLogDataModel,
args: Optional[RedfishEventLogAnalyzerArgs] = None,
) -> TaskResult:
"""Report Critical and Warning entries, collapsed by Severity and MessageId."""
if args is None:
args = RedfishEventLogAnalyzerArgs()

selected = [e for e in data.entries if _selected(e, args)]
groups: dict[tuple[str, str], list[EventLogEntry]] = {}
for entry in selected:
severity = (entry.severity or "").lower()
if severity in SEVERITY_PRIORITY:
key = (severity, entry.message_id or entry.message or "")
groups.setdefault(key, []).append(entry)

counts = {severity: 0 for severity in SEVERITY_PRIORITY}
for (severity, _), group in groups.items():
counts[severity] += len(group)
newest = group[0]
label = newest.message_id or "LogEntry"
repeat = f" (x{len(group)})" if len(group) > 1 else ""
detail = f": {newest.message}" if newest.message else ""
self._log_event(
category=EventCategory.PLATFORM,
description=f"{newest.severity} {label}{repeat}{detail}",
data={
"log_service_path": data.log_service_path,
"severity": newest.severity,
"message_id": newest.message_id,
"count": len(group),
"newest_created": newest.created,
"oldest_created": group[-1].created,
"message_args": newest.message_args,
"ids": [e.id for e in group[:MAX_IDS_PER_EVENT]],
},
priority=SEVERITY_PRIORITY[severity],
console_log=True,
)

self.result.message = (
f"EventLog: {counts['critical']} critical, {counts['warning']} warning "
f"in {len(selected)} of {len(data.entries)} entries"
)
if counts["critical"]:
self.result.status = ExecutionStatus.ERROR
elif counts["warning"]:
self.result.status = ExecutionStatus.WARNING
else:
self.result.status = ExecutionStatus.OK
return self.result
Loading
Loading