Classifiers¶
Classifiers convert grouped log chunks into findings. Built-in options include the regex counter and an rsnapshot-specific heuristic, but you can add your own for project-specific formats.
Configuration and regexes are easiest to edit in the Web UI. Use the config editor to point pipelines at your new classifier and the regex lab to validate patterns.
Built-in classifiers¶
regex_counter: counts warning/error regex matches per line and emits findings with the matching snippet.rsnapshot_basic: groups rsnapshot runs and applies rsnapshot-aware heuristics.
Select either via pipelines[].classifier in config.yaml.
Creating a new classifier¶
- Add a classifier module. Create a new file under
logtriage/classifiers/(for example,custom_http.py) and implement a function that matches the signature used by the dispatcher: - Inputs:
PipelineConfig,file_path,pipeline_name,lines,start_line,excerpt_limit,context_prefix_lines. - Output: a
List[Finding]populated with severity, message, line numbers, and excerpt context. - Register the classifier. Update
logtriage/classifiers/__init__.pyto route a newclassifier_typestring to your function, similar to howrsnapshot_basicis registered. - Expose configuration. In
config.yaml, setpipelines[].classifierto your newclassifier_type(for example,custom_http). Add any regexes or options your classifier consumes. - Test with the CLI. Run
logtriage run --module <module>and use--reload-on-changeto iterate quickly while editing code and regexes via the Web UI.
Authoring tips¶
- Reuse
FindingandSeverityfromlogtriage.modelsto stay consistent with the Web UI and alerts. - Use
context_prefix_linesto include enough preamble for LLM prompts and dashboard excerpts. - Keep error messages concise; they appear in the CLI, alerts, and UI.
- Add comments in your classifier for any expected log markers so future contributors can align grouping strategies.