Skip to content

Commit

Permalink
Merge pull request #255 from splunk/update/templates
Browse files Browse the repository at this point in the history
Update templates and syslog formats
  • Loading branch information
Ryan Faircloth authored and GitHub committed Dec 31, 2019
2 parents 866de2d + 09c8dd0 commit db6310a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
14 changes: 7 additions & 7 deletions package/etc/conf.d/conflib/_common/syslog_format.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ filter f_rfc5424_noversion{
filter f_rfc5424_epochtime{
message('^(?<SYSLOGMSG>(?<HEADER>(?<PRI><\d{1,3}>)(?<VERSION>[1-9][0-9]?) (?<TIMESTAMP>(?<EPOCH>\d{10})(?:.(?<TIMESECFRAC>\d{1,9})?)) (?<FROMHOST>[^ ]+) ))');
};
filter f_rfc5424_bsdtime{
filter f_rfc3164_version{
message('^(?<SYSLOGMSG>(?<HEADER>(?<PRI><\d{1,3}>)(?<VERSION>[1-9][0-9]?) (?<TIMESTAMP>[A-Za-z]{3} \d\d \d\d:\d\d:\d\d) (?<FROMHOST>[^ ]+) ))');
};
rewrite set_rfcnonconformant{
Expand All @@ -31,11 +31,11 @@ rewrite set_rfc5424_epochtime{
filter f_is_rfc5424_epochtime{
match("rfc5424_epochtime" value("fields.sc4s_syslog_format"))
};
rewrite set_rfc5424_bsdtime{
set("rfc5424_bsdtime" value("fields.sc4s_syslog_format"));
rewrite set_rfc3164_version{
set("rfc3164_version" value("fields.sc4s_syslog_format"));
};
filter f_is_rfc5424_bsdtime{
match("rfc5424_bsdtime" value("fields.sc4s_syslog_format"))
filter f_is_rfc3164_version{
match("rfc3164_version" value("fields.sc4s_syslog_format"))
};
rewrite set_rfc3164{
set("rfc3164" value("fields.sc4s_syslog_format"));
Expand All @@ -56,6 +56,6 @@ filter f_is_no_parse{
match("no_parse" value("fields.sc4s_syslog_format"))
};

rewrite set_rfc3894_bsdtime{
subst('^<\d+>(\d)', "", value("MESSAGE"));
rewrite set_rfc3164_no_version_string{
subst('(^<\d+>)\d', $1, value("MESSAGE"));
};
34 changes: 16 additions & 18 deletions package/etc/conf.d/conflib/_common/templates.conf
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,25 @@ template t_hdr_sdata_msg {
# JSON; for JSON pretty-printing (for debugging)
# ===============================================================================================

template t_JSON {
template("$(format-json --scope all-nv-pairs
--exclude fields.*
--exclude .splunk.*
--exclude HOST
--exclude HOST_FROM
--exclude SOURCE
)");
};
template t_JSON_3164 {
template('$(format-json --scope rfc3164
--pair PRI="<$PRI>"
--key LEGACY_MSGHDR
--exclude FACILITY
--exclude PRIORITY
)');
};

# ===============================================================================================
# JSON; for JSON pretty-printing (for RFC5424)
# ===============================================================================================

template t_JSON_5424 {
template("$(format-json --scope all-nv-pairs
--exclude fields.*
--exclude .splunk.*
--exclude HOST
--exclude HOST_FROM
--exclude RAWMSG
--exclude SOURCE
)");
};
template('$(format-json --scope rfc5424
--pair PRI="<$PRI>"
--key ISODATE
--exclude DATE
--exclude FACILITY
--exclude PRIORITY
)');
};
2 changes: 1 addition & 1 deletion package/etc/conf.d/filters/paloalto/panos.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
filter f_is_palalto_format{
match("rfc5424_bsdtime" value("fields.sc4s_syslog_format"))
match("rfc3164_version" value("fields.sc4s_syslog_format"))
or
match("rfc3164" value("fields.sc4s_syslog_format"))
};
Expand Down
2 changes: 1 addition & 1 deletion package/etc/conf.d/log_paths/p_zz_fallback.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ log {

rewrite {
r_set_splunk_dest_default(sourcetype("sc4s:fallback"), index("main") );
set("$(template ${.splunk.sc4s_template} $(template t_JSON))" value("MSG"));
set("$(template ${.splunk.sc4s_template} $(template t_JSON_3164))" value("MSG"));
unset(value("RAWMSG"));
unset(value("PROGRAM"));
unset(value("LEGACY_MSGHDR"));
Expand Down
6 changes: 3 additions & 3 deletions package/etc/go_templates/source_network.t
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ source s_{{ .port_id}} {
parser {cisco-parser()};
rewrite(set_cisco_ios);
} elif {
filter(f_rfc5424_bsdtime);
rewrite(set_rfc3894_bsdtime);
filter(f_rfc3164_version);
rewrite(set_rfc3164_no_version_string);
parser {
syslog-parser(time-zone({{- getenv "SC4S_DEFAULT_TIMEZONE" "GMT"}}) flags(store-raw-message, guess-timezone));
};
rewrite(set_rfc5424_bsdtime);
rewrite(set_rfc3164_version);
} elif {
parser (p_cisco_meraki);
rewrite(set_rfc5424_epochtime);
Expand Down

0 comments on commit db6310a

Please sign in to comment.