Currently the expressions language has some "gotchas" that aren't documented. Additionally, expected data types for the fields that expr can be used with are not declared.
Currently, expressions using matches (regex) cannot have named capture groups in them. This makes sense, but isn't documented, and can catch people trying to make a router by copy/pasting the regex from a regex_parser that the router will drive to.
Additionally, all escape characters (backslash by default), but be escaped. This is counterintuitive, as it does not match out regex_parser.
Non-working example (contains named capture groups, and does not escape the escape characters)
- type: router
routes:
- expr: '$record matches "^\[(?P<datetime>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}),\d+\]\s\d+\s(?P<severity>\w+)\s(?P<workflow>.*?):(?P<process>.*?):(?P<line_number>\d+)\s-\s\[(?P<type>.*?)\]\s(?P<message>.*)\sWorker\(id=(?P<worker_id>\d+),\sname=(?P<worker_name>.*?)\)"'
output: formatA_parser
- expr: '$labels["k8s-pod/app"] contains "worker-automation"'
output: general_format_parser
default: output
Working version of the above
- type: router
routes:
- expr: '$record matches "^\\[\\d{4}-\\d{2}-\\d{2}\\s+\\d{2}\\:\\d{2}\\:\\d{2},\\d+\\]\\s\\d+\\s\\w+\\s.*?\\:.*?\\:\\d+\\s-\\s\\[.*?\\]\\s.*\\sWorker\\(id=\\d+,\\sname=.*?\\)"'
output: formatA_parser
- expr: '$labels["k8s-pod/app"] contains "worker-automation"'
output: general_format_parser
default: output
Data that matches the formatA
[2022-02-04 12:21:06,301] 1 DEBUG inmar_libs.workflows.process_hire:process_hire_worker:555 - [New Hire] Username will be hawoody. Worker(id=205298, name=Hannah Woody)
Currently the expressions language has some "gotchas" that aren't documented. Additionally, expected data types for the fields that expr can be used with are not declared.
Currently, expressions using matches (regex) cannot have named capture groups in them. This makes sense, but isn't documented, and can catch people trying to make a router by copy/pasting the regex from a regex_parser that the router will drive to.
Additionally, all escape characters (backslash by default), but be escaped. This is counterintuitive, as it does not match out regex_parser.
Non-working example (contains named capture groups, and does not escape the escape characters)
Working version of the above
Data that matches the formatA