log-timeline-mapper

Implements and tests LogIngesterTask and LogToTimelineMapper tasks in KHI.

2.1k|97|Updated Jan 22, 2025
One-click install
npx skills add https://github.com/GoogleCloudPlatform/khi --skill log-timeline-mapper-googlecloudplatform
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: log-timeline-mapper
Source: https://github.com/GoogleCloudPlatform/khi/tree/main/.agents/skills/log_timeline_mapper
Command: npx skills add https://github.com/GoogleCloudPlatform/khi --skill log-timeline-mapper-googlecloudplatform

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers extending Kubernetes History Inspector (KHI) need consistent patterns for parsing raw logs and mapping them to timeline events or resource revisions, plus reliable unit tests for these tasks. ## Core Features & Use Cases - LogIngesterTask Implementation: Guides parsing raw logs into LogChangeSet metadata including timestamp, severity, summary, and log type. - Three Mapper Patterns: Covers Multi-Pass with State, Single-Pass with State, and Single-Pass Stateless LogToTimelineMapper implementations. - Table-Driven Testing: Provides fluent assertion patterns using testchangeset and testlog utilities for verifying ingester and mapper behavior. - Use Case: When adding a new log provider feature to KHI, follow this guide to implement the ingester, choose the correct mapper pattern, and write table-driven unit tests with a shared Builder instance. ## Quick Start Ask the AI to implement a new LogIngester and stateless LogToTimelineMapper for a KHI feature following these guidelines, including table-driven unit tests.

Frequently Asked Questions about log-timeline-mapper

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a LogIngester in KHI?▼

Implement the LogIngester interface by defining RawLogTask, Dependencies, and ProcessLog methods. In ProcessLog, create a LogChangeSet and explicitly set timestamp, severity, and summary, since metadata defaults are not filled automatically.

Which LogToTimelineMapper pattern should I use in KHI?▼

Choose based on state needs: Multi-Pass with State for pre-collecting data across grouped logs, Single-Pass with State for sequential state propagation, or Single-Pass Stateless via StatelessMapperBase when each log maps independently.

How do I test KHI timeline mappers with table-driven tests?▼

Create mock logs with testlog.NewMockLog, initialize one khifilev6.Builder, inject it into the context via khictx.WithValue, and assert outcomes using testchangeset.AssertTimeline fluent assertions like HasEvent and HasRevision.

Why is my KHI log ingester producing empty metadata?▼

LogChangeSet does not automatically populate metadata defaults. You must explicitly call SetTimestamp, SetSeverity, and SetSummary in your ProcessLog implementation, otherwise the ingested log will lack these fields.

Where should KHI task IDs and implementations be placed?▼

TaskID definitions must be defined in the feature root package under pkg/task/inspection/<provider>/<feature>, while task implementation instantiations must be placed in the impl subpackage to respect package boundaries.