You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/07/21 10:00:17 UTC
[GitHub] [apisix] zhendongcmss opened a new pull request, #7517: feat(clickhouse-logger): support multi endpoints
zhendongcmss opened a new pull request, #7517:
URL: https://github.com/apache/apisix/pull/7517
### Description
<!-- Please include a summary of the change and which issue is fixed. -->
<!-- Please also include relevant motivation and context. -->
Fixes # (issue)
### 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](https://github.com/apache/apisix/tree/master#community) first)
<!--
Note
1. Mark the PR as draft until it's ready to be reviewed.
2. Always add/update tests for any changes unless you have a good reason.
3. Always update the documentation to reflect the changes made in the PR.
4. Make a new commit to resolve conversations instead of `push -f`.
5. To resolve merge conflicts, merge master instead of rebasing.
6. Use "request review" to notify the reviewer after making changes.
7. Only a reviewer can mark a conversation as resolved.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r930687658
##########
t/plugin/clickhouse-logger.t:
##########
@@ -175,7 +187,49 @@ passed
-=== TEST 5: access local server
+=== TEST 5: add plugin on routes using multi clickhouse-logger
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "clickhouse-logger": {
+ "user": "default",
+ "password": "a",
+ "database": "default",
+ "logtable": "t",
+ "endpoint_addr": ["http://127.0.0.1:10420/clickhouse-logger/test",
Review Comment:
```suggestion
"endpoint_addrs": ["http://127.0.0.1:10420/clickhouse-logger/test",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] zhendongcmss commented on pull request #7517: feat(clickhouse-logger): support multi endpoints
Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on PR #7517:
URL: https://github.com/apache/apisix/pull/7517#issuecomment-1193264792
> files conflict, pls rebase the upstream master to your PR branch.
resolved
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r928488132
##########
apisix/plugins/clickhouse-logger.lua:
##########
@@ -32,7 +32,7 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
type = "object",
properties = {
- endpoint_addrs = {items = core.schema.uri_def, type = "array", minItems = 1},
+ endpoint_addrs = {items = core.schema.uri_def, type = "array", minItems = 1}, -- deprecated, use "host" instead
Review Comment:
Err... I mean keeping the original endpoint_addr and marking it as deprecated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r928249785
##########
t/plugin/clickhouse-logger.t:
##########
@@ -149,7 +161,7 @@ property "endpoint_addr" is required
"password": "a",
"database": "default",
"logtable": "t",
- "endpoint_addr": "http://127.0.0.1:10420/clickhouse-logger/test",
+ "endpoint_addrs": ["http://127.0.0.1:10420/clickhouse-logger/test"],
Review Comment:
We can keep an old test to test the compatibility of the deprecated configuration
##########
apisix/plugins/clickhouse-logger.lua:
##########
@@ -31,7 +32,7 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
type = "object",
properties = {
- endpoint_addr = core.schema.uri_def,
Review Comment:
Would be better to keep the old conf and mark it as deprecated?
Like https://github.com/apache/apisix/blob/1771c51f94d1c5c4f6542a9d90c7c1d777b992d2/apisix/stream/plugins/mqtt-proxy.lua#L40
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] zhendongcmss commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r930550880
##########
apisix/plugins/clickhouse-logger.lua:
##########
@@ -72,11 +74,12 @@ end
local function send_http_data(conf, log_message)
local err_msg
local res = true
- local url_decoded = url.parse(conf.endpoint_addr)
+ local selected_endpoint_addr = conf.endpoint_addr[math_random(#conf.endpoint_addr)]
+ local url_decoded = url.parse(selected_endpoint_addr)
local host = url_decoded.host
local port = url_decoded.port
- core.log.info("sending a batch logs to ", conf.endpoint_addr)
+ core.log.info("sending a batch logs to ", selected_endpoint_addr)
Review Comment:
selected_endpoint_addr is ONLY one endpoint by randomly selected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] zhendongcmss commented on pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on PR #7517:
URL: https://github.com/apache/apisix/pull/7517#issuecomment-1194853509
The test case doesn't pass.
https://github.com/apache/apisix/runs/7500977665?check_suite_focus=true#step:14:538
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r928608953
##########
docs/en/latest/plugins/clickhouse-logger.md:
##########
@@ -35,7 +35,7 @@ The `clickhouse-logger` Plugin is used to push logs to [ClickHouse](https://clic
| Name | Type | Required | Default | Valid values | Description |
|---------------|---------|----------|---------------------|--------------|----------------------------------------------------------------|
-| endpoint_addr | string | True | | | ClickHouse endpoint. |
Review Comment:
Also let's keep the old conf and mark it as deprecated like what we have done with `upstream.ip` in https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/mqtt-proxy.md#attributes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r929530667
##########
docs/en/latest/plugins/clickhouse-logger.md:
##########
@@ -35,7 +35,7 @@ The `clickhouse-logger` Plugin is used to push logs to [ClickHouse](https://clic
| Name | Type | Required | Default | Valid values | Description |
|---------------|---------|----------|---------------------|--------------|----------------------------------------------------------------|
-| endpoint_addr | string | True | | | ClickHouse endpoint. |
+| endpoint_addr | Deprecated | True | | | Use `host` instead. ClickHouse endpoints. |
Review Comment:
`host` is not exposed in the plugin scheme?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on pull request #7517: feat(clickhouse-logger): support multi endpoints
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on PR #7517:
URL: https://github.com/apache/apisix/pull/7517#issuecomment-1192129068
files conflict, pls rebase the upstream master to your PR branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r929540725
##########
docs/en/latest/plugins/clickhouse-logger.md:
##########
@@ -35,7 +35,7 @@ The `clickhouse-logger` Plugin is used to push logs to [ClickHouse](https://clic
| Name | Type | Required | Default | Valid values | Description |
|---------------|---------|----------|---------------------|--------------|----------------------------------------------------------------|
-| endpoint_addr | string | True | | | ClickHouse endpoint. |
Review Comment:
```
| endpoint_addr | string | True | | | Deprecated, use `endpoint_addrs` instead. ClickHouse endpoint. |
| endpoint_addrs | array | True | | | ClickHouse endpoints. |
```
##########
apisix/plugins/clickhouse-logger.lua:
##########
@@ -31,7 +32,8 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
type = "object",
properties = {
- endpoint_addr = core.schema.uri_def,
+ -- deprecated, use "host" instead
+ endpoint_addr = {items = core.schema.uri_def, type = "array", minItems = 1},
Review Comment:
In fact, I suggest to use:
```
-- deprecated, use "endpoint_addrs" instead
endpoint_addr = core.schema.uri_def,
endpoint_addrs = {items = core.schema.uri_def, type = "array", minItems = 1},
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r929531364
##########
t/plugin/clickhouse-logger.t:
##########
@@ -171,11 +183,53 @@ property "endpoint_addr" is required
}
}
--- response_body
+{"error_msg":"failed to check the configuration of plugin clickhouse-logger err: property "endpoint_addr" validation failed: wrong type: expected array, got string"}
+--- error_code: 400
+
+
+
+=== TEST 5: add plugin on routes using multi clickhouse-logger
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "clickhouse-logger": {
+ "user": "default",
+ "password": "a",
+ "database": "default",
+ "logtable": "t",
+ "endpoint_addr": ["http://127.0.0.1:10420/clickhouse-logger/test",
Review Comment:
since `endpoint_addr` is marked as deprecated, should we use `host` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] zhendongcmss commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r928370177
##########
t/plugin/clickhouse-logger.t:
##########
@@ -149,7 +161,7 @@ property "endpoint_addr" is required
"password": "a",
"database": "default",
"logtable": "t",
- "endpoint_addr": "http://127.0.0.1:10420/clickhouse-logger/test",
+ "endpoint_addrs": ["http://127.0.0.1:10420/clickhouse-logger/test"],
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r929529757
##########
apisix/plugins/clickhouse-logger.lua:
##########
@@ -72,11 +74,12 @@ end
local function send_http_data(conf, log_message)
local err_msg
local res = true
- local url_decoded = url.parse(conf.endpoint_addr)
+ local selected_endpoint_addr = conf.endpoint_addr[math_random(#conf.endpoint_addr)]
+ local url_decoded = url.parse(selected_endpoint_addr)
local host = url_decoded.host
local port = url_decoded.port
- core.log.info("sending a batch logs to ", conf.endpoint_addr)
+ core.log.info("sending a batch logs to ", selected_endpoint_addr)
Review Comment:
if `selected_endpoint_addr ` is a table. would it better to use `core.json.delay_encode(selected_endpoint_addr)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on a diff in pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7517:
URL: https://github.com/apache/apisix/pull/7517#discussion_r929530590
##########
docs/en/latest/plugins/clickhouse-logger.md:
##########
@@ -35,7 +35,7 @@ The `clickhouse-logger` Plugin is used to push logs to [ClickHouse](https://clic
| Name | Type | Required | Default | Valid values | Description |
|---------------|---------|----------|---------------------|--------------|----------------------------------------------------------------|
-| endpoint_addr | string | True | | | ClickHouse endpoint. |
+| endpoint_addr | Deprecated | True | | | Use `host` instead. ClickHouse endpoints. |
Review Comment:
`host` is not exposed in the plugin scheme?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander merged pull request #7517: feat(clickhouse-logger): support multi clickhouse endpoints
Posted by GitBox <gi...@apache.org>.
spacewander merged PR #7517:
URL: https://github.com/apache/apisix/pull/7517
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org