Skip to content

fix: syslog plugin doesn't work#9425

Merged
juststillthinking merged 14 commits into
apache:masterfrom
jiangfucheng:syslog
May 18, 2023
Merged

fix: syslog plugin doesn't work#9425
juststillthinking merged 14 commits into
apache:masterfrom
jiangfucheng:syslog

Conversation

@jiangfucheng

@jiangfucheng jiangfucheng commented May 7, 2023

Copy link
Copy Markdown
Member

Description

Fixes #9419

1.Convert the log message to RFC5424 format before sending it to the syslog server.
2.RFC5424 is “The Syslog Protocol", not only used for sls-logger. So, I relocated the file rfc5424.lua from apisix/plugins/slslog to apisix/syslog

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@juststillthinking

Copy link
Copy Markdown
Contributor

@Sn0rt please help to review

@Sn0rt

Sn0rt commented May 8, 2023

Copy link
Copy Markdown
Contributor

@jiangfucheng thx your PR.

can you add a test set to verify the syslog plugin is really working?

I think https://github.com/apache/apisix/blob/master/t/plugin/tcp-logger.t#L466 is helpful for you.

I think the below config file of vector can help you save more time.

file path ci/pod/vector/vector.toml

[sources.log-from-syslog-tcp]
type = "syslog"
address = "0.0.0.0:5050"
mode = "tcp"

[sources.log-from-syslog-udp]
type = "syslog"
address = "0.0.0.0:5050"
host_key = "host"
mode = "udp"
port_key = "port"
shutdown_timeout_secs = 30
socket_file_mode = 511

[sinks.log-2-console]
inputs = [ "log-from-tcp",  "log-from-tls", "log-from-syslog-tcp", "log-from-syslog-udp"]
type = "console"
encoding.codec = "json"

[sinks.log-2-syslog-tcp-file]
inputs = [ "log-from-syslog-tcp" ]
type = "file"
encoding.codec = "text"
path = "/etc/vector/syslog-tcp.log"

[sinks.log-2-syslog-udp-file]
inputs = [ "log-from-syslog-udp" ]
type = "file"
encoding.codec = "text"
path = "/etc/vector/syslog-udp.log"

and some new test set at tcp-logger.lua to verify the syslog is real working.

Comment thread apisix/plugins/syslog/init.lua Outdated
Comment thread apisix/plugins/syslog/init.lua Outdated
@Sn0rt Sn0rt mentioned this pull request May 8, 2023
5 tasks
@jiangfucheng

Copy link
Copy Markdown
Member Author

@Sn0rt Updated, please review again, thanks.

@Sn0rt

Sn0rt commented May 9, 2023

Copy link
Copy Markdown
Contributor

LGTM @monkeyDluffy6017 pls approve CI.

@Sn0rt

Sn0rt commented May 9, 2023

Copy link
Copy Markdown
Contributor

@shreemaan-abhishek your commit has been duplicated here

@juststillthinking

Copy link
Copy Markdown
Contributor

@jiangfucheng Could you merge the master branch, some ci error are fixed

Comment thread apisix/plugins/sls-logger.lua Outdated
Comment thread apisix/plugins/sls-logger.lua Outdated
Comment thread apisix/plugins/syslog/init.lua Outdated
Comment thread apisix/plugins/syslog/init.lua Outdated
Comment thread apisix/syslog/rfc5424.lua Outdated
Sn0rt
Sn0rt previously approved these changes May 17, 2023
@juststillthinking
juststillthinking merged commit 35ea74e into apache:master May 18, 2023
AlinsRan pushed a commit to AlinsRan/apisix that referenced this pull request Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: syslog plugin looks doesn’t work

5 participants