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/04/19 09:38:36 UTC
[GitHub] [incubator-apisix] OnlyPiglet opened a new issue #1474: bug:
global_rule prometheus ineffective
OnlyPiglet opened a new issue #1474: bug: global_rule prometheus ineffective
URL: https://github.com/apache/incubator-apisix/issues/1474
### Issue description
When I try to make a global_rule of prometheus,it's ineffrctive.
### Environment
* apisix version (cmd: `apisix version`): 1.1
* OS: Centos7
### Minimal test code / Steps to reproduce the issue
1. make a global_rule of prometheus,
### What's the actual result? (including assertion message & call stack if applicable)
the /apisix/prometheus/metrics can't get the apisix_http_latency_bucket and apisix_http_status
### What's the expected result?the /apisix/prometheus/metrics should get the apisix_http_latency_bucket and apisix_http_status
Reason
apisix.lua the function http_log_phase() didn't merge the global_rules.
function _M.http_log_phase()
local api_ctx = run_plugin("log")
if api_ctx then
if api_ctx.uri_parse_param then
core.tablepool.release("uri_parse_param", api_ctx.uri_parse_param)
end
core.ctx.release_vars(api_ctx)
if api_ctx.plugins then
core.tablepool.release("plugins", api_ctx.plugins)
end
core.tablepool.release("api_ctx", api_ctx)
end
end
----------------------------------------------------------------
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] OnlyPiglet commented on issue #1474: bug:
global_rule prometheus ineffective
Posted by GitBox <gi...@apache.org>.
OnlyPiglet commented on issue #1474: bug: global_rule prometheus ineffective
URL: https://github.com/apache/incubator-apisix/issues/1474#issuecomment-616088114
I fixed it temporarily by inserting thie part of code
```lua
local ngx_ctx = ngx.ctx
local api_ctx = ngx_ctx.api_ctx
if router.global_rules and router.global_rules.values
and #router.global_rules.values > 0 then
local plugins = core.tablepool.fetch("plugins", 32, 0)
for _, global_rule in ipairs(router.global_rules.values) do
api_ctx.conf_type = "global_rule"
api_ctx.conf_version = global_rule.modifiedIndex
api_ctx.conf_id = global_rule.value.id
core.table.clear(plugins)
api_ctx.plugins = plugin.filter(global_rule, plugins)
run_plugin("log", plugins, api_ctx)
run_plugin("access", plugins, api_ctx)
end
core.tablepool.release("plugins", plugins)
api_ctx.plugins = nil
api_ctx.conf_type = nil
api_ctx.conf_version = nil
api_ctx.conf_id = nil
end
```
----------------------------------------------------------------
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] OnlyPiglet edited a comment on issue #1474: bug:
global_rule prometheus ineffective
Posted by GitBox <gi...@apache.org>.
OnlyPiglet edited a comment on issue #1474: bug: global_rule prometheus ineffective
URL: https://github.com/apache/incubator-apisix/issues/1474#issuecomment-616088114
I fixed it temporarily by inserting thie part of code
```lua
local ngx_ctx = ngx.ctx
local api_ctx = ngx_ctx.api_ctx
if router.global_rules and router.global_rules.values
and #router.global_rules.values > 0 then
local plugins = core.tablepool.fetch("plugins", 32, 0)
for _, global_rule in ipairs(router.global_rules.values) do
api_ctx.conf_type = "global_rule"
api_ctx.conf_version = global_rule.modifiedIndex
api_ctx.conf_id = global_rule.value.id
core.table.clear(plugins)
api_ctx.plugins = plugin.filter(global_rule, plugins)
run_plugin("log", plugins, api_ctx)
end
core.tablepool.release("plugins", plugins)
api_ctx.plugins = nil
api_ctx.conf_type = nil
api_ctx.conf_version = nil
api_ctx.conf_id = nil
end
```
----------------------------------------------------------------
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 #1474: bug: global_rule prometheus ineffective
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1474:
URL: https://github.com/apache/incubator-apisix/issues/1474#issuecomment-616263860
We have fixed this bug in `master` branch. please make a try with 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org