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 2020/11/19 02:18:47 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #2592: feat: implement `error-log-logger` plug-in

spacewander commented on a change in pull request #2592:
URL: https://github.com/apache/apisix/pull/2592#discussion_r526543014



##########
File path: doc/plugins/error-log-logger.md
##########
@@ -0,0 +1,101 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+- [中文](../zh-cn/plugins/error-log-logger.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable And Disable**](#how-to-enable-and-disable)
+- [**How To Update**](#how-to-update)
+
+## Name
+
+`error-log-logger` is a plugin which push the log data of APISIX's error.log to TCP servers.
+
+This will provide the ability to send the log data which selected by the level to Monitoring tools and other TCP servers.
+
+This plugin provides the ability to push the log data as a batch to you're external TCP servers. In case if you did not recieve the log data don't worry give it some time it will automatically send the logs after the timer function expires in our Batch Processor.

Review comment:
       `you're` => your?
   `recieve` => `receive`

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},
+        batch_max_size = {type = "integer", minimum = 0, default = 1000},
+        max_retry_count = {type = "integer", minimum = 0, default = 0},
+        retry_delay = {type = "integer", minimum = 0, default = 1},
+        buffer_duration = {type = "integer", minimum = 1, default = 60},
+        inactive_timeout = {type = "integer", minimum = 1, default = 3},
+    },
+    required = {"host", "port"}
+}
+
+
+local log_level = {
+    STDERR =    ngx.STDERR,
+    EMERG  =    ngx.EMERG,
+    ALERT  =    ngx.ALERT,
+    CRIT   =    ngx.CRIT,
+    ERR    =    ngx.ERR,
+    ERROR  =    ngx.ERR,
+    WARN   =    ngx.WARN,
+    NOTICE =     ngx.NOTICE,
+    INFO   =    ngx.INFO,
+    DEBUG  =    ngx.DEBUG
+}
+
+
+local config = {}
+local buffers = {}
+
+
+local _M = {
+    version = 0.1,
+    priority = 1091,
+    name = plugin_name,
+    metadata_schema = metadata_schema,
+}
+
+
+local function send_to_server(data)
+    local sock, soc_err = tcp()
+
+    if not sock then
+        return false, "failed to init the socket " .. soc_err
+    end
+
+    sock:settimeout(config.timeout * 1000)
+
+    local ok, err = sock:connect(config.host, config.port)
+    if not ok then
+        return false, "failed to connect the TCP server: host[" .. config.host
+                         .. "] port[" .. tostring(config.port) .. "] err: " .. err

Review comment:
       Style: indent

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},
+        batch_max_size = {type = "integer", minimum = 0, default = 1000},
+        max_retry_count = {type = "integer", minimum = 0, default = 0},
+        retry_delay = {type = "integer", minimum = 0, default = 1},
+        buffer_duration = {type = "integer", minimum = 1, default = 60},
+        inactive_timeout = {type = "integer", minimum = 1, default = 3},
+    },
+    required = {"host", "port"}
+}
+
+
+local log_level = {
+    STDERR =    ngx.STDERR,
+    EMERG  =    ngx.EMERG,
+    ALERT  =    ngx.ALERT,
+    CRIT   =    ngx.CRIT,
+    ERR    =    ngx.ERR,
+    ERROR  =    ngx.ERR,
+    WARN   =    ngx.WARN,
+    NOTICE =     ngx.NOTICE,
+    INFO   =    ngx.INFO,
+    DEBUG  =    ngx.DEBUG
+}
+
+
+local config = {}
+local buffers = {}
+
+
+local _M = {
+    version = 0.1,
+    priority = 1091,
+    name = plugin_name,
+    metadata_schema = metadata_schema,
+}
+
+
+local function send_to_server(data)
+    local sock, soc_err = tcp()
+
+    if not sock then
+        return false, "failed to init the socket " .. soc_err
+    end
+
+    sock:settimeout(config.timeout * 1000)
+
+    local ok, err = sock:connect(config.host, config.port)
+    if not ok then
+        return false, "failed to connect the TCP server: host[" .. config.host
+                         .. "] port[" .. tostring(config.port) .. "] err: " .. err
+    end
+
+    if config.tls then
+        ok, err = sock:sslhandshake(true, config.tls_options, false)
+        if not ok then
+            return false, "failed to to perform TLS handshake to TCP server: host["
+                          .. config.host .. "] port[" .. tostring(config.port) .. "] err: " .. err
+        end
+    end
+
+    local bytes, err = sock:send(data)
+    if not bytes then
+        sock:close()
+        return false, "failed to send data to TCP server: host[" .. config.host
+                        .. "] port[" .. tostring(config.port) .. "] err: " .. err
+    end
+
+    sock:setkeepalive(config.keepalive * 1000)
+    return true
+end
+
+
+local function update_filter(value)
+    local level = log_level[string.upper(value.level)]
+    local status, err = errlog.set_filter_level(level)
+    if not status then
+        return nil, "failed to set filter level by ngx.errlog, the error is :" .. err
+    else
+        core.log.debug("set the filter_level to ", config.level)
+    end
+
+    return value
+end
+
+
+local function process()
+    local metadata = plugin.plugin_metadata(plugin_name)
+    if not (metadata and metadata.value and metadata.modifiedIndex) then
+        core.log.info("please set the correct plugin_metadata for ", plugin_name)
+        return
+    else
+        local err
+        config, err = lrucache(plugin_name, metadata.modifiedIndex, update_filter,
+                                 metadata.value)
+        if not config then
+            core.log.warn("set log filter failed for ", err)
+            return
+        end
+
+    end
+
+    local id = ngx.worker.id()
+    local entries = {}
+    local logs = errlog.get_logs(10)

Review comment:
       Better to get 3's multiple? Like `get_logs(9)`. And we should reuse `logs` as the second argument of `get_logs`.

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},
+        batch_max_size = {type = "integer", minimum = 0, default = 1000},
+        max_retry_count = {type = "integer", minimum = 0, default = 0},
+        retry_delay = {type = "integer", minimum = 0, default = 1},
+        buffer_duration = {type = "integer", minimum = 1, default = 60},
+        inactive_timeout = {type = "integer", minimum = 1, default = 3},
+    },
+    required = {"host", "port"}
+}
+
+
+local log_level = {
+    STDERR =    ngx.STDERR,
+    EMERG  =    ngx.EMERG,
+    ALERT  =    ngx.ALERT,
+    CRIT   =    ngx.CRIT,
+    ERR    =    ngx.ERR,
+    ERROR  =    ngx.ERR,
+    WARN   =    ngx.WARN,
+    NOTICE =     ngx.NOTICE,
+    INFO   =    ngx.INFO,
+    DEBUG  =    ngx.DEBUG
+}
+
+
+local config = {}
+local buffers = {}
+
+
+local _M = {
+    version = 0.1,
+    priority = 1091,
+    name = plugin_name,
+    metadata_schema = metadata_schema,
+}
+
+
+local function send_to_server(data)
+    local sock, soc_err = tcp()
+
+    if not sock then
+        return false, "failed to init the socket " .. soc_err
+    end
+
+    sock:settimeout(config.timeout * 1000)
+
+    local ok, err = sock:connect(config.host, config.port)
+    if not ok then
+        return false, "failed to connect the TCP server: host[" .. config.host
+                         .. "] port[" .. tostring(config.port) .. "] err: " .. err
+    end
+
+    if config.tls then
+        ok, err = sock:sslhandshake(true, config.tls_options, false)
+        if not ok then
+            return false, "failed to to perform TLS handshake to TCP server: host["
+                          .. config.host .. "] port[" .. tostring(config.port) .. "] err: " .. err
+        end
+    end
+
+    local bytes, err = sock:send(data)
+    if not bytes then
+        sock:close()
+        return false, "failed to send data to TCP server: host[" .. config.host
+                        .. "] port[" .. tostring(config.port) .. "] err: " .. err
+    end
+
+    sock:setkeepalive(config.keepalive * 1000)
+    return true
+end
+
+
+local function update_filter(value)
+    local level = log_level[string.upper(value.level)]
+    local status, err = errlog.set_filter_level(level)
+    if not status then
+        return nil, "failed to set filter level by ngx.errlog, the error is :" .. err
+    else
+        core.log.debug("set the filter_level to ", config.level)
+    end
+
+    return value
+end
+
+
+local function process()
+    local metadata = plugin.plugin_metadata(plugin_name)
+    if not (metadata and metadata.value and metadata.modifiedIndex) then
+        core.log.info("please set the correct plugin_metadata for ", plugin_name)
+        return
+    else
+        local err
+        config, err = lrucache(plugin_name, metadata.modifiedIndex, update_filter,
+                                 metadata.value)

Review comment:
       Style: indent

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},
+        batch_max_size = {type = "integer", minimum = 0, default = 1000},
+        max_retry_count = {type = "integer", minimum = 0, default = 0},
+        retry_delay = {type = "integer", minimum = 0, default = 1},
+        buffer_duration = {type = "integer", minimum = 1, default = 60},
+        inactive_timeout = {type = "integer", minimum = 1, default = 3},
+    },
+    required = {"host", "port"}
+}
+
+
+local log_level = {
+    STDERR =    ngx.STDERR,
+    EMERG  =    ngx.EMERG,
+    ALERT  =    ngx.ALERT,
+    CRIT   =    ngx.CRIT,
+    ERR    =    ngx.ERR,
+    ERROR  =    ngx.ERR,
+    WARN   =    ngx.WARN,
+    NOTICE =     ngx.NOTICE,
+    INFO   =    ngx.INFO,
+    DEBUG  =    ngx.DEBUG
+}
+
+
+local config = {}
+local buffers = {}
+
+
+local _M = {
+    version = 0.1,
+    priority = 1091,
+    name = plugin_name,
+    metadata_schema = metadata_schema,
+}
+
+
+local function send_to_server(data)
+    local sock, soc_err = tcp()
+
+    if not sock then
+        return false, "failed to init the socket " .. soc_err
+    end
+
+    sock:settimeout(config.timeout * 1000)
+
+    local ok, err = sock:connect(config.host, config.port)
+    if not ok then
+        return false, "failed to connect the TCP server: host[" .. config.host
+                         .. "] port[" .. tostring(config.port) .. "] err: " .. err
+    end
+
+    if config.tls then
+        ok, err = sock:sslhandshake(true, config.tls_options, false)
+        if not ok then

Review comment:
       Should close the socket when handshake failed.

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},
+        batch_max_size = {type = "integer", minimum = 0, default = 1000},
+        max_retry_count = {type = "integer", minimum = 0, default = 0},
+        retry_delay = {type = "integer", minimum = 0, default = 1},
+        buffer_duration = {type = "integer", minimum = 1, default = 60},
+        inactive_timeout = {type = "integer", minimum = 1, default = 3},
+    },
+    required = {"host", "port"}
+}
+
+
+local log_level = {
+    STDERR =    ngx.STDERR,
+    EMERG  =    ngx.EMERG,
+    ALERT  =    ngx.ALERT,
+    CRIT   =    ngx.CRIT,
+    ERR    =    ngx.ERR,
+    ERROR  =    ngx.ERR,
+    WARN   =    ngx.WARN,
+    NOTICE =     ngx.NOTICE,

Review comment:
       Style: indent

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        tls = {type = "boolean", default = false},
+        tls_options = {type = "string"},
+        timeout = {type = "integer", minimum = 1, default = 3},
+        keepalive = {type = "integer", minimum = 1, default = 30},
+        name = {type = "string", default = plugin_name},
+        level = {type = "string", default = "WARN"},

Review comment:
       Need to validate with enum, like this: ` enum = {"GET", "POST", "PUT", "DELETE", "PATCH",`

##########
File path: doc/plugins/error-log-logger.md
##########
@@ -0,0 +1,101 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+- [中文](../zh-cn/plugins/error-log-logger.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable And Disable**](#how-to-enable-and-disable)
+- [**How To Update**](#how-to-update)
+
+## Name
+
+`error-log-logger` is a plugin which push the log data of APISIX's error.log to TCP servers.
+
+This will provide the ability to send the log data which selected by the level to Monitoring tools and other TCP servers.
+
+This plugin provides the ability to push the log data as a batch to you're external TCP servers. In case if you did not recieve the log data don't worry give it some time it will automatically send the logs after the timer function expires in our Batch Processor.
+
+For more info on Batch-Processor in Apache APISIX please refer.
+[Batch-Processor](../batch-processor.md)
+
+## Attributes
+
+| Name             | Type    | Requirement | Default | Valid   | Description                                                                              |
+| ---------------- | ------- | ----------- | ------- | ------- | ---------------------------------------------------------------------------------------- |
+| host             | string  | required    |         |         | IP address or the Hostname of the TCP server.                                            |
+| port             | integer | required    |         | [0,...] | Target upstream port.                                                                    |
+| timeout          | integer | optional    | 3       | [1,...] | Timeout for the upstream to connect and send, unit: second.                                                   |
+| keepalive        | integer | optional    | 30      | [1,...] | Time for keeping the cosocket alive, unit: second.                                                   |
+| level            | string  | optional    | WARN    |         | The filter's log level, default warn, chose the level in ["STDERR", "EMERG", "ALERT", "CRIT", "ERR", "ERROR", "WARN", "NOTICE", "INFO", "DEBUG"], the value ERR equals ERROR.         |

Review comment:
       "chose" => "choose"

##########
File path: apisix/plugins/error-log-logger.lua
##########
@@ -0,0 +1,204 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local errlog = require("ngx.errlog")
+local batch_processor = require("apisix.utils.batch-processor")
+local plugin = require("apisix.plugin")
+local timers = require("apisix.timers")
+local plugin_name = "error-log-logger"
+local table = core.table
+local ngx = ngx
+local tcp = ngx.socket.tcp
+local string = string
+local tostring = tostring
+local ipairs  = ipairs
+local lrucache = core.lrucache.new({
+    ttl = 300, count = 32
+})
+
+
+local metadata_schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},

Review comment:
       Need to validate with `core.schema.host_def`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org