Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .chloggen/feature_syslog-facility-message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: receiver/syslog

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add facility_text attribute to syslog parser output

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [45641]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
The syslog parser now outputs a facility_text attribute containing
the human-readable facility name (e.g., "auth", "kern", "local0")
in addition to the existing numeric facility attribute.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
28 changes: 15 additions & 13 deletions pkg/stanza/operator/input/syslog/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ var (
Severity: entry.Info,
SeverityText: "info",
Attributes: map[string]any{
"appname": "SecureAuth0",
"facility": 10,
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"appname": "SecureAuth0",
"facility": 10,
"facility_text": "authpriv",
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"structured_data": map[string]any{
"SecureAuth@27389": map[string]any{
"PEN": "27389",
Expand Down Expand Up @@ -86,12 +87,13 @@ var (
"service.name": "apache_server",
},
Attributes: map[string]any{
"foo": "bar",
"appname": "apache_server",
"facility": 4,
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
"foo": "bar",
"appname": "apache_server",
"facility": 4,
"facility_text": "auth",
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
},
Body: fmt.Sprintf("<34>%s 1.2.3.4 apache_server: test message", ts.Format("Jan _2 15:04:05")),
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/stanza/operator/parser/syslog/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (p *Parser) parseRFC3164(syslogMessage *rfc3164.SyslogMessage, skipPriHeade
value["priority"] = syslogMessage.Priority
value["severity"] = syslogMessage.Severity
value["facility"] = syslogMessage.Facility
value["facility_text"] = syslogMessage.FacilityLevel()
}

return p.toSafeMap(value)
Expand All @@ -169,6 +170,7 @@ func (p *Parser) parseRFC5424(syslogMessage *rfc5424.SyslogMessage, skipPriHeade
value["priority"] = syslogMessage.Priority
value["severity"] = syslogMessage.Severity
value["facility"] = syslogMessage.Facility
value["facility_text"] = syslogMessage.FacilityLevel()
}

return p.toSafeMap(value)
Expand Down
109 changes: 59 additions & 50 deletions pkg/stanza/operator/parser/syslog/syslogtest/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Error,
SeverityText: "err",
Attributes: map[string]any{
"appname": "apache_server",
"hostname": "1.2.3.4",
"message": "test message",
"facility": 15,
"priority": 123,
"appname": "apache_server",
"hostname": "1.2.3.4",
"message": "test message",
"facility": 15,
"facility_text": "cron2",
"priority": 123,
},
Body: fmt.Sprintf("<123>%s 1.2.3.4 apache_server: test message", ts.Format("Jan _2 15:04:05")),
},
Expand All @@ -130,11 +131,12 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Error2,
SeverityText: "crit",
Attributes: map[string]any{
"appname": "apache_server",
"facility": 4,
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
"appname": "apache_server",
"facility": 4,
"facility_text": "auth",
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
},
Body: fmt.Sprintf("<34>%s 1.2.3.4 apache_server: test message", ts.Format("Jan _2 15:04:05")),
},
Expand All @@ -157,11 +159,12 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Error2,
SeverityText: "crit",
Attributes: map[string]any{
"appname": "apache_server",
"facility": 4,
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
"appname": "apache_server",
"facility": 4,
"facility_text": "auth",
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
},
Body: fmt.Sprintf("<34>%s 1.2.3.4 apache_server: test message", ts.Format("Jan _2 15:04:05")),
},
Expand All @@ -184,11 +187,12 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Error2,
SeverityText: "crit",
Attributes: map[string]any{
"appname": "apache_server",
"facility": 4,
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
"appname": "apache_server",
"facility": 4,
"facility_text": "auth",
"hostname": "1.2.3.4",
"message": "test message",
"priority": 34,
},
Body: fmt.Sprintf("<34>%s 1.2.3.4 apache_server: test message", ts.Format("Jan _2 15:04:05")),
},
Expand All @@ -210,13 +214,14 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Info,
SeverityText: "info",
Attributes: map[string]any{
"appname": "SecureAuth0",
"facility": 10,
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"appname": "SecureAuth0",
"facility": 10,
"facility_text": "authpriv",
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"structured_data": map[string]any{
"SecureAuth@27389": map[string]any{
"PEN": "27389",
Expand Down Expand Up @@ -297,9 +302,10 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
"UserID": "Tester2",
},
},
"version": 1,
"facility": 15,
"priority": 123,
"version": 1,
"facility": 15,
"facility_text": "cron2",
"priority": 123,
},
Body: `<123>1 2015-08-05T21:58:59.693Z 192.168.2.132 SecureAuth0 23108 ID52020 [SecureAuth@27389 UserHostAddress="192.168.2.132" Realm="SecureAuth0" UserID="Tester2" PEN="27389"] Found the user for retrieving user's profile`,
},
Expand All @@ -322,13 +328,14 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Info,
SeverityText: "info",
Attributes: map[string]any{
"appname": "SecureAuth0",
"facility": 10,
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"appname": "SecureAuth0",
"facility": 10,
"facility_text": "authpriv",
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"structured_data": map[string]any{
"SecureAuth@27389": map[string]any{
"PEN": "27389",
Expand Down Expand Up @@ -360,12 +367,13 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Info,
SeverityText: "info",
Attributes: map[string]any{
"appname": "inactive",
"facility": 10,
"hostname": "192.168.2.132",
"message": " partition is p2 ",
"priority": 86,
"version": 1,
"appname": "inactive",
"facility": 10,
"facility_text": "authpriv",
"hostname": "192.168.2.132",
"message": " partition is p2 ",
"priority": 86,
"version": 1,
},
Body: `77 <86>1 2015-08-05T21:58:59.693Z 192.168.2.132 inactive - - - partition is p2 `,
},
Expand All @@ -388,13 +396,14 @@ func CreateCases(basicConfig func() *syslog.Config) ([]Case, error) {
Severity: entry.Info,
SeverityText: "info",
Attributes: map[string]any{
"appname": "SecureAuth0",
"facility": 10,
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"appname": "SecureAuth0",
"facility": 10,
"facility_text": "authpriv",
"hostname": "192.168.2.132",
"message": "Found the user for retrieving user's profile",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"structured_data": map[string]any{
"SecureAuth@27389": map[string]any{
"PEN": "27389",
Expand Down