bug:prometheus metrics 500 Internal Server Error
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
- 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?
@idbeta Please take a look first, to check if this issue occurred.
@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.
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 Can you tell me what is the triggering condition of this bug?
@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.
I think we can close this issue. @zh417233956 if you still have a problem, please feel free to reopen this issue