-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Milestone
Description
Overview
Implement LogQL pipeline formatting stages that transform labels and log lines using Go template syntax.
Parent Issue
Part of #6 (Query Service Implementation), delegated from #8 (LogQL Query Compiler).
Context
Pipeline formatting stages allow users to transform labels and log lines. Currently, all formatting stages are no-op placeholders that return the DataFrame unchanged.
Requirements
Formatting Stages to Implement
| Stage | Syntax | Description |
|---|---|---|
label_format |
| label_format new="{{.old}}" |
Create/modify labels using Go templates |
line_format |
| line_format "{{.level}}: {{.message}}" |
Reformat the entire log line |
decolorize |
| decolorize |
Remove ANSI color codes from log lines |
Example Queries
{job="app"} | label_format level_upper="{{.level | ToUpper}}"
{job="app"} | line_format "{{.timestamp}} [{{.level}}] {{.message}}"
{job="app"} | decolorize
Implementation Approach
-
Add
gtmplcrate for Go template parsing and rendering -
Create UDFs in
src/query/logql/datafusion/udf.rs:label_format_template(template: String, ...labels) -> Stringline_format_template(template: String, ...labels) -> Stringdecolorize(text: String) -> String(ANSI regex removal)
-
Update planner in
src/query/logql/datafusion/planner.rs:- Replace no-op implementations in
apply_label_format(),apply_line_format(),apply_decolorize()
- Replace no-op implementations in
Acceptance Criteria
-
label_formatcreates/modifies labels using Go template syntax -
line_formattransforms log lines using Go template syntax -
decolorizeremoves ANSI escape sequences - Go template functions (ToUpper, ToLower, Replace, etc.) are supported
- Template errors are handled gracefully
- Unit tests for each formatting stage
- Integration tests with full LogQL queries
Dependencies
gtmplcrate for Go template parsing
Technical References
- LogQL Label Format
- LogQL Line Format
- Current placeholder:
src/query/logql/datafusion/planner.rs - Technical spec:
src/query/logql/TECHNICAL_SPEC.mdSection 7.1.9-7.1.10