apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug:prometheus metrics 500 Internal Server Error

Open zh417233956 opened this issue 6 years ago • 6 comments

Issue description

访问:http://192.168.5.139/apisix/prometheus/metrics,出现:metrics 500 Internal Server Error apisix reload 以后正常,几分钟以后,仍然出现:metrics 500 Internal Server Error

Environment

  • apisix version (cmd: apisix version):1.5
  • OS:CentOS 7.6

Minimal test code / Steps to reproduce the issue

  1. http://192.168.5.139/apisix/prometheus/metrics

What's the actual result? (including assertion message & call stack if applicable)

metrics 500 Internal Server Error error.log: 2020/10/12 12:21:09 [error] 31448#31448: *217543 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/plugins/prometheus/exporter.lua:181: attempt to compare number with string stack traceback: coroutine 0: /usr/local/apisix/apisix/plugins/prometheus/exporter.lua: in function 'set_modify_index' /usr/local/apisix/apisix/plugins/prometheus/exporter.lua:233: in function 'etcd_modify_index' /usr/local/apisix/apisix/plugins/prometheus/exporter.lua:262: in function 'handler' /usr/local/apisix/apisix/plugin.lua:209: in function 'handler' /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:739: in function 'dispatch' /usr/local/apisix/apisix/http/router/radixtree_uri.lua:110: in function 'match' /usr/local/apisix/apisix/init.lua:336: in function 'http_access_phase' access_by_lua(nginx.conf:179):2: in main chunk, client: 192.168.6.88, server: , request: "GET /apisix/prometheus/metrics HTTP/1.1", host: "192.168.5.139:80"

What's the expected result?

zh417233956 avatar Oct 12 '20 04:10 zh417233956

@idbeta Please take a look first, to check if this issue occurred.

juzhiyuan avatar Oct 12 '20 05:10 juzhiyuan

@zh417233956 This doesn’t happen in my environment(centos7.6,apisix1.5), is the problem in your environment happen immediately or after a while, can you provide more information? like the setting of Prometheus plugin etc.

idbeta avatar Oct 12 '20 07:10 idbeta

this bug should have been fixed in master branch, you can make a try with the latest version.

https://github.com/apache/apisix/blob/master/apisix/plugins/prometheus/exporter.lua#L197

membphis avatar Oct 12 '20 09:10 membphis

@membphis Can you tell me what is the triggering condition of this bug?

idbeta avatar Oct 12 '20 09:10 idbeta

@membphis Can you tell me what is the triggering condition of this bug?

The item.modifiedIndex maybe updated in here:

https://github.com/apache/apisix/blob/v1.5/apisix/init.lua#L251

It has changed to string object.

So we need to fetch the original value from modifiedIndex_org.

membphis avatar Oct 12 '20 10:10 membphis

I think we can close this issue. @zh417233956 if you still have a problem, please feel free to reopen this issue

membphis avatar Oct 15 '20 15:10 membphis