Introduction

In the DSH ecosystem, when agents process log files, they usually need to extract errors or exception information from large amounts of text. Manual parsing of logs is time-consuming and may miss key context. This plugin provides automated parsing and aggregation capabilities to help quickly locate issues.

What This Is

A log analysis plugin maintained by uckkk. It parses log files, extracts errors/exceptions/warnings, aggregates statistics by signature, and returns a structured list of errors with context. It is implemented in pure Node.js and requires no network access or external services.

Core Features

  1. Aggregation Statistics: Counts errors/warnings, aggregates error type distribution by signature, and returns a list of error lines.
  2. Context Extraction: Extracts error lines and their surrounding context (N lines before/after) using regular expressions.
  3. Keyword Recognition: Recognizes common error keywords such as ERROR/FATAL/Exception/Traceback/panic/failed.
  4. Noise Removal: Automatically removes noise such as timestamps, numbers, and paths.

Installation and Enablement

Install it using the following command:

dsh plugin add github:uckkk/dsh-log-analyzer

After installation, add "dsh-log-analyzer" to dsh.profile.bundles in the profile’s package.json.

Typical Usage

  • Analyze log errors:
  analyze_log(file="app.log")
  • Extract specific errors and context:
  extract_errors(file="app.log", pattern="Timeout|Connection refused", context=3)

Applicable Scenarios and Notes

This plugin is suitable for scenarios that require quickly counting log error frequency or extracting context around specific exceptions.

Notes:
- For very large logs, only the tail (50,000 lines) is read by default. This can be adjusted via maxLines.
- Installing the plugin means running third-party code locally. Please review the source code yourself.

Closing

By combining aggregation statistics and context extraction, this tool simplifies the log troubleshooting process. For more details, refer to the project homepage or plugin directory.