diff --git a/assets/nginx.mtail b/assets/nginx.mtail index 41a6090..492d137 100644 --- a/assets/nginx.mtail +++ b/assets/nginx.mtail @@ -1,7 +1,11 @@ counter nginx_requests_total by vhost, method, code, cache_status -counter nginx_request_duration_milliseconds_sum by le, vhost, method, code counter nginx_response_size_bytes_sum by vhost, method, code, cache_status +counter nginx_request_duration_milliseconds_bucket by le, vhost, method, code +counter nginx_request_duration_milliseconds_sum by vhost, method, code +counter nginx_request_duration_milliseconds_count by vhost, method, code + + # log_format mtail '$server_name $remote_addr - $remote_user [$time_local] ' # '"$request" $status $bytes_sent $request_time' # '"$http_referer" "$http_user_agent" "$content_type" "$upstream_cache_status"'; @@ -22,44 +26,68 @@ counter nginx_response_size_bytes_sum by vhost, method, code, cache_status /"(?P[[:print:]]+)?"/ + /$/ { nginx_requests_total[$vhost][tolower($request_method)][$status][tolower($upstream_cache_status)]++ + nginx_response_size_bytes_sum[$vhost][tolower($request_method)][$status][tolower($upstream_cache_status)] += $bytes_sent + nginx_request_duration_milliseconds_count[$vhost][tolower($request_method)][$status][tolower($upstream_cache_status)]++ + nginx_request_duration_milliseconds_sum[$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds < 100 + $request_seconds * 1000 + $request_milliseconds < 100 { - nginx_request_duration_milliseconds_sum["100"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["100"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["100"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 200 { - nginx_request_duration_milliseconds_sum["200"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["200"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["200"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 300 { - nginx_request_duration_milliseconds_sum["300"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["300"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["300"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 500 { - nginx_request_duration_milliseconds_sum["500"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["500"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["500"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 800 { - nginx_request_duration_milliseconds_sum["800"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["800"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["800"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 1300 { - nginx_request_duration_milliseconds_sum["1300"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["1300"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["1300"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 2100 { - nginx_request_duration_milliseconds_sum["2100"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["2100"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["2100"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 3400 { - nginx_request_duration_milliseconds_sum["3400"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["3400"][$vhost][tolower($request_method)][$status] ++ + } else { + nginx_request_duration_milliseconds_bucket["3400"][$vhost][tolower($request_method)][$status] += 0 } $request_seconds * 1000 + $request_milliseconds < 5500 { - nginx_request_duration_milliseconds_sum["5500"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds + nginx_request_duration_milliseconds_bucket["5500"][$vhost][tolower($request_method)][$status]++ + } else { + nginx_request_duration_milliseconds_bucket["5500"][$vhost][tolower($request_method)][$status] += 0 } + nginx_request_duration_milliseconds_bucket["+Inf"][$vhost][tolower($request_method)][$status]++ + nginx_request_duration_milliseconds_sum["+Inf"][$vhost][tolower($request_method)][$status] += $request_seconds * 1000 + $request_milliseconds }