Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with the "mashape-analytics" plugin #423

Closed
dpanelli opened this issue Jul 23, 2015 · 4 comments
Closed

Error with the "mashape-analytics" plugin #423

dpanelli opened this issue Jul 23, 2015 · 4 comments
Assignees
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. task/bug

Comments

@dpanelli
Copy link

Hello ,
I'm having this error after activating the plugin:

2015/07/23 13:32:59 [error] 37#0: *110 failed to run log_by_lua*: ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:139: bad argument #1 to 'len' (string expected, got nil)
stack traceback:
    [builtin:len]: in function 'len'
    ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:139: in function 'serialize_entry'
    ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:175: in function 'add_entry'
    ...share/lua/5.1/kong/plugins/mashape-analytics/handler.lua:140: in function 'log'
    /usr/local/share/lua/5.1/kong.lua:254: in function 'exec_plugins_log'
    log_by_lua(nginx.conf:103):1: in function <log_by_lua(nginx.conf:103):1>

Any idea?

I'm using the latest docker image.

@nicksamps
Copy link

+1

Here's some of our logs:

2015/07/23 18:53:28 [error] 10032#0: *911285 failed to run log_by_lua*: ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:99: attempt to perform arithmetic on field 'upstream_response_time' (a string value)
stack traceback:
    ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:99: in function 'serialize_entry'
    ...local/share/lua/5.1/kong/plugins/log_serializers/alf.lua:175: in function 'add_entry'
    ...share/lua/5.1/kong/plugins/mashape-analytics/handler.lua:140: in function 'log'
    /usr/local/share/lua/5.1/kong.lua:254: in function 'exec_plugins_log'
    log_by_lua(nginx.conf:103):1: in function <log_by_lua(nginx.conf:103):1> while logging request, 
2015/07/23 18:53:54 [error] 10032#0: [lua] handler.lua:68: [mashape-analytics] socket refused the batch: , context: ngx.timer, client: 47.19.42.194, server: 0.0.0.0:80
2015/07/23 18:53:54 [error] 10032#0: [lua] handler.lua:68: [mashape-analytics] socket refused the batch: The payload may not exceed 1Mb, context: ngx.timer, client: 162.1.129.32, server: 0.0.0.0:80

@thibaultcha thibaultcha self-assigned this Jul 23, 2015
@thibaultcha thibaultcha added task/bug idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. labels Jul 23, 2015
@nicksamps
Copy link

I'm actually seeing a similar error with file log as well

[error] 10561#0: *6449 failed to run log_by_lua*: ...cal/share/lua/5.1/kong/plugins/log_serializers/basic.lua:22: attempt to perform arithmetic on field 'upstream_response_time' (a nil value)
stack traceback:
    ...cal/share/lua/5.1/kong/plugins/log_serializers/basic.lua:22: in function 'serialize'
    /usr/local/share/lua/5.1/kong/plugins/filelog/log.lua:44: in function 'execute'
    /usr/local/share/lua/5.1/kong/plugins/filelog/handler.lua:12: in function 'log'
    /usr/local/share/lua/5.1/kong.lua:254: in function 'exec_plugins_log'
    log_by_lua(nginx.conf:103):1: in function <log_by_lua(nginx.conf:103):1> while logging request, client: 216.234.104.26, server: _, request: 

Also seeing a bunch of nginx workers dying as well, for example:

2015/07/23 20:03:03 [alert] 10510#0: worker process 10561 exited on signal 11 (core dumped)

thibaultcha added a commit that referenced this issue Jul 23, 2015
- fix an issue when `log_body` was true but the request had no body (GET
  request for example)
- fix an issue when nginx is retrying against upstream after a timeout
  and resulting in multiple `upstream_response_time` values

  addressing #423
@thibaultcha
Copy link
Member

#425 addresses both those issues.

  • One was related to this nginx directive being enabled by default for upstream requests that timeout, thus resulting in an edge-case not handled by the ALF serializer.
  • The other was an issue when log_body was enabled but the request had no body (ex: GET request)

The other errors you are seeing @nicksamps is because you have log_body enabled and thus the buffer is considerably bigger than usual. The mashape analytics server doesn't allow payloads bigger than 1Mb, thus refuses the content of your buffer. This edge-case is not handled yet by the plugin, so I would suggest either not logging the bodies (analytics doesn't use them yet anyways) or set a smaller batch_size value so the buffer gets flushed more frequently and contains less data.

@nicksamps
Copy link

Got it, thanks @thibaultcha

ctranxuan pushed a commit to streamdataio/kong that referenced this issue Aug 25, 2015
- fix an issue when `log_body` was true but the request had no body (GET
  request for example)
- fix an issue when nginx is retrying against upstream after a timeout
  and resulting in multiple `upstream_response_time` values

  addressing Kong#423


Former-commit-id: db2d75180c01ccd2a96df7aad093dfae8aa742a8
bungle added a commit that referenced this issue Aug 8, 2022
### Summary

#### 1.13.1 (2022-Jul-22)
 - fix: `warn` unquoted argument
   [#439](lunarmodules/Penlight#439)

#### 1.13.0 (2022-Jul-22)
 - fix: `xml.parse` returned nonsense when given a file name
   [#431](lunarmodules/Penlight#431)
 - feat: `app.require_here` now follows symlink'd main modules to their directory
   [#423](lunarmodules/Penlight#423)
 - fix: `pretty.write` invalid order function for sorting
   [#430](lunarmodules/Penlight#430)
 - fix: `compat.warn` raised write guard warning in OpenResty
   [#414](lunarmodules/Penlight#414)
 - feat: `utils.enum` now accepts hash tables, to enable better error handling
   [#413](lunarmodules/Penlight#413)
 - feat: `utils.kpairs` new iterator over all non-integer keys
   [#413](lunarmodules/Penlight#413)
 - fix: `warn` use rawget to not trigger strict-checkers
   [#437](lunarmodules/Penlight#437)
 - fix: `lapp` provides the file name when using the default argument
   [#427](lunarmodules/Penlight#427)
 - fix: `lapp` positional arguments now allow digits after the first character
   [#428](lunarmodules/Penlight#428)
 - fix: `path.isdir` windows root directories (including drive letter) were not considered valid
   [#436](lunarmodules/Penlight#436)
bungle added a commit that referenced this issue Aug 8, 2022
### Summary

#### 1.13.1 (2022-Jul-22)
 - fix: `warn` unquoted argument
   [#439](lunarmodules/Penlight#439)

#### 1.13.0 (2022-Jul-22)
 - fix: `xml.parse` returned nonsense when given a file name
   [#431](lunarmodules/Penlight#431)
 - feat: `app.require_here` now follows symlink'd main modules to their directory
   [#423](lunarmodules/Penlight#423)
 - fix: `pretty.write` invalid order function for sorting
   [#430](lunarmodules/Penlight#430)
 - fix: `compat.warn` raised write guard warning in OpenResty
   [#414](lunarmodules/Penlight#414)
 - feat: `utils.enum` now accepts hash tables, to enable better error handling
   [#413](lunarmodules/Penlight#413)
 - feat: `utils.kpairs` new iterator over all non-integer keys
   [#413](lunarmodules/Penlight#413)
 - fix: `warn` use rawget to not trigger strict-checkers
   [#437](lunarmodules/Penlight#437)
 - fix: `lapp` provides the file name when using the default argument
   [#427](lunarmodules/Penlight#427)
 - fix: `lapp` positional arguments now allow digits after the first character
   [#428](lunarmodules/Penlight#428)
 - fix: `path.isdir` windows root directories (including drive letter) were not considered valid
   [#436](lunarmodules/Penlight#436)
StarlightIbuki pushed a commit that referenced this issue Aug 9, 2022
### Summary

#### 1.13.1 (2022-Jul-22)
 - fix: `warn` unquoted argument
   [#439](lunarmodules/Penlight#439)

#### 1.13.0 (2022-Jul-22)
 - fix: `xml.parse` returned nonsense when given a file name
   [#431](lunarmodules/Penlight#431)
 - feat: `app.require_here` now follows symlink'd main modules to their directory
   [#423](lunarmodules/Penlight#423)
 - fix: `pretty.write` invalid order function for sorting
   [#430](lunarmodules/Penlight#430)
 - fix: `compat.warn` raised write guard warning in OpenResty
   [#414](lunarmodules/Penlight#414)
 - feat: `utils.enum` now accepts hash tables, to enable better error handling
   [#413](lunarmodules/Penlight#413)
 - feat: `utils.kpairs` new iterator over all non-integer keys
   [#413](lunarmodules/Penlight#413)
 - fix: `warn` use rawget to not trigger strict-checkers
   [#437](lunarmodules/Penlight#437)
 - fix: `lapp` provides the file name when using the default argument
   [#427](lunarmodules/Penlight#427)
 - fix: `lapp` positional arguments now allow digits after the first character
   [#428](lunarmodules/Penlight#428)
 - fix: `path.isdir` windows root directories (including drive letter) were not considered valid
   [#436](lunarmodules/Penlight#436)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea/new plugin [legacy] those issues belong to Kong Nation, since GitHub issues are reserved for bug reports. task/bug
Projects
None yet
Development

No branches or pull requests

3 participants