From a5972f2033626bb8c88451c92db17f5502be6eb3 Mon Sep 17 00:00:00 2001 From: ccxhwmy Date: Mon, 29 Aug 2022 21:46:25 +0800 Subject: [PATCH] modify reviewer suggestion 1. remove useless code 2. replace application/json with application/x-ndjson 3. modify cp port from 9080 to 9180 --- apisix/plugins/elasticsearch-logger.lua | 7 +------ docs/en/latest/plugins/elasticsearch-logger.md | 10 +++++----- docs/zh/latest/plugins/elasticsearch-logger.md | 10 +++++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/apisix/plugins/elasticsearch-logger.lua b/apisix/plugins/elasticsearch-logger.lua index 346e6df91b69..105cbe4d98bb 100644 --- a/apisix/plugins/elasticsearch-logger.lua +++ b/apisix/plugins/elasticsearch-logger.lua @@ -31,11 +31,6 @@ local batch_processor_manager = bp_manager_mod.new(plugin_name) local schema = { type = "object", properties = { - meta_format = { - type = "string", - default = "default", - enum = {"default", "origin"}, - }, endpoint_addr = { type = "string", pattern = "[^/]$", @@ -133,7 +128,7 @@ local function send_to_elasticsearch(conf, entries) local uri = conf.endpoint_addr .. "/_bulk" local body = core.table.concat(entries, "") - local headers = {["Content-Type"] = "application/json"} + local headers = {["Content-Type"] = "application/x-ndjson"} if conf.auth then local authorization = "Basic " .. ngx.encode_base64( conf.auth.username .. ":" .. conf.auth.password diff --git a/docs/en/latest/plugins/elasticsearch-logger.md b/docs/en/latest/plugins/elasticsearch-logger.md index 6a1f40122095..51deead8649c 100644 --- a/docs/en/latest/plugins/elasticsearch-logger.md +++ b/docs/en/latest/plugins/elasticsearch-logger.md @@ -56,7 +56,7 @@ This Plugin supports using batch processors to aggregate and process entries (lo The example below shows a complete configuration of the Plugin on a specific Route: ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{ @@ -95,7 +95,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 \ The example below shows a bare minimum configuration of the Plugin on a Route: ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{ @@ -202,7 +202,7 @@ Configuring the Plugin metadata is global in scope. This means that it will take The example below shows how you can configure through the Admin API: ```shell -curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ +curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/elasticsearch-logger \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "log_format": { @@ -263,7 +263,7 @@ curl -X GET "http://127.0.0.1:9200/services/_search" | jq . ### Disable Metadata ```shell -curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ +curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/elasticsearch-logger \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE ``` @@ -272,7 +272,7 @@ curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ To disable the `elasticsearch-logger` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect. ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{}, diff --git a/docs/zh/latest/plugins/elasticsearch-logger.md b/docs/zh/latest/plugins/elasticsearch-logger.md index 31207ada30ff..82e035d05720 100644 --- a/docs/zh/latest/plugins/elasticsearch-logger.md +++ b/docs/zh/latest/plugins/elasticsearch-logger.md @@ -57,7 +57,7 @@ description: 本文介绍了 API 网关 Apache APISIX 的 elasticsearch-logger ### 完整配置示例 ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{ @@ -94,7 +94,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 \ ### 最小化配置示例 ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{ @@ -193,7 +193,7 @@ curl -X GET "http://127.0.0.1:9200/services/_search" | jq . ### 设置日志格式示例 ```shell -curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ +curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/elasticsearch-logger \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "log_format": { @@ -254,7 +254,7 @@ curl -X GET "http://127.0.0.1:9200/services/_search" | jq . ### 禁用插件元数据 ```shell -curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ +curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/elasticsearch-logger \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE ``` @@ -263,7 +263,7 @@ curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/elasticsearch-logger \ 当你需要禁用该插件时,可以通过如下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务: ```shell -curl http://127.0.0.1:9080/apisix/admin/routes/1 \ +curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "plugins":{},