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 LogEntry severity and sourceLocation mappings in systemd_journald receiver. #502

Merged
merged 2 commits into from
Apr 1, 2022

Conversation

rafaelwestphal
Copy link
Contributor

@rafaelwestphal rafaelwestphal commented Mar 31, 2022

Transform keys from journald JSON to Cloud Logging JSON. This adds
severity and sourceLocation to the logging JSON.
Previously the json would have only the fields in the jsonPayload key, for example:

{
  "jsonPayload": {
    "MESSAGE": "error message here",
    "PRIORITY": "0"
    "CODE_FILE": "main.go"
    "CODE_FUNC": "main_func",
    "CODE_LINE": "100",
  },
  "resource": {},
  "timestamp": "2022-03-31T17:36:59.521960Z",
  "logName": "projects/sample-prj/logs/systemdreceiver",
  "receiveTimestamp": "2022-03-31T17:37:00.742917663Z"
}

Now, we populate the Cloud Logging JSON fields:

{
  "jsonPayload": {
    "MESSAGE": "error message here",
    "PRIORITY": "0",
    "CODE_FILE": "main.go"
    "CODE_FUNC": "main_func",
    "CODE_LINE": "100",
  },
  "severity": "EMERGENCY",
  "resource": {},
  "timestamp": "2022-03-31T17:36:59.521960Z",
  "logName": "projects/sample-prj/logs/systemdreceiver",
  "receiveTimestamp": "2022-03-31T17:37:00.742917663Z"
  "sourceLocation": {
       "file": "main.go"
       "function": "main_func"
       "line": "100"
    }
}

Fixes #256

Transform keys from journald JSON to Cloud Logging JSON. This adds
severity, message, and sourceLocation to the logging JSON.
Copy link
Contributor

@qingling128 qingling128 left a comment

Choose a reason for hiding this comment

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

LGTM

@qingling128 qingling128 changed the title Journald receiver now transform keys from JSON to Cloud Logging JSON Add LogEntry severity and sourceLocation mappings in systemd_journald receiver. Mar 31, 2022
@qingling128
Copy link
Contributor

Adjusted the title to be more release note friendly.

@rafaelwestphal rafaelwestphal merged commit ce41293 into master Apr 1, 2022
@rafaelwestphal rafaelwestphal deleted the westphalrafael-systemdreceiver-enhancements branch April 1, 2022 00:07
rafaelwestphal added a commit that referenced this pull request Apr 1, 2022
… receiver. (#502)

* Journald receiver now transform keys from JSON to Cloud Logging JSON

Transform keys from journald JSON to Cloud Logging JSON. This adds
severity, message, and sourceLocation to the logging JSON.

* Removing message change since it can break old pipelines
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.

systemd_journald: Transform keys from journald JSON to Cloud Logging JSON
2 participants