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/10/22 09:25:52 UTC

[GitHub] [apisix] tzssangglass opened a new pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

tzssangglass opened a new pull request #2497:
URL: https://github.com/apache/apisix/pull/2497


   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   Prometheus plugin `apisix_http_status` metric `route` tag Improve recognition.
   
   Originally, the `/apisix/prometheus/metrics` endpoint only showed the `id` of the `router`.
   However, if the route has `uris` or `hosts` parameters, the user does not know the number of times an element in `uris` or `hosts` has been matched, the collection of coarse granularity, and in Grafana to display the `id` of the `route` is not friendly enough.
   
   This PR adds two elements, `matched_uri` and `matched_host`, to the `apisix_http_status` property of the `/apisix/prometheus/metrics` endpoint to show in detail the elements that are matched in the `uris` or `hosts`.
   Note: I added the parameter `curr_req_matched_record` to the `api_ctx` to keep track of the `route` record for the current request match.
   
   The `apisix_http_status` will look like this
   
   ```
   apisix_http_status{code="200",route="",matched_uri="",matched_host="",service="localhost",node=""} 5
   apisix_http_status{code="200",route="1",matched_uri="/hello",matched_host="",service="",node=""} 6
   apisix_http_status{code="200",route="1",matched_uri="/hello",matched_host="",service="",node="127.0.0.1"} 20
   apisix_http_status{code="200",route="2",matched_uri="/hello1",matched_host="",service="1",node="127.0.0.1"} 6
   apisix_http_status{code="404",route="",matched_uri="",matched_host="",service="localhost",node=""} 6
   apisix_http_status{code="404",route="3",matched_uri="/hello3",matched_host="",service="",node="127.0.0.1"} 2
   ```
   
   <!--- If it fixes an open issue, please link to the issue here. -->
   fix #1574 
   
   ### Pre-submission checklist:
   
   * [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?
   


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



[GitHub] [apisix] tzssangglass commented on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   @membphis Do I need to update `prometheus.md`? 


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



[GitHub] [apisix] tzssangglass commented on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   ping @membphis 


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



[GitHub] [apisix] membphis commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
+    match_opts.matched = {}

Review comment:
       Can we reuse this Lua table?




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



[GitHub] [apisix] membphis commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
+    match_opts.matched = {}

Review comment:
       yes, waiting for your result




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



[GitHub] [apisix] membphis commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -131,7 +131,7 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
-    match_opts.matched = {}
+    match_opts.matched = core.tablepool.fetch("match_opts_matched", 0, 4)

Review comment:
       @tzssangglass can you fix this soon? then we can merge this PR ^_^




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



[GitHub] [apisix] tzssangglass commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
+    match_opts.matched = {}

Review comment:
       suspend merged, let me check the Grafana Dashboard




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



[GitHub] [apisix] tzssangglass edited a comment on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

Posted by GitBox <gi...@apache.org>.
tzssangglass edited a comment on pull request #2497:
URL: https://github.com/apache/apisix/pull/2497#issuecomment-717045543


   `match_opts_matched` ->  `matched_route_record`
   @membphis 


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



[GitHub] [apisix] tzssangglass commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
+    match_opts.matched = {}

Review comment:
       I find that this change will not be reflected in Grafana Dashboard, may be because of `apisix-grafana-dashboard`  hasn't been updated, but I don't know how to modify it yet.




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



[GitHub] [apisix] membphis commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -131,7 +131,7 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
-    match_opts.matched = {}
+    match_opts.matched = core.tablepool.fetch("match_opts_matched", 0, 4)

Review comment:
       `match_opts_matched` is not a good name.
   
   Need to add the word `route`.




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



[GitHub] [apisix] membphis commented on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   @tzssangglass many thx, merged already


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



[GitHub] [apisix] membphis merged pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   


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



[GitHub] [apisix] tzssangglass commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -131,7 +131,7 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
-    match_opts.matched = {}
+    match_opts.matched = core.tablepool.fetch("match_opts_matched", 0, 4)

Review comment:
       ok, let me think of a better name.




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



[GitHub] [apisix] tzssangglass commented on a change in pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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



##########
File path: apisix/http/router/radixtree_host_uri.lua
##########
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
     match_opts.remote_addr = api_ctx.var.remote_addr
     match_opts.vars = api_ctx.var
     match_opts.host = api_ctx.var.host
+    match_opts.matched = {}

Review comment:
       you mean using `tablepool`? I get, the `api_ctx` also use `tablepool`, let me try.




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



[GitHub] [apisix] tzssangglass commented on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   `match_opts_matched` ->  `matched_route_record`


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



[GitHub] [apisix] tzssangglass commented on pull request #2497: feature: prometheus plugin `apisix_http_status` metric `route` tag Im…

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


   @membphis pls take a look


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