{"id":37046156,"url":"https://github.com/mrrazor22/draindotnet","last_synced_at":"2026-01-14T05:28:00.403Z","repository":{"id":313970838,"uuid":"1052317677","full_name":"MrRazor22/DrainDotNet","owner":"MrRazor22","description":"C# port of LogPai’s Drain log parser - fast, reliable log template mining for .NET","archived":false,"fork":false,"pushed_at":"2025-10-05T16:39:41.000Z","size":1397,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-21T18:51:25.543Z","etag":null,"topics":["csharp","dotnet","drain","log-analysis","log-mining","log-templating","logging","logpai","logparser"],"latest_commit_sha":null,"homepage":"https://github.com/logpai/logparser","language":"C#","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/MrRazor22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-07T20:59:37.000Z","updated_at":"2025-10-05T20:22:06.000Z","dependencies_parsed_at":"2025-09-09T22:21:53.496Z","dependency_job_id":"4b2774fa-d43e-436b-b99d-931ed9284917","html_url":"https://github.com/MrRazor22/DrainDotNet","commit_stats":null,"previous_names":["mrrazor22/draindotnet"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MrRazor22/DrainDotNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRazor22%2FDrainDotNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRazor22%2FDrainDotNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRazor22%2FDrainDotNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRazor22%2FDrainDotNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrRazor22","download_url":"https://codeload.github.com/MrRazor22/DrainDotNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrRazor22%2FDrainDotNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28410400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["csharp","dotnet","drain","log-analysis","log-mining","log-templating","logging","logpai","logparser"],"created_at":"2026-01-14T05:27:59.916Z","updated_at":"2026-01-14T05:28:00.397Z","avatar_url":"https://github.com/MrRazor22.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# DrainDotNet\n\nDrainDotNet is a C# port and improvement of [LogPai’s Drain log parser](https://github.com/logpai/logparser), with several improvements to make it faster, more reliable, and more user-friendly. It takes raw logs and automatically groups them into templates so you can easily see log patterns.\n\n## Key Improvements over the original Drain\n- Core + Wrapper Split: The code is cleanly split into: \n\t- `DrainCore` → the pure clustering algorithm (tree, similarity, templates). No I/O. \n\t- `LogParser` → a wrapper that handles regex-based parsing, preprocessing, saving to CSV, and reloading later.\n  This makes it easier to maintain and test the core logic separately.\n- **UniqueEventPatterns**: You can provide regex patterns that mark certain tokens as *important*. If a log contains these tokens and they change, DrainDotNet will always create a new event/template instead of merging them. This gives you more control over clustering.\n- **Faster Parameter Extraction**: The original Drain used regex-heavy logic for extracting parameters. DrainDotNet uses a simpler, token-based method that:\n  - Runs much faster (no heavy regex overhead).\n  - Handles tricky cases like `time: 15\u003e ms`, which used to confuse Drain and produce broken templates like `time: \u003c*\u003e\u003e`.\n- **Edge Case Handling**: Robust against logs with odd punctuation or mixed tokens.\n- **Strongly Typed Output**: `Parse()` returns a `List\u003cParsedLog\u003e` in code (with `LineId`, `Content`, `EventId`, `EventTemplate`, `ParameterList`, and extra fields), so you don’t have to re-parse CSVs if you want to use results directly.\n- **Optional Auto-Save**: Results are saved to CSV by default. You can disable this with `autoSave: false` if you only want in-memory results.\n- **Deterministic Reloading**: Use ReloadResults() to rehydrate ParsedLog objects from CSV after an app restart.\n- **MD5 Hash Event IDs**: Templates get stable 8-character Event IDs. Collisions are theoretically possible, but for typical datasets (even 100k+ templates) it’s practically safe.\n\n## How to use\n1. Put your log file in the `data` folder (see `Program.cs` for path).\n2. Build and run the project.\n3. Results will be written into the `outputDir` path specified:\n   - `*_structured.csv` — each log line matched with a template (includes `ParameterList`).\n   - `*_templates.csv` — unique log templates with counts.\n\n   Or use directly in code:\n\n\t```csharp\n\tusing DrainDotNet;\n\n\tvar logFormat = \"\u003cDate\u003e \u003cTime\u003e \u003cPid\u003e \u003cLevel\u003e \u003cComponent\u003e \u003cContent\u003e\";\n\n\tvar parser = new LogParser(logFormat, indir: \"./data/\", outdir: \"./result/\");\n\n\t// Parse logs and also save CSVs (default)\n\tvar parsedLogs = parser.Parse(\"HDFS.log\");\n\n\t// Parse logs but keep results in memory only\n\tvar parsedInMemory = parser.Parse(\"HDFS.log\", autoSave: false);\n\n\t// Reload results later (if auto saved) from saved CSVs\n\tvar reloaded = parser.ReloadResults(\"HDFS.log\");\n\t```\n\n## Using as a CLI Tool **(new)**\nDrainDotNet is also available as a .NET global tool, so you can parse logs directly from the command line without writing code.\n\n### Install\n```sh\ndotnet tool install -g DrainDotNet.Tool\n```\n### Usage\n```sh\ndraindotnet parse --log \u003clogFile\u003e --format \"\u003cLogFormat\u003e\" [--indir \u003cinputDir\u003e] [--out \u003coutputDir\u003e]\n```\n## Example (HDFS sample)\n```sh\ndraindotnet parse --log HDFS_2k.log --format \"\u003cDate\u003e \u003cTime\u003e \u003cPid\u003e \u003cLevel\u003e \u003cComponent\u003e: \u003cContent\u003e\" --indir ./SampleApp/data/loghub_2k/HDFS --out ./SampleApp/result\n```\n\nThis will generate:\n- HDFS_2k.log_structured.csv → structured logs with parameters\n- HDFS_2k.log_templates.csv → unique log templates with counts\n\n## License\nApache 2.0 (same as the original Drain).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrazor22%2Fdraindotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrrazor22%2Fdraindotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrrazor22%2Fdraindotnet/lists"}