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/01/16 05:15:22 UTC

[GitHub] [incubator-apisix] sshniro opened a new pull request #1070: Adding UDP logger plugin

sshniro opened a new pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070
 
 
   The UDP logger sends the logs to a UDP server. 
   Fix for #1069 
   

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367751556
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
 
 Review comment:
   aw forgot! will refactor.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367748401
 
 

 ##########
 File path: lua/apisix/plugins/log-util.lua
 ##########
 @@ -0,0 +1,62 @@
+--
+-- 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 _M = {}
+
+local function get_full_log(ngx)
+
+    local ctx = ngx.ctx.api_ctx
+    local var = ctx.var
+
+    local url = var.scheme .. "://" .. var.host .. ":" .. var.server_port .. var.request_uri
+
+    local service_name
+    local vars = var
+    if ctx.matched_route and ctx.matched_route.value then
+        service_name = ctx.matched_route.value.desc or
 
 Review comment:
   It should not be `service_name`, it is the description of `route`. 
   We need a better name here.
   
   https://github.com/apache/incubator-apisix/blob/master/lua/apisix/plugins/prometheus/exporter.lua#L71

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367254876
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+
 
 Review comment:
   please remove this blank line

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367255006
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+    end
+
+    ok, err = sock:close()
+
+    if not ok then
+        core.log.error("Failed to close the UDP connection, host[", conf.host, "] port[", conf.port, "] ", err)
+    end
+end
+
+
+function _M.log(conf)
+
 
 Review comment:
   delete this blank line

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367753240
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+
+    local ok, err = sock:setpeername(conf.host, conf.port)
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
 
 Review comment:
   You are right, sorry for this.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575553334
 
 
   @membphis the review comments have been resolved, thanks for the pointers.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367751505
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+
+    local ok, err = sock:setpeername(conf.host, conf.port)
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
 
 Review comment:
   @membphis do you mean to return and end the function after error? In that case don't we have to close the socket? (which is done in the next line of statements)

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367748401
 
 

 ##########
 File path: lua/apisix/plugins/log-util.lua
 ##########
 @@ -0,0 +1,62 @@
+--
+-- 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 _M = {}
+
+local function get_full_log(ngx)
+
+    local ctx = ngx.ctx.api_ctx
+    local var = ctx.var
+
+    local url = var.scheme .. "://" .. var.host .. ":" .. var.server_port .. var.request_uri
+
+    local service_name
+    local vars = var
+    if ctx.matched_route and ctx.matched_route.value then
+        service_name = ctx.matched_route.value.desc or
 
 Review comment:
   that should not be `service_name`, it should be the description of `route`. 
   We need a better name here.
   
   https://github.com/apache/incubator-apisix/blob/master/lua/apisix/plugins/prometheus/exporter.lua#L71

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367747767
 
 

 ##########
 File path: lua/apisix/plugins/log-util.lua
 ##########
 @@ -0,0 +1,62 @@
+--
+-- 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 _M = {}
+
+local function get_full_log(ngx)
+
 
 Review comment:
   Code style: between the function and the code, this blank line is not needed, and please fix other similar places.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367727549
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
 
 Review comment:
   @membphis as these are individual JSON messages is it okay to add a tail to the JSON string? 

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367848357
 
 

 ##########
 File path: lua/apisix/plugins/log-util.lua
 ##########
 @@ -0,0 +1,62 @@
+--
+-- 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 _M = {}
+
+local function get_full_log(ngx)
+
+    local ctx = ngx.ctx.api_ctx
+    local var = ctx.var
+
+    local url = var.scheme .. "://" .. var.host .. ":" .. var.server_port .. var.request_uri
+
+    local service_name
+    local vars = var
+    if ctx.matched_route and ctx.matched_route.value then
+        service_name = ctx.matched_route.value.desc or
 
 Review comment:
   added service id, and route id as advised.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367254331
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
 
 Review comment:
   ditto

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] moonming merged pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
moonming merged pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070
 
 
   

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367748970
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
 
 Review comment:
   We should delete this logic because we have specified the default value through `schema`.
   
   https://github.com/apache/incubator-apisix/pull/1070/files#diff-7e79d5b9c98bca193773cd21898e449cR30

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575402718
 
 
   ```
   t/admin/plugins.t ...................... 1/? 
   #   Failed test 'TEST 1: get plugins' name - response_body_like - response is expected (["limit-req","limit-count","limit-conn","key-auth","basic-auth","prometheus","node-status","jwt-auth","zipkin","ip-restriction","grpc-transcode","serverless-pre-function","serverless-post-function","openid-connect","proxy-rewrite","redirect","response-rewrite","fault-injection","udp-logger"])'
   #   at /home/travis/build/apache/incubator-apisix/test-nginx/lib/Test/Nginx/Socket.pm line 1635.
   #                   '["limit-req","limit-count","limit-conn","key-auth","basic-auth","prometheus","node-status","jwt-auth","zipkin","ip-restriction","grpc-transcode","serverless-pre-function","serverless-post-function","openid-connect","proxy-rewrite","redirect","response-rewrite","fault-injection","udp-logger"]
   # '
   #     doesn't match '(?^:\["limit-req","limit-count","limit-conn","key-auth","prometheus","node-status","jwt-auth","zipkin","ip-restriction","grpc-transcode","serverless-pre-function","serverless-post-function","openid-connect","proxy-rewrite","redirect","response-rewrite","udp-logger"\])'
   t/admin/plugins.t ...................... 3/? # Looks like you failed 1 test of 3.
   ```

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367255035
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+    end
+
+    ok, err = sock:close()
+
+    if not ok then
+        core.log.error("Failed to close the UDP connection, host[", conf.host, "] port[", conf.port, "] ", err)
+    end
+end
+
+
+function _M.log(conf)
+
+    return timer_at(0, log, conf, core.json.encode(log_util.get_full_log(ngx)))
+
 
 Review comment:
   ditto

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575449117
 
 
   > should I round the number for latency?
   
   Recommended to milliseconds.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575447317
 
 
   @membphis  The following is the final log sent to the server.
   
   ```json
   {
     "upstream": "127.0.0.1:80",
     "start_time": 1579231324391,
     "client_ip": "127.0.0.1",
     "service_id": "10",
     "route_id": "5",
     "request": {
       "querystring": {
         "param1": "value"
       },
       "size": 118,
       "uri": "/?param1=value",
       "url": "http://127.0.0.1:9080/?param1=value",
       "headers": {
         "host": "127.0.0.1:9080",
         "apikey": "superSecretAPIKey",
         "accept": "*/*",
         "user-agent": "curl/7.58.0"
       },
       "method": "GET"
     },
     "response": {
       "headers": {
         "accept-ranges": "bytes",
         "content-type": "text/html",
         "date": "Fri, 17 Jan 2020 03:22:04 GMT",
         "server": "APISIX web server",
         "connection": "close",
         "last-modified": "Thu, 29 Aug 2019 23:49:13 GMT",
         "etag": "\"5d686479-289\"",
         "content-length": "649"
       },
       "status": 200,
       "size": 892
     },
     "latency": 0.99992752075195
   }
   ````
   should I round the number for latency?

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367256569
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
 
 Review comment:
   I think we'd better add a tail `\r\n` or `\n` for each log message.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367749246
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+
+    local ok, err = sock:setpeername(conf.host, conf.port)
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
 
 Review comment:
   `Failed to send data` to `failed to send data`

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367731644
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+    local ok, err = sock:setpeername(conf.host, conf.port)
+
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
 
 Review comment:
   You can ignore this message. that is a UDP connection, we do not need to use a separator between different log messages.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] moonming commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
moonming commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575040974
 
 
   > There are performance issues with the per-request log message mode.
   > 
   > It is better to put log messages in the queue first, and then send them in batches.
   
   Done is better then perfect. I think we can use another PR to fix performance issues.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367254647
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
+        timeout = {type = "number", minimum = 1} --default is 3 seconds
 
 Review comment:
   we can specify the default value directly.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367254302
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,87 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "number"},
 
 Review comment:
   It should be 'integer', and the value should more than `0`.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367749155
 
 

 ##########
 File path: lua/apisix/plugins/udp-logger.lua
 ##########
 @@ -0,0 +1,83 @@
+--
+-- 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 log_util = require("apisix.plugins.log-util")
+local plugin_name = "udp-logger"
+local ngx = ngx
+
+local timer_at = ngx.timer.at
+local udp = ngx.socket.udp
+
+local schema = {
+    type = "object",
+    properties = {
+        host = {type = "string"},
+        port = {type = "integer", minimum = 0},
+        timeout = {type = "integer", minimum = 1, default= 1000} -- timeout in milliseconds
+    },
+    required = {"host", "port"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = 400,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+
+    if not conf.timeout then
+        conf.timeout = 3
+    end
+
+    return core.schema.check(schema, conf)
+end
+
+local function log(premature, conf, log_message)
+    if premature then
+        return
+    end
+
+    local sock = udp()
+    sock:settimeout(conf.timeout)
+
+    local ok, err = sock:setpeername(conf.host, conf.port)
+    if not ok then
+        core.log.error("Failed to connect to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
+        return
+    end
+
+    ok, err = sock:send(log_message)
+    if not ok then
+        core.log.error("Failed to send data to UDP server: host[", conf.host, "] port[", conf.port, "] ", err)
 
 Review comment:
   need to return directly 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on issue #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#issuecomment-575013794
 
 
   There are performance issues with the per-request log message mode.
   
   It is better to put log messages in the queue first, and then send them in batches.

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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] sshniro commented on a change in pull request #1070: Adding UDP logger plugin

Posted by GitBox <gi...@apache.org>.
sshniro commented on a change in pull request #1070: Adding UDP logger plugin
URL: https://github.com/apache/incubator-apisix/pull/1070#discussion_r367848357
 
 

 ##########
 File path: lua/apisix/plugins/log-util.lua
 ##########
 @@ -0,0 +1,62 @@
+--
+-- 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 _M = {}
+
+local function get_full_log(ngx)
+
+    local ctx = ngx.ctx.api_ctx
+    local var = ctx.var
+
+    local url = var.scheme .. "://" .. var.host .. ":" .. var.server_port .. var.request_uri
+
+    local service_name
+    local vars = var
+    if ctx.matched_route and ctx.matched_route.value then
+        service_name = ctx.matched_route.value.desc or
 
 Review comment:
   added serivice id, and route id as adviced.

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


With regards,
Apache Git Services