-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(elasticsearch-logger): support multi elasticsearch endpoints #8604
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -106,10 +106,10 @@ __DATA__ | |||
--- response_body_like | ||||
passed | ||||
passed | ||||
property "endpoint_addr" is required | ||||
property "field" is required | ||||
value should match only one schema, but matches none | ||||
value should match only one schema, but matches none | ||||
property "field" validation failed: property "index" is required | ||||
property "endpoint_addr" validation failed: object matches none of the required | ||||
property "endpoint_addr" validation failed: failed to match pattern "\[\^/\]\$" with "http://127.0.0.1:9200/" | ||||
|
||||
|
||||
|
||||
|
@@ -533,7 +533,7 @@ PTQvJEaPcNOXcOHeErC0XQ== | |||
}, | ||||
plugins = { | ||||
["elasticsearch-logger"] = { | ||||
endpoint_addr = {"http://127.0.0.1:9200", "http://127.0.0.1:9201"}, | ||||
endpoint_addrs = {"http://127.0.0.1:9200", "http://127.0.0.1:9201"}, | ||||
field = { | ||||
index = "services" | ||||
}, | ||||
|
@@ -551,3 +551,32 @@ PTQvJEaPcNOXcOHeErC0XQ== | |||
} | ||||
--- response_body | ||||
passed | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add a test to show that different endpoints will be chosen randomly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you, but I don't know how. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about hitting the path multiple times and triggering multiple sending? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @spacewander. |
||||
|
||||
|
||||
|
||||
=== TEST 14: to show that different endpoints will be chosen randomly | ||||
--- config | ||||
location /t { | ||||
content_by_lua_block { | ||||
local t = require("lib.test_admin").test | ||||
for i = 1, 10 do | ||||
local code, body = t('/hello', ngx.HTTP_GET) | ||||
ngx.say("code: ", code) | ||||
end | ||||
|
||||
} | ||||
} | ||||
--- response_body | ||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can count the code like Line 139 in 22be6d0
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
code: 200 | ||||
--- error_log | ||||
http://127.0.0.1:9200/_bulk | ||||
http://127.0.0.1:9201/_bulk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extending endpoint_addr in a compatible way, and adding a new configuration is not a good choice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply.
What is your suggestion?
Can you give an example?
I refer to PR #7517
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this: https://github.com/apache/apisix/pull/7517/files#diff-d8d1670bb4d48884ee796f652172591cc371e5da972d7581ca585e60ddaab0f2R35, it also indicates the need to unify into one. You can refer to the definition of nodes_schema to allow endpoint_addrs to be set to multiple types: https://github.com/apache/apisix/blob/master/apisix/schema_def.lua#L289
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the helpful advice!
Hi @soulbird.
I fixed the code according to your suggestion. please review it.