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 2022/03/11 07:36:41 UTC

[GitHub] [apisix] shuaijinchao opened a new pull request #6579: fix(prometheus): conflict between global rule and route configure

shuaijinchao opened a new pull request #6579:
URL: https://github.com/apache/apisix/pull/6579


   ### What this PR does / why we need it:
   FIX #6555
   
   ### Pre-submission checklist:
   
   <!--
   Please follow the PR manners:
   1. Use Draft if the PR is not ready to be reviewed
   2. Test is required for the feat/fix PR, unless you have a good reason
   3. Doc is required for the feat PR
   4. Use a new commit to resolve review instead of `push -f`
   5. If you need to resolve merge conflicts after the PR is reviewed, please merge master but do not rebase
   6. Use "request review" to notify the reviewer once you have resolved the review
   7. Only reviewer can click "Resolve conversation" to mark the reviewer's review resolved
   -->
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [x] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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



[GitHub] [apisix] shuaijinchao commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
shuaijinchao commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r824626975



##########
File path: apisix/plugins/prometheus.lua
##########
@@ -39,6 +39,7 @@ local _M = {
     name = plugin_name,
     log  = exporter.log,
     schema = schema,
+    run_policy = "prefer_route",

Review comment:
       > Does the `nginx-lua-prometheus` need update ?
   
   No, APISIX from 2.7 to master, `nginx-lua-prometheus` has only one version upgrade, and this upgrade of `nginx-lua-prometheus` is not related to the current issue.
   
   https://github.com/knyar/nginx-lua-prometheus/blob/master/CHANGELOG.md#020220127




-- 
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



[GitHub] [apisix] shuaijinchao commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
shuaijinchao commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r825440126



##########
File path: apisix/plugins/prometheus/exporter.lua
##########
@@ -171,6 +171,8 @@ function _M.log(conf, ctx)
 
     metrics.bandwidth:inc(vars.bytes_sent,
         gen_arr("egress", route_id, service_id, consumer_name, balancer_ip))
+
+    core.log.info("prometheus run report")

Review comment:
       this is not just for testing purposes. Currently, there is no log output when prometheus reports data. I think adding this log will also help developers watch it while developing and debugging.
   
   what do you think?




-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r825575693



##########
File path: t/plugin/prometheus3.t
##########
@@ -256,7 +256,12 @@ passed
 GET /opentracing
 --- response_body
 opentracing
---- grep_error_log eval
-qr/prometheus run \w+/
---- grep_error_log_out
-prometheus run report
+--- error_code: 200

Review comment:
       The error_code check here is redundant?

##########
File path: t/plugin/prometheus3.t
##########
@@ -256,7 +256,12 @@ passed
 GET /opentracing
 --- response_body
 opentracing
---- grep_error_log eval
-qr/prometheus run \w+/
---- grep_error_log_out
-prometheus run report
+--- error_code: 200
+
+
+
+=== TEST 7: fetch prometheus plugin at both global rule and route data
+--- request
+GET /apisix/prometheus/metrics
+--- response_body eval
+qr/apisix_http_status\{code="200",route="1",matched_uri="\/opentracing",matched_host="",service="",consumer="",node="127.0.0.1\"} \d+/

Review comment:
       It doesn't check the number this request is hit...




-- 
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



[GitHub] [apisix] zhendongcmss commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r824615692



##########
File path: apisix/plugins/prometheus.lua
##########
@@ -39,6 +39,7 @@ local _M = {
     name = plugin_name,
     log  = exporter.log,
     schema = schema,
+    run_policy = "prefer_route",

Review comment:
       Does the `nginx-lua-prometheus` need update ?




-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r825447390



##########
File path: apisix/plugins/prometheus/exporter.lua
##########
@@ -171,6 +171,8 @@ function _M.log(conf, ctx)
 
     metrics.bandwidth:inc(vars.bytes_sent,
         gen_arr("egress", route_id, service_id, consumer_name, balancer_ip))
+
+    core.log.info("prometheus run report")

Review comment:
       A hit will increase the metric: https://github.com/apache/apisix/blob/1ac7166e80fdd502cc6a8a60ef58f415d3c0e56c/apisix/plugins/prometheus/exporter.lua#L153
   
   There is no need to add another way.




-- 
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



[GitHub] [apisix] spacewander commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r825434273



##########
File path: apisix/plugins/prometheus/exporter.lua
##########
@@ -171,6 +171,8 @@ function _M.log(conf, ctx)
 
     metrics.bandwidth:inc(vars.bytes_sent,
         gen_arr("egress", route_id, service_id, consumer_name, balancer_ip))
+
+    core.log.info("prometheus run report")

Review comment:
       Can we check the result of prometheus instead of adding a new log just for testing?




-- 
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



[GitHub] [apisix] zhendongcmss commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r824618867



##########
File path: apisix/plugins/prometheus.lua
##########
@@ -39,6 +39,7 @@ local _M = {
     name = plugin_name,
     log  = exporter.log,
     schema = schema,
+    run_policy = "prefer_route",

Review comment:
       This fix like https://github.com/apache/apisix/pull/4589/files




-- 
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



[GitHub] [apisix] spacewander merged pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #6579:
URL: https://github.com/apache/apisix/pull/6579


   


-- 
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



[GitHub] [apisix] spacewander commented on pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
spacewander commented on pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#issuecomment-1066082148


   > The way do work for fixing the problem but my concern is that are there other plugins have the same problem? Shall we have a generic mechanism to handle this situation?
   
   This has been discussed before. The `run_policy` used in this PR is the solution to 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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] zhendongcmss commented on a change in pull request #6579: fix(prometheus): conflict between global rule and route configure

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on a change in pull request #6579:
URL: https://github.com/apache/apisix/pull/6579#discussion_r824618867



##########
File path: apisix/plugins/prometheus.lua
##########
@@ -39,6 +39,7 @@ local _M = {
     name = plugin_name,
     log  = exporter.log,
     schema = schema,
+    run_policy = "prefer_route",

Review comment:
       This fix like https://github.com/apache/apisix/pull/4589/files




-- 
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