[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r804344901 ## File path: apisix/plugins/loggly.lua ## @@ -85,6 +86,17 @@ local schema = { type = "boolean", default = true }, +severity_map = { +type = "object", +description = "upstream response code vs syslog severity mapping", +patternProperties = { +[".*"] = { Review comment: Got it. What about adding `additionalProperties = false,`? So the mismatch key will cause an error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r804344901 ## File path: apisix/plugins/loggly.lua ## @@ -85,6 +86,17 @@ local schema = { type = "boolean", default = true }, +severity_map = { +type = "object", +description = "upstream response code vs syslog severity mapping", +patternProperties = { +[".*"] = { Review comment: Got it. What about adding `"additionalProperties": false`? So the mismatch key will cause an error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r803238364 ## File path: apisix/plugins/loggly.lua ## @@ -85,6 +86,17 @@ local schema = { type = "boolean", default = true }, +severity_map = { +type = "object", +description = "upstream response code vs syslog severity mapping", +patternProperties = { +[".*"] = { Review comment: Does `["^[1-5][0-9]{2}$"] = {...}` work for it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r803238141 ## File path: apisix/plugins/loggly.lua ## @@ -145,6 +157,18 @@ function _M.check_schema(conf, schema_type) if not ok then return nil, err end + +if conf.severity_map then +local cache = {} +for k, v in pairs(conf.severity_map) do +local rcode = tonumber(k) +if not rcode or rcode < 100 or rcode >= 600 then +return nil, "expecting severity_map with http response code([100,599]) as keys" +end +cache[k] = severity[v:upper()] Review comment: OK -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r801226395 ## File path: apisix/plugins/loggly.lua ## @@ -85,6 +86,17 @@ local schema = { type = "boolean", default = true }, +severity_map = { +type = "object", +description = "upstream response code vs syslog severity mapping", +patternProperties = { +[".*"] = { Review comment: We can use regex to verify the range of status code? ## File path: apisix/plugins/loggly.lua ## @@ -145,6 +157,18 @@ function _M.check_schema(conf, schema_type) if not ok then return nil, err end + +if conf.severity_map then +local cache = {} +for k, v in pairs(conf.severity_map) do +local rcode = tonumber(k) +if not rcode or rcode < 100 or rcode >= 600 then +return nil, "expecting severity_map with http response code([100,599]) as keys" +end +cache[k] = severity[v:upper()] Review comment: We can convert k to a number? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on a change in pull request #6228: feat(loggly): support HTTP response code to SYSLOG severity mapping
spacewander commented on a change in pull request #6228: URL: https://github.com/apache/apisix/pull/6228#discussion_r794986279 ## File path: apisix/plugins/loggly.lua ## @@ -184,9 +202,18 @@ local function generate_log_message(conf, ctx) core.table.insert(taglist, "tag=\"" .. conf.tags[i] .. "\"") end end + +local message_severity = severity[conf.severity:upper()] Review comment: Let's do the conversion in `check_schema` so we don't need to do it per request. ## File path: apisix/plugins/loggly.lua ## @@ -145,6 +150,19 @@ function _M.check_schema(conf, schema_type) if not ok then return nil, err end + +if conf.severity_map then +for k, v in pairs(conf.severity_map) do +local rcode = tonumber(k) Review comment: We can do part of the validation in jsonschema? Like https://github.com/apache/apisix/blob/82d17abf9987528856cbd20ce5f17f2ae0a799ce/apisix/schema_def.lua#L94 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org