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


   ### 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. -->
   https://github.com/apache/apisix/issues/1574
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   * [ ] 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:
[email protected]


Reply via email to