Reputation: 345
Need a little bit of help or advice here. I guess there is no direct way to calculate the success/failure percentage in GCP for the log based metric so I am trying to use MQL for the first time. I have gone through the documentation here
Basically I have a log based metric for my API which I can filter using HTTP Status Code
. This field can contain values like 2XX
and 5XX
. How do i calculate the failure percentage using this. I am trying to do something like (Total number of 5XX errors divided by Total requests) * 100.
I have done a bit of query but I am stuck here. If someone can guide me that would be very helpful. Many Thanks.
fetch l7_lb_rule
| metric logging.googleapis.com/user/my_apis
| { t_0:
filter (metric.URL
=~ 'https://example.com/myapi/services/myapi' && metric.STATUS='200')
| align
Upvotes: 0
Views: 1105
Reputation: 1527
You could use compute ratios to display the ratio of requests that return HTTP 500 responses to the total number of requests; that is, the request-failure ratio.
Upvotes: 1