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

Allow to set log_format's "escape" parameter #1513

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Conversation

smortex
Copy link
Member

@smortex smortex commented Aug 19, 2022

Pull Request (PR) description

NGINX can output logs in JSONL format. This requires to set the escape
parameter to NGINX log_format, which the module does not currently
support.

This change is backwards-incompatible

Most users will not be affected, but if you customized the escape parameter with a log_format containing closing and opening quotes in the form "escape=foo' 'actual_format", an update is required. e.g.:

diff --git a/site-modules/profile/manifests/nginx.pp b/site-modules/profile/manifests/nginx.pp
index 1fa15f7..3d5192f 100644
--- a/site-modules/profile/manifests/nginx.pp
+++ b/site-modules/profile/manifests/nginx.pp
@@ -109,7 +108,10 @@ class profile::nginx (
     dynamic_modules           => $dynamic_modules,
     log_mode                  => '0755',
     log_format                => {
-      json_combined => "escape=json' '{${json_log.map |$key, $value| { "\"${key}\":${value}" }.join(',')}}",
+      json_combined => {
+        escape => 'json',
+        format => "{${json_log.map |$key, $value| { "\"${key}\":${value}" }.join(',')}}",
+      },
     },
     http_format_log           => 'json_combined buffer=10m flush=5m',
 

This Pull Request (PR) fixes the following issues

n/a

@smortex smortex added the enhancement New feature or request label Aug 19, 2022
NGINX can output logs in JSONL format.  This requires to set the escape
parameter to NGINX log_format, which the module does not currently
support.

This commit describe the desired interface.
@smortex smortex force-pushed the log_format-escape-json branch 3 times, most recently from 2f6e201 to 530337d Compare August 19, 2022 18:18
@smortex smortex marked this pull request as ready for review August 19, 2022 18:59
templates/conf.d/nginx.conf.erb Outdated Show resolved Hide resolved
While here, rely on #inspect to generate espaped quoted string.
@smortex smortex merged commit 113f3d2 into master Aug 24, 2022
@smortex smortex deleted the log_format-escape-json branch August 24, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants