Sindweller commented on PR #910:
URL:
https://github.com/apache/apisix-ingress-controller/pull/910#issuecomment-1222092455
Agreed with
> First, I think the apisix_ingress_controller_apisix_bad_status_codes is
not a good name since it counts all the requests including the good ones.
And this has been modified in #1012
---
But IMOP `apisix_ingress_controller_apisix_requests` contains both success
reqeusts and failed request. Here is a code slice of the exact increase of this
count.
```
if err := u.cluster.deleteResource(ctx, url, "upstream"); err != nil {
u.cluster.metricsCollector.IncrAPISIXRequest("upstream")
return err
}
u.cluster.metricsCollector.IncrAPISIXRequest("upstream")
return nil
```
and in `deleteResource` we consider status code not in [200, 204, 404] as
err:
```
if resp.StatusCode != http.StatusOK && resp.StatusCode !=
http.StatusNoContent && resp.StatusCode != http.StatusNotFound {
message := readBody(resp.Body, url)
if c.isFunctionDisabled(message) {
return ErrFunctionDisabled
}
err = multierr.Append(err, fmt.Errorf("unexpected status code
%d", resp.StatusCode))
err = multierr.Append(err, fmt.Errorf("error message: %s",
message))
if strings.Contains(message, "still using") {
return cache.ErrStillInUse
}
return err
}
```
Either success or failed request was send, this metric would increase.
So the "expr" now:
`"sum(apisix_ingress_controller_apisix_bad_status_codes{status_code =~
\"[4-5].*\"}) / sum(apisix_ingress_controller_apisix_requests)"` is correct, I
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]