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 ability to prefix log lines with a.. prefix. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonphilpott
Copy link

No description provided.

@@ -57,7 +58,7 @@ def log_as_json(payload, as_logstash_event: false)
payload.to_json
end

logger << json_payload + $INPUT_RECORD_SEPARATOR
logger << (prefix.nil? ? "" : prefix) + json_payload + $INPUT_RECORD_SEPARATOR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix.to_s will work here since nil.to_s #=> "".

Copy link

@film42 film42 Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might actually be a bit problematic since the expectation is that the output is a pure json blob without any formatting or parsing required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea we were discussing was that prefixing the blob with a prefix would allow us to positively identify logstasher output in a stdout stream without having to fully parse the json

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break logstash filters that try to parse a json payload?

    filter {
      json {
        source => "message"
      }
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if someone defines a prefix then the logstash pipeline will extract the json string after the prefix to a field and then json parse on that new field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants