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

Escape message when using JSON format for the logs #4004

Merged
merged 1 commit into from
Aug 19, 2019

Conversation

hush-hush
Copy link
Member

@hush-hush hush-hush commented Aug 12, 2019

What does this PR do?

Escape message when using JSON format for the logs

This fix broken JSON output like:

{"agent":"core","time":"2019-08-12 16:58:46 MDT","level":"ERROR","file":"pkg/collector/runner/runner.go","line":"298","func":"work","msg":"Error running check max: [{"message": "ERROR", "traceback": "Traceback (most recent call last):
  File \"/home/maxime/dev/go/src/github.com/DataDog/datadog-agent/venv/local/lib/python2.7/site-packages/datadog_checks/base/checks/base.py\", line 532, in run
    self.check(instance)
  File \"/home/maxime/dev/go/src/github.com/DataDog/datadog-agent/bin/agent/dist/max.py\", line 8, in check
    raise Exception(\"ERROR\")
Exception: ERROR
"}]"}

to:

{"agent":"core","time":"2019-08-12 17:04:25 MDT","level":"ERROR","file":"pkg/collector/runner/runner.go","line":"298","func":"work","msg":"Error running check max: [{\"message\": \"ERROR\", \"traceback\": \"Traceback (most recent call last):\\n  File \\\"/home/maxime/dev/go/src/github.com/DataDog/datadog-agent/venv/local/lib/python2.7/site-packages/datadog_checks/base/checks/base.py\\\", line 532, in run\\n    self.check(instance)\\n  File \\\"/home/maxime/dev/go/src/github.com/DataDog/datadog-agent/bin/agent/dist/max.py\\\", line 8, in check\\n    raise Exception(\\\"ERROR\\\")\\nException: ERROR\\n\"}]"}

@hush-hush hush-hush requested a review from a team as a code owner August 12, 2019 22:59
@hush-hush hush-hush force-pushed the maxime/escape-log-in-json branch from 23ade1b to 7c4a6d3 Compare August 12, 2019 23:01
@hush-hush hush-hush added the [deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead.. label Aug 12, 2019
@hush-hush hush-hush added this to the 6.14.0 milestone Aug 12, 2019
Copy link
Contributor

@albertvaka albertvaka left a comment

Choose a reason for hiding this comment

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

👍

@hush-hush hush-hush merged commit ddaea82 into master Aug 19, 2019
@hush-hush hush-hush deleted the maxime/escape-log-in-json branch August 19, 2019 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead..
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants