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

vdk-logging-json: Escape newlines in log messages #121

Merged
merged 2 commits into from Aug 24, 2021

Conversation

gageorgiev
Copy link
Contributor

@gageorgiev gageorgiev commented Aug 23, 2021

The message in logs formatted by the vdk-logging-json now
have any newline characters replaced by 4 spaces. This change
is made due to how logs are currently parsed by separating
at newline characters.

Testing done: local, pipelines
Before installing plugin:

2021-08-23 10:29:26,908=1629703767[VDK] example-process-in-star-schema [DEBUG] taurus.vdk.builtin_plugins.con    managed_cursor.py:29   execute         [OpId:1629703766-571a7d-67d79b]- Executing query:
-- job_name: example-process-in-star-schema
-- op_id: 1629703766
CREATE VIEW IF NOT EXISTS super_collider.vw_gageorgiev_dim_users AS
SELECT id, name, username, email FROM history_staging.sc_code_samples__users

After installing plugin:

{"@timestamp":"2021-08-23T10:26:39.355Z","created":"1629703599.355760","jobname":"example-process-in-star-schema","level":"DEBUG","modulename":"taurus.vdk.builtin_plugins.connection.impl.wrapped_connection","filename":"managed_cursor.py","lineno":"29","funcname":"execute","attemptid":"1629703599-8dcccb-def749","message":"Executing query:    -- job_name: example-process-in-star-schema    -- op_id: 1629703599    CREATE VIEW IF NOT EXISTS super_collider.vw_gageorgiev_dim_users AS    SELECT id, name, username, email FROM history_staging.sc_code_samples__users    "}

Signed-off-by: gageorgiev gageorgiev@vmware.com

@gageorgiev gageorgiev force-pushed the person/gageorgiev/replace-newlines-in-kibana-logs branch from dc794e3 to f702746 Compare August 23, 2021 07:25
@antoniivanov
Copy link
Collaborator

Is this the recommended way to handle new lines with JSON parser? That would make multi-line logs harder to consume. Imagine 50 line stack trace on a single line. There should be a way to escape new line but for Kibana/log insight to visualize it.

@antoniivanov
Copy link
Collaborator

antoniivanov commented Aug 23, 2021

vdk-core: Replace newlines ...

The component name is the plugin name :

vdk-logging-json: Replace newlines ..

@gageorgiev gageorgiev force-pushed the person/gageorgiev/replace-newlines-in-kibana-logs branch from f702746 to 5280d32 Compare August 23, 2021 10:08
@gageorgiev gageorgiev changed the title vdk-core: Replace newlines in log messages processed by vdk-logging-json vdk-logging-json: Escape newlines in log messages Aug 23, 2021
@gageorgiev
Copy link
Contributor Author

gageorgiev commented Aug 23, 2021

Is this the recommended way to handle new lines with JSON parser? That would make multi-line logs harder to consume. Imagine 50 line stack trace on a single line. There should be a way to escape new line but for Kibana/log insight to visualize it.

Dug around a bit and it seems like the recommended way is to escape the backwards slash, i.e. replace \n with \\n. Not sure exactly how that'll get parsed and then visualized in the end, but I'm willing to experiment.

@antoniivanov
Copy link
Collaborator

Dug around a bit and it seems like the recommended way is to escape the backwards slash, i.e. replace \n with \n. Not sure exactly how that'll get parsed and then visualized in the end, but I'm willing to experiment.

Can you please add link as a comment in the code to this recommendation.

We should consider installing and configuring either locally (minikube) or in our CICD environment to use fluentd. I did install it now (it's easy with helm install) but have no idea how to configure it in any meaningful way to test something .

@gageorgiev gageorgiev force-pushed the person/gageorgiev/replace-newlines-in-kibana-logs branch from 5280d32 to b828044 Compare August 24, 2021 09:24
…ogging-json

The message in logs formatted by the vdk-logging-json now
have any newline characters replaced by 4 spaces. This change
is made due to how logs are currently parsed by separating
at newline characters.

Signed-off-by: gageorgiev <gageorgiev@vmware.com>
@gageorgiev gageorgiev force-pushed the person/gageorgiev/replace-newlines-in-kibana-logs branch from b828044 to 7c83098 Compare August 24, 2021 09:24
@gageorgiev gageorgiev enabled auto-merge (squash) August 24, 2021 12:58
@gageorgiev gageorgiev merged commit d7da18f into main Aug 24, 2021
@gageorgiev gageorgiev deleted the person/gageorgiev/replace-newlines-in-kibana-logs branch August 24, 2021 13:01
kostoww pushed a commit that referenced this pull request Aug 29, 2021
…ogging-json (#121)

The message in logs formatted by the vdk-logging-json now
have any newline characters escaped. This change
is made due to how logs are currently parsed by separating
at newline characters.

Signed-off-by: gageorgiev <gageorgiev@vmware.com>
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.

None yet

3 participants