Skip to content

Commit

Permalink
modify reviewer suggestion
Browse files Browse the repository at this point in the history
1. remove useless code
2. replace application/json with application/x-ndjson
3. modify cp port from 9080 to 9180
  • Loading branch information
ccxhwmy committed Aug 29, 2022
1 parent 5062c8d commit a5972f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
7 changes: 1 addition & 6 deletions apisix/plugins/elasticsearch-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[^/]$",
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/en/latest/plugins/elasticsearch-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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":{
Expand Down Expand Up @@ -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":{
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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
```

Expand All @@ -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":{},
Expand Down
10 changes: 5 additions & 5 deletions docs/zh/latest/plugins/elasticsearch-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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":{
Expand Down Expand Up @@ -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":{
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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
```

Expand All @@ -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":{},
Expand Down

0 comments on commit a5972f2

Please sign in to comment.