Why does web_log_1m_successful count redirects as failure? and how to change it

I have a domain that redirects elsewhere (eg. imagine www.example.com redirecting to example.com). When a lot of people (or search engine indexers) hit the domain that redirects, I get a web_log_1m_redirects warning alert plus a web_log_1m_successful critical alert.

Why are redirects not counted as successful hits? They do not represent any error condition.

I understand how to disable the web_log_1m_redirects alert, but how do I modify the web_log_1m_successful counter to count redirects as successful and only treat actual errors (4xx and 5xx) as failures?

Hi, @Daniel. Sorry for the late reply.

That is how we count success/redirect/etc:

	code := w.line.respCode
	switch {
	case code >= 100 && code < 300, code == 304, code == 401:
		w.mx.ReqSuccess.Inc()
	case code >= 300 && code < 400:
		w.mx.ReqRedirect.Inc()
	case code >= 400 && code < 500:
		w.mx.ReqBad.Inc()
	case code >= 500 && code < 600:
		w.mx.ReqError.Inc()
	}

I guess making that configurable would solve the problem.

Thanks @ilyam8. I started using Sentry to track errors in my app, so I could just disable Netdata’s monitoring for this particular webapp, which worked around the issue.

Another solution is using responses_by_status_code_class for those alarms instead of requests_by_type.

		Dims: Dims{
			{ID: "resp_2xx", Name: "2xx", Algo: module.Incremental},
			{ID: "resp_5xx", Name: "5xx", Algo: module.Incremental},
			{ID: "resp_3xx", Name: "3xx", Algo: module.Incremental},
			{ID: "resp_4xx", Name: "4xx", Algo: module.Incremental},
			{ID: "resp_1xx", Name: "1xx", Algo: module.Incremental},

The lookup line would be like:

lookup: sum -1m unaligned of 1xx,2xx,3xx

But that requires overwriting all web_log alarms.