Skip to content

LogsQL: add switch/case syntax to format pipe for multi-branch conditional formatting #1255

@func25

Description

@func25

Is your feature request related to a problem? Please describe

format already supports if (<filters>), but only as a single condition for the whole pipe. This works for simple cases, but it becomes awkward when one field needs different values for different conditions (if else/ switch case).

In such cases, users currently have to duplicate logic across multiple pipes or build less readable workarounds.

Describe the solution you'd like

Add switch/case support to the format pipe for writing different values into a single destination field based on multiple filter conditions.

Proposed syntax:

| format switch (
  case (status:200) "OK"
  case (status:400) "Error"
  default "Other"
) as status_string

The switch block should evaluate cases from top to bottom and write the first matching result into status_string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlogsqlIssues related to LogsQL

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions