Skip to content

feat: Added log format support in syslog plugin.#8279

Merged
spacewander merged 11 commits into
apache:masterfrom
fatihusta:syslog-custom-log-format
Nov 29, 2022
Merged

feat: Added log format support in syslog plugin.#8279
spacewander merged 11 commits into
apache:masterfrom
fatihusta:syslog-custom-log-format

Conversation

@fatihusta

Copy link
Copy Markdown
Contributor

Fixes #8278

Comment thread t/plugin/syslog.t Outdated
[error]


=== TEST 5: add plugin metadata

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed test reordering problem.

Should I add "access request" test?
And is that enough if is require?

=== TEST 10: access for log format
--- request
GET /hello
--- response_body
hello world

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it. And we need to inject some code in extra_init_by_lua to check the logged data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need extra_init_by_lua for these tests.
I added new test cases. Please review it again.

BTW: It was to hard to understand test framework for me. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tzssangglass tzssangglass mentioned this pull request Nov 9, 2022
5 tasks
@fatihusta
fatihusta force-pushed the syslog-custom-log-format branch from dd52597 to 642c15c Compare November 9, 2022 08:48
Comment thread t/plugin/syslog.t Outdated
--- grep_error_log eval
qr/sending a batch logs to 127.0.0.1:(\d+)/
--- grep_error_log_out
sending a batch logs to 127.0.0.1:5044

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check only ensures the log is sent to port 5044, which is already checked by other tests.
It is necessary to check the content of the log via injected code like

assert(r.client_ip == "127.0.0.1", r.client_ip)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed syslog server port.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply modifying the port is useless , we should check the format of the reported logs to ensure that log_format is in effect, see: https://github.com/apache/apisix/blob/master/t/plugin/kafka-logger-log-format.t

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check again?

Comment thread docs/en/latest/plugins/syslog.md Outdated
Comment thread t/plugin/syslog.t Outdated
--- no_error_log
[error]
--- error_log eval
qr/syslog-log-format.*\{.*"host":"localhost"/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run this test locally and it can pass even without setting metadata, because the default log format already contains "host":"localhost" in

headers = ngx.req.get_headers(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added upstream variable into log format.

@spacewander

Copy link
Copy Markdown
Member

Please make the CI pass, thanks!

@spacewander
spacewander merged commit d18db2c into apache:master Nov 29, 2022
hongbinhsu added a commit to fitphp/apix that referenced this pull request Dec 4, 2022
* upstream/master: (48 commits)
  fix(ai): remove BUILD_ROUTER event when ai module is unloaded (apache#8184)
  chore: add some comment for make_request_to_vault function (apache#8420)
  docs: update admin api English doc (apache#8227)
  ci: use fixed os version of ubuntu (apache#8438)
  feat: Support store secrets in secrets manager for auth plugin via kms components (apache#8421)
  feat: interact via gRPC in APISIX Admin API (apache#8411)
  fix: last_err can be nil when the reconnection is successful (apache#8377)
  feat: support global data encryption of secret information (apache#8403)
  refactor(env): rename funtion name (apache#8426)
  feat(admin): add kms admin api (apache#8394)
  docs: update consumer and upstream docs (apache#8223)
  ci: add cron job for GM (apache#8398)
  docs: add kms env doc (apache#8419)
  feat: Added log format support in syslog plugin. (apache#8279)
  feat: add vault common components (apache#8412)
  docs: update global-rule/plugin-config/plugin/ docs (apache#8262)
  docs: update consumer-group/router/service/script doc (apache#8332)
  feat: support store secret in env for auth plugin (apache#8390)
  docs: update Upgrade Guide CN version (apache#8392)
  docs: add GM plugin EN doc to make website display normally (apache#8393)
  ...
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.

feat: Support for custom log format in syslog plugin

3 participants