Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: syslog plugin doesn't work #9425

Merged
merged 14 commits into from
May 18, 2023
Merged

Conversation

jiangfucheng
Copy link
Member

@jiangfucheng jiangfucheng commented May 7, 2023

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)

@monkeyDluffy6017
Copy link
Contributor

@Sn0rt please help to review

@Sn0rt
Copy link
Contributor

Sn0rt commented May 8, 2023

@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.

apisix/plugins/syslog/init.lua Outdated Show resolved Hide resolved
apisix/plugins/syslog/init.lua Outdated Show resolved Hide resolved
@Sn0rt Sn0rt mentioned this pull request May 8, 2023
5 tasks
@jiangfucheng
Copy link
Member Author

@Sn0rt Updated, please review again, thanks.

@Sn0rt
Copy link
Contributor

Sn0rt commented May 9, 2023

LGTM @monkeyDluffy6017 pls approve CI.

@Sn0rt
Copy link
Contributor

Sn0rt commented May 9, 2023

@shreemaan-abhishek your commit has been duplicated here

@monkeyDluffy6017
Copy link
Contributor

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

apisix/plugins/sls-logger.lua Outdated Show resolved Hide resolved
apisix/plugins/sls-logger.lua Outdated Show resolved Hide resolved
apisix/plugins/syslog/init.lua Outdated Show resolved Hide resolved
apisix/plugins/syslog/init.lua Outdated Show resolved Hide resolved
apisix/syslog/rfc5424.lua Outdated Show resolved Hide resolved
Sn0rt
Sn0rt previously approved these changes May 17, 2023
@monkeyDluffy6017 monkeyDluffy6017 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