Skip to content

Commit

Permalink
MB-51323: [BP] Ignore path when counting 4** http ...
Browse files Browse the repository at this point in the history
...requests

Otherwise it may lead to a huge number of time series created in
prometheus.

Simplest scenario:
while true; do curl "http://127.0.0.1:9000/$RANDOM" -v; done

Change-Id: I30452447d60f029ef9bb70df9789cea6b01d6c35
Reviewed-on: https://review.couchbase.org/c/ns_server/+/172311
Well-Formed: Restriction Checker
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Steve Watanabe <steve.watanabe@couchbase.com>
Tested-by: Timofey Barmin <timofey.barmin@couchbase.com>
  • Loading branch information
timofey-barmin committed Mar 16, 2022
1 parent 13aafb7 commit dea724f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/menelaus_util.erl
Expand Up @@ -251,13 +251,14 @@ count_web_hit(Req, Resp) ->
end,
Scheme = mochiweb_request:get(scheme, Req),
Method = mochiweb_request:get(method, Req),
Code = mochiweb_response:get(code, Resp),
Path = case string:lexemes(mochiweb_request:get(path, Req), "/") of
_ when Code >= 400, Code < 500 -> "/*";
[] -> "/";
["pools"] -> "/pools";
["pools", "default", P | _] -> "/pools/default/" ++ P ++ "/*";
[P | _] -> "/" ++ P ++ "/*"
end,
Code = mochiweb_response:get(code, Resp),
ResponseTime = menelaus_web:response_time_ms(Req),
ns_server_stats:notify_counter(
{<<"http_requests">>, [{scheme, Scheme}, {method, Method}, {path, Path},
Expand Down

0 comments on commit dea724f

Please sign in to comment.