Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 661 Bytes

Pattern.md

File metadata and controls

28 lines (21 loc) · 661 Bytes

Pattern

A parser that work exactly like Loki pattern (see README for usage example).

API

class Pattern<T extends LokiPatternType> implements PatternShape<T> {}

constructor(pattern: T)

Create a new instance of Pattern using either:

  • a string
  • an array of string
  • a tuple (readonly array)
new Pattern([
  "[schema: <id>|type: <user_type>]",
  "HTTP <verb> <_> <endpoint>"
] as const)

compile(): (log: string) => [] | [log: LokiLiteralPattern< T >]

Compile a function to parse a log (one by one). This method is used in executeOnLogs().

executeOnLogs(logs: string[]): LokiLiteralPattern< T >[]

Parse an Array of logs