-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to disable NGINX metrics #3512
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,12 +78,14 @@ http { | |
balancer = res | ||
end | ||
|
||
{{ if $all.EnableMetrics }} | ||
ok, res = pcall(require, "monitor") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
monitor = res | ||
end | ||
{{ end }} | ||
|
||
{{ if $all.DynamicCertificatesEnabled }} | ||
ok, res = pcall(require, "certificate") | ||
|
@@ -97,7 +99,9 @@ http { | |
|
||
init_worker_by_lua_block { | ||
balancer.init_worker() | ||
{{ if $all.EnableMetrics }} | ||
monitor.init_worker() | ||
{{ end }} | ||
} | ||
|
||
{{/* Enable the real_ip module only if we use either X-Forwarded headers or Proxy Protocol. */}} | ||
|
@@ -576,7 +580,7 @@ http { | |
{{ $cfg.ServerSnippet }} | ||
{{ end }} | ||
|
||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders $cfg.CustomHTTPErrors) }} | ||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders $cfg.CustomHTTPErrors $all.EnableMetrics) }} | ||
} | ||
## end server {{ $server.Hostname }} | ||
|
||
|
@@ -679,7 +683,7 @@ http { | |
proxy_pass http://upstream_balancer; | ||
} | ||
|
||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders $cfg.CustomHTTPErrors) }} | ||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders $cfg.CustomHTTPErrors $all.EnableMetrics) }} | ||
} | ||
} | ||
|
||
|
@@ -800,6 +804,7 @@ stream { | |
{{/* definition of templates to avoid repetitions */}} | ||
{{ define "CUSTOM_ERRORS" }} | ||
{{ $proxySetHeaders := .ProxySetHeaders }} | ||
{{ $enableMetrics := .EnableMetrics }} | ||
{{ range $errCode := .ErrorCodes }} | ||
location @custom_{{ $errCode }} { | ||
internal; | ||
|
@@ -821,7 +826,9 @@ stream { | |
|
||
proxy_pass http://upstream_balancer; | ||
log_by_lua_block { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cloudn't the whole log_by_lua_block be deactivated here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could. But it makes customizing Nginx config template harder. For example in my use case we call custom Lua module in |
||
{{ if $enableMetrics }} | ||
monitor.call() | ||
{{ end }} | ||
} | ||
} | ||
{{ end }} | ||
|
@@ -922,7 +929,7 @@ stream { | |
{{ $server.ServerSnippet }} | ||
{{ end }} | ||
|
||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders (collectCustomErrorsPerServer $server)) }} | ||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders (collectCustomErrorsPerServer $server) $all.EnableMetrics) }} | ||
|
||
{{ $enforceRegex := enforceRegexModifier $server.Locations }} | ||
{{ range $location := $server.Locations }} | ||
|
@@ -1087,7 +1094,9 @@ stream { | |
waf:exec() | ||
{{ end }} | ||
balancer.log() | ||
{{ if $all.EnableMetrics }} | ||
monitor.call() | ||
{{ end }} | ||
} | ||
|
||
{{ if (and (not (empty $server.SSLCert.PemFileName)) $all.Cfg.HSTS) }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
things in this file weren't being used anywhere before right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct