Skip to content

Commit cce1102

Browse files
committed
fix: The condition ~= "/health" ensures that the subsequent code inside the if block will not be executed for requests to the "/health" endpoint, which is typically used for health checks.
1 parent 56507a3 commit cce1102

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

prometheus.conf

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ init_worker_by_lua_block {
1616
metric_connections = prometheus:gauge("nginx_http_connections","Number of HTTP connections", {"state"})
1717
}
1818
log_by_lua_block {
19-
metric_requests:inc(1, {ngx.var.server_name, ngx.var.status, ngx.var.request_method, ngx.var.cache_status})
20-
metric_latency:observe(tonumber(ngx.var.request_time),{ngx.var.server_name})
19+
if ngx.var.request_uri ~= "/health" then
20+
metric_requests:inc(1, {ngx.var.server_name, ngx.var.status, ngx.var.request_method, ngx.var.cache_status})
21+
metric_latency:observe(tonumber(ngx.var.request_time),{ngx.var.server_name})
22+
end
2123
}
2224
header_filter_by_lua_block {
2325
ngx.header["server"] = nil

0 commit comments

Comments
 (0)