{"id":26648916,"url":"https://github.com/archsyscall/klogstream","last_synced_at":"2026-04-29T14:05:57.167Z","repository":{"id":284184335,"uuid":"954027625","full_name":"archsyscall/klogstream","owner":"archsyscall","description":"Go library that implements Kubernetes log streaming with filtering capabilities","archived":false,"fork":false,"pushed_at":"2025-03-24T15:16:35.000Z","size":57,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T09:52:53.772Z","etag":null,"topics":["go","k8s","kubernetes","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archsyscall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-24T13:03:53.000Z","updated_at":"2025-04-19T04:55:05.000Z","dependencies_parsed_at":"2025-03-24T16:37:50.625Z","dependency_job_id":null,"html_url":"https://github.com/archsyscall/klogstream","commit_stats":null,"previous_names":["archsyscall/klogstream"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/archsyscall/klogstream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archsyscall%2Fklogstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archsyscall%2Fklogstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archsyscall%2Fklogstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archsyscall%2Fklogstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archsyscall","download_url":"https://codeload.github.com/archsyscall/klogstream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archsyscall%2Fklogstream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32428629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","k8s","kubernetes","logging"],"created_at":"2025-03-25T00:47:19.038Z","updated_at":"2026-04-29T14:05:57.151Z","avatar_url":"https://github.com/archsyscall.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# klogstream\n\n**klogstream** is a **Go library** that implements **Kubernetes** log streaming with **multi-pod filtering**, **JSON formatting**, and **error handling**. The library extends standard Kubernetes clients by adding **regex-based filtering** and **concurrent log processing**. It provides a handler interface for custom log processing, automatic reconnection mechanisms, and built-in support for multiline log assembly. Developers can filter logs by pod names, namespaces, and labels while streaming from multiple containers simultaneously.\n\n## Features\n\n- Concurrent log streaming across multiple pods/containers using goroutines\n- Regex-based filtering for pod/container names\n- Namespace and label-based log filtering\n- Multiline log reassembly (e.g., Java stack traces)\n- Flexible log formatting with JSON and custom formats\n- Pluggable log handler system\n- Automatic reconnection with exponential backoff\n- Direct Kubernetes clientset injection support for testing\n\n## Installation\n\n```bash\ngo get github.com/archsyscall/klogstream/pkg/klogstream\n```\n\n## Log Handler Interface\n\nklogstream provides a LogHandler interface for flexible log processing:\n\n```go\ntype LogHandler interface {\n    // OnLog is called whenever a new log message arrives\n    OnLog(message LogMessage)\n    \n    // OnError is called when an error occurs during streaming\n    OnError(err error)\n    \n    // OnEnd is called when the streaming ends\n    OnEnd()\n}\n```\n\nLogMessage structure:\n```go\ntype LogMessage struct {\n    Timestamp     time.Time\n    PodName       string\n    ContainerName string\n    Message       string\n    Labels        map[string]string\n}\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\t// Other imports...\n\n\t\"github.com/archsyscall/klogstream/pkg/klogstream\"\n)\n\nfunc main() {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\t\n\t// Set up context and signal handling...\n\n\t// Create a streamer using the builder pattern - this is the main part!\n\tstreamer, err := klogstream.NewBuilder().\n\t\tWithNamespace(\"default\").             // Stream logs from the default namespace\n\t\tWithPodRegex(\"my-app.*\").             // Stream logs from pods matching regex\n\t\tWithContainerRegex(\".*\").             // Stream logs from all containers\n\t\tWithHandler(\u0026ConsoleHandler{}).       // Use a custom log handler\n\t\tBuild()\n\n\tif err != nil {\n\t\t// Error handling...\n\t}\n\n\t// Start streaming logs\n\tif err := streamer.Start(ctx); err != nil \u0026\u0026 err != context.Canceled {\n\t\t// Error handling...\n\t}\n}\n\n// ConsoleHandler is a simple handler that prints logs to the console\ntype ConsoleHandler struct{}\n\nfunc (h *ConsoleHandler) OnLog(message klogstream.LogMessage) {\n\tfmt.Printf(\"[%s] %s/%s: %s\\n\", \n\t\tmessage.Timestamp.Format(time.RFC3339),\n\t\tmessage.PodName,\n\t\tmessage.ContainerName,\n\t\tmessage.Message)\n}\n\n// OnError and OnEnd implementations...\n```\n\n## Development Status\n\nThis project is under active development and not yet production-ready. APIs may change without notice.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchsyscall%2Fklogstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchsyscall%2Fklogstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchsyscall%2Fklogstream/lists"}