feat(log-forwarding): each forwarding rule names its template
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Failing after 17s
driver / types (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 1m15s
driver / test (3.12) (pull_request) Successful in 1m30s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Failing after 2m38s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Failing after 17s
driver / types (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 1m15s
driver / test (3.12) (pull_request) Successful in 1m30s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Failing after 2m38s
driver / publish (pull_request) Skipped
A rule's template decides the timestamp it sends: rsyslog's default, RFC 3164, carries the host's local time without a zone, which a collector such as Graylog files shifted by the host's UTC offset (NetOrk/netork#493). The rule now says which template it uses: its own (`@host;Name`, `action(... template="...")`), else the default set before it (`$ActionForwardDefaultTemplate`, or `module(load="builtin:omfwd" template="...")` for omfwd actions), else None.
This commit is contained in:
1 parent
1b04818982
commit
8e43fe2ed9
3 files changed
+74
-4
No files matched your search
@@ -37,9 +37,40 @@ class TestRules:
|
||||
"selector": "*.*",
|
||||
"complete": True,
|
||||
"ruleset": None,
|
||||
"template": "RSYSLOG_SyslogProtocol23Format",
|
||||
},
|
||||
]
|
||||
|
||||
def test_a_rule_without_a_template_sends_rsyslogs_default(self):
|
||||
"""None: RFC 3164, the sender's local time without a zone (NetOrk/netork#493)."""
|
||||
(rule,) = _rules("*.* @graylog.example.net:514\n")
|
||||
assert rule["template"] is None
|
||||
|
||||
def test_an_actions_template_parameter(self):
|
||||
(rule,) = _rules(
|
||||
'action(type="omfwd" target="10.0.0.7" Template="RSYSLOG_ForwardFormat")\n'
|
||||
)
|
||||
assert rule["template"] == "RSYSLOG_ForwardFormat"
|
||||
|
||||
def test_the_legacy_default_template_holds_for_the_rules_after_it(self):
|
||||
rules = _rules(
|
||||
"*.* @a\n$ActionForwardDefaultTemplate RSYSLOG_SyslogProtocol23Format\n"
|
||||
"*.* @@b:514\n*.* @c;RSYSLOG_TraditionalForwardFormat\n"
|
||||
)
|
||||
assert [(r["target"], r["template"]) for r in rules] == [
|
||||
("a", None),
|
||||
("b", "RSYSLOG_SyslogProtocol23Format"),
|
||||
("c", "RSYSLOG_TraditionalForwardFormat"),
|
||||
]
|
||||
|
||||
def test_the_forward_modules_template_holds_for_its_actions(self):
|
||||
text = (
|
||||
'module(load="builtin:omfwd" template="RSYSLOG_SyslogProtocol23Format")\n'
|
||||
'action(type="omfwd" target="10.0.0.7")\n'
|
||||
)
|
||||
(rule,) = _rules(text)
|
||||
assert rule["template"] == "RSYSLOG_SyslogProtocol23Format"
|
||||
|
||||
def test_two_ats_are_tcp_and_a_missing_port_stays_unknown(self):
|
||||
(rule,) = _rules("*.* @@logs.lan\n")
|
||||
assert (rule["protocol"], rule["target"], rule["port"]) == ("tcp", "logs.lan", None)
|
||||
|
||||
Reference in new issue
Block a user