You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "ChuanFF (via GitHub)" <gi...@apache.org> on 2023/12/12 11:29:12 UTC
[I] bug: Prometheus plugin issues with removed upstream [apisix]
ChuanFF opened a new issue, #10636:
URL: https://github.com/apache/apisix/issues/10636
### Current Behavior
When the upstream is updated/deleted, the upstream health status data of the Prometheus plug-in does not remove the corresponding upstream node.

### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
1. create uptream & route
2. request prometheus uri
3. remove upstream
4. req prometheus uri , will found upstream info still here
### Environment
- APISIX version (run `apisix version`): 2.13.1
- Operating system (run `uname -a`):Linux pekshcsitd54867 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):nginx version: openresty/1.21.4.1
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):{"boot_time":1702379993,"etcd_version":"3.5.0","id":"aa6db183-43e6-4f8d-a86d-6ed48e76dbaa","hostname":"pekshcsitd54867","version":"2.13.1"}
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
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-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Prometheus plugin issues with removed upstream [apisix]
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #10636:
URL: https://github.com/apache/apisix/issues/10636#issuecomment-1853107233
pls assgin to me
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Prometheus plugin issues with removed upstream [apisix]
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #10636:
URL: https://github.com/apache/apisix/issues/10636#issuecomment-1855100204
a new test case for question 2 has been reproduced

```lua
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
use t::APISIX 'no_plan';
no_root_location();
repeat_each(1);
log_level('info');
no_root_location();
no_shuffle();
add_block_preprocessor(sub {
my ($block) = @_;
if (!$block->http_config) {
my $http_config = <<'_EOC_';
server {
listen 8765;
location /ping {
return 200 '8765';
}
location /healthz {
return 200 'ok';
}
}
server {
listen 8766;
location /ping {
return 200 '8766';
}
location /healthz {
return 500;
}
}
server {
listen 8767;
location /ping {
return 200 '8767';
}
location /healthz {
return 200 'ok';
}
}
_EOC_
$block->set_value("http_config", $http_config);
}
if (!$block->request) {
$block->set_value("request", "GET /t");
}
});
run_tests;
__DATA__
=== TEST 1: https health check (two health nodes)
--- config
location /t {
content_by_lua_block {
local function find_apisix_upstream_status(multiLineStr)
local pattern = "(apisix_upstream_status{.-)$"
local result = {}
for line in multiLineStr:gmatch("[^\r\n]+") do
local match = line:match(pattern)
if match then
table.insert(result, match)
end
end
return result
end
local t = require("lib.test_admin")
local core = require("apisix.core")
local data = {
uri = "/ping",
upstream = {
nodes = {
["127.0.0.1:8765"] = 1,
["127.0.0.1:8766"] = 1,
["127.0.0.1:8767"] = 1
},
retries = 2,
checks = {
active = {
http_path = "/healthz",
healthy = {
interval = 1,
successes = 1
},
unhealthy = {
interval = 1,
http_failures = 1
},
}
}
}
}
local code, body = t.test('/apisix/admin/routes/1',
ngx.HTTP_PUT, core.json.encode(data))
if code >= 300 then
ngx.status = code
ngx.say(body)
return
end
local http = require("resty.http")
local httpc = http.new()
local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/ping"
local _, _ = httpc:request_uri(uri, {method = "GET", keepalive = false})
ngx.sleep(3)
local healthcheck_uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/v1/healthcheck/routes/1"
local httpc = http.new()
local route_res, _ = httpc:request_uri(healthcheck_uri, {method = "GET", keepalive = false})
local route_json_data = core.json.decode(route_res.body)
assert(#route_json_data.nodes == 3)
--- get the metrics
local metric_uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/apisix/prometheus/metrics"
local metric_res, _ = httpc:request_uri(metric_uri, {method = "GET"})
local apisix_upstream_status_body = find_apisix_upstream_status(metric_res.body)
for _, match in ipairs(apisix_upstream_status_body) do
ngx.say("before: " .. match)
end
ngx.say("will remove a node for test metric")
local new_data = {
uri = "/ping",
upstream = {
nodes = {
["127.0.0.1:8765"] = 1,
["127.0.0.1:8766"] = 1
},
retries = 2,
checks = {
active = {
http_path = "/healthz",
healthy = {
interval = 1,
successes = 1
},
unhealthy = {
interval = 1,
http_failures = 1
},
}
}
}
}
local code, body = t.test('/apisix/admin/routes/1',
ngx.HTTP_PUT, core.json.encode(new_data))
if code >= 300 then
ngx.status = code
ngx.say(body)
return
end
ngx.sleep(1.5)
--- get the metrics again
local metric_uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/apisix/prometheus/metrics"
local metric_res, _ = httpc:request_uri(metric_uri, {method = "GET"})
local apisix_upstream_status_body = find_apisix_upstream_status(metric_res.body)
for _, match in ipairs(apisix_upstream_status_body) do
ngx.say("after: " .. match)
end
}
}
--- request
GET /t
--- response_body
before: apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8765"} 1
before: apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8766"} 0
before: apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8767"} 1
will remove a node for test metric
after: apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8765"} 1
after: apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8766"} 0
```
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: health checker target leak [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 closed issue #10636: bug: health checker target leak
URL: https://github.com/apache/apisix/issues/10636
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Prometheus plugin issues with removed upstream [apisix]
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #10636:
URL: https://github.com/apache/apisix/issues/10636#issuecomment-1859689044
duplicated: https://github.com/apache/apisix/issues/10500
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: health checker target leak [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #10636:
URL: https://github.com/apache/apisix/issues/10636#issuecomment-1996885702
The PR that fixed this bug has been reverted as it significantly increased CPU load. Another way to fix this bug would be to configure metrics expiry: https://github.com/apache/apisix/blob/master/conf/config-default.yaml#L608
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org