'locust stat for single api call

in the locust documentation is specified how to get aggregated stats. However both the csv you can generate and in the web UI you have stats divided per api call.

My use case: Just like in the documentation example I linked above, but I want to exit with status 1 when a single API call has a fail ration above 0.01. I do not want to fail when environment.stats.total.fail_ratio > 0.01 but when environment.stats.my_single_api_call.fail_ratio > 0.01

Moreover since I can see I have a lot of single requests in the form

/api/application/v1/action/param1/report
/api/application/v1/action/param2/report
/api/application/v1/action/param3/report

it would be great if I could loop the request's and aggregate the same one that have different parameters



Solution 1:[1]

You can get stats by request name+method by using the RequestStats.get-method, e.g.

environment.stats.get("/api/application/v1/action/param1/report", "GET")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cyberwiz