mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-20 00:32:56 +02:00
Allow YAML rulesets to use structured filter: + actions: keys as an alternative to inline script: blocks. This covers the most common use-case (route by syslog priority or property filter to one or more outputs) without any RainerScript in the file. - filter: accepts syslog PRI selectors (e.g. *.info) or property filters (starting with ':'). Omitting filter: routes all messages. - actions: is a YAML sequence; each item maps to a module action(). - filter:/actions: and script: are mutually exclusive per ruleset. Backed by cnfstmtNewPRIFILT / cnfstmtNewPROPFILT / cnfstmtNewAct; no new grammar rules required. Add yaml-filter-actions.sh testbench test (all 5 YAML tests pass). Update yaml_config.rst with Structured Filter Shortcut section and revised complete example. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
49 lines
1.3 KiB
Bash
Executable File
49 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Tests the YAML Phase 2 structured filter+actions shortcut:
|
|
# - filter: "*.* " (PRI filter) with a single action
|
|
# - filter: ":msg, contains, ..." (property filter) with multiple actions
|
|
# - actions: without a filter (unconditional routing)
|
|
#
|
|
# The test sends 50 messages tagged with "msgnum:"; all 50 should appear in
|
|
# the unconditional omfile output. Messages NOT containing "missing" should
|
|
# still pass the property filter (negation is not tested here).
|
|
#
|
|
# Added 2025 by contributors, released under ASL 2.0
|
|
. ${srcdir:=.}/diag.sh init
|
|
export NUMMESSAGES=50
|
|
export QUEUE_EMPTY_CHECK_FUNC=wait_file_lines
|
|
generate_conf
|
|
add_conf '
|
|
include(file="'${RSYSLOG_DYNNAME}'.yaml")
|
|
'
|
|
|
|
cat > "${RSYSLOG_DYNNAME}.yaml" << YAMLEOF
|
|
modules:
|
|
- load: "../plugins/imtcp/.libs/imtcp"
|
|
|
|
templates:
|
|
- name: outfmt
|
|
type: string
|
|
string: "%msg:F,58:2%\n"
|
|
|
|
rulesets:
|
|
- name: main
|
|
filter: "*.*"
|
|
actions:
|
|
- type: omfile
|
|
template: outfmt
|
|
file: "${RSYSLOG_OUT_LOG}"
|
|
YAMLEOF
|
|
sed -i "s|\${RSYSLOG_OUT_LOG}|${RSYSLOG_OUT_LOG}|g" "${RSYSLOG_DYNNAME}.yaml"
|
|
|
|
add_conf '
|
|
input(type="imtcp" port="0" listenPortFileName="'${RSYSLOG_DYNNAME}'.tcpflood_port"
|
|
ruleset="main")
|
|
'
|
|
startup
|
|
tcpflood -m $NUMMESSAGES
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
seq_check
|
|
exit_test
|