logfilter

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logfilter provides a simple query syntax for filtering logs. The syntax supports:

  • Word matching: `error` matches logs containing "error" (case-insensitive)
  • Quoted phrases: `"error message"` or `'error message'` matches exact phrase (case-insensitive)
  • Regex matching: `/pattern/` matches logs matching the regex pattern
  • Negation: `-word` excludes logs containing "word"
  • Multiple terms: `error timeout` requires both terms to match (AND)

Examples:

  • `error` - logs containing "error"
  • `"connection failed"` - logs containing exact phrase "connection failed"
  • `error timeout` - logs containing both "error" AND "timeout"
  • `-debug` - logs NOT containing "debug"
  • `error -debug` - logs containing "error" but NOT "debug"
  • `/err(or)?/` - logs matching the regex
  • `error /warn(ing)?/` - logs containing "error" AND matching the regex

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter represents a compiled log filter that can match log lines and be converted to LogsQL for server-side filtering.

func Parse

func Parse(input string) (*Filter, error)

Parse parses a filter string into a Filter. Returns nil if the input is empty.

func (*Filter) Match

func (f *Filter) Match(line string) bool

Match returns true if the line matches the filter. All terms must match (AND logic), with negated terms inverted.

func (*Filter) String

func (f *Filter) String() string

String returns the original filter string representation.

func (*Filter) ToLogsQL

func (f *Filter) ToLogsQL() string

ToLogsQL converts the filter to a LogsQL filter expression. This can be appended to a LogsQL query for server-side filtering.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL