Skip to content
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

Add option in the configuration configmap to enable remote logging #2145

Merged
merged 1 commit into from
Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,13 @@ type Configuration struct {
// http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_status
// Default: 503
LimitReqStatusCode int `json:"limit-req-status-code"`

// EnableSyslog enables the configuration for remote logging in NGINX
EnableSyslog bool `json:"enable-syslog"`
// SyslogHost FQDN or IP address where the logs should be sent
SyslogHost string `json:"syslog-host"`
// SyslogPort port
SyslogPort int `json:"syslog-port",omitempty`
}

// NewDefault returns the default nginx configuration
Expand Down Expand Up @@ -569,6 +576,7 @@ func NewDefault() Configuration {
JaegerSamplerType: "const",
JaegerSamplerParam: "1",
LimitReqStatusCode: 503,
SyslogPort: 514,
}

if glog.V(5) {
Expand Down
9 changes: 9 additions & 0 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,18 @@ http {
{{ if $cfg.DisableAccessLog }}
access_log off;
{{ else }}
{{ if $cfg.EnableSyslog }}
access_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} upstreaminfo if=$loggable;
{{ else }}
access_log {{ $cfg.AccessLogPath }} upstreaminfo if=$loggable;
{{ end }}
{{ end }}

{{ if $cfg.EnableSyslog }}
error_log syslog:server={{ $cfg.SyslogHost }}:{{ $cfg.SyslogPort }} {{ $cfg.ErrorLogLevel }};
{{ else }}
error_log {{ $cfg.ErrorLogPath }} {{ $cfg.ErrorLogLevel }};
{{ end }}

{{ buildResolvers $cfg.Resolver $cfg.DisableIpv6DNS }}

Expand Down