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

Change timestamp in elastic-agent-json.log ut UTC #26016

Merged

Conversation

michel-laterman
Copy link
Contributor

What does this PR do?

Change encoder to force UTC timestamps in RFC3339 for the json.log
entries.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

Logs

elastic-agent-8.0.0-SNAPSHOT-darwin-x86_64|⇒ sudo ./elastic-agent
2021-05-31T17:40:45.099-0700	INFO	cmd/run.go:133	Artifact has been built with security disabled. Elastic Agent will not verify signatures of the artifacts.
2021-05-31T17:40:45.100-0700	INFO	warn/warn.go:18	The Elastic Agent is currently in BETA and should not be used in production
2021-05-31T17:40:45.101-0700	INFO	application/application.go:68	Detecting execution mode
elastic-agent-8.0.0-SNAPSHOT-darwin-x86_64|⇒ sudo head data/elastic-agent-5bcdff/logs/elastic-agent-json.log-20210531174045
{"log.level":"info","@timestamp":"2021-06-01T00:40:45.099Z","log.origin":{"file.name":"cmd/run.go","file.line":133},"message":"Artifact has been built with security disabled. Elastic Agent will not verify signatures of the artifacts.","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2021-06-01T00:40:45.100Z","log.origin":{"file.name":"warn/warn.go","file.line":18},"message":"The Elastic Agent is currently in BETA and should not be used in production","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2021-06-01T00:40:45.101Z","log.origin":{"file.name":"application/application.go","file.line":68},"message":"Detecting execution mode","ecs.version":"1.6.0"}

Change encoder to force UTC timestamps in ISO-8601 for the json.log
entries.
@michel-laterman michel-laterman added cleanup v7.14.0 Team:Elastic-Agent Label for the Agent team backport-v7.14.0 Automated backport with mergify labels Jun 1, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 1, 2021
return ecszap.WrapCore(zapcore.NewCore(encoder, rotator, cfg.Level.ZapLevel())), nil
}

// utcTimestampEncode is a zapcore.TimeEncoder that formats time.Time in ISO-8601 in UTC.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

logp.JSONEncoderConfig uses zap's ISO8601 encoder; this function copies that pattern but forces the time into UTC

Copy link
Contributor

Choose a reason for hiding this comment

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

looks ok, i will test it a bit later

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #26016 opened

  • Start Time: 2021-06-01T00:42:52.752+0000

  • Duration: 85 min 1 sec

  • Commit: 5bcdff5

Test stats 🧪

Test Results
Failed 0
Passed 6908
Skipped 16
Total 6924

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 6908
Skipped 16
Total 6924

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

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

Tested ok

@michel-laterman michel-laterman merged commit c65305b into elastic:master Jun 4, 2021
@michel-laterman michel-laterman deleted the agent-timestamp-utc branch June 4, 2021 16:23
mergify bot pushed a commit that referenced this pull request Jun 4, 2021
Change encoder to force UTC timestamps in ISO-8601 for the json.log
entries.

(cherry picked from commit c65305b)
michel-laterman added a commit that referenced this pull request Jun 8, 2021
Change encoder to force UTC timestamps in ISO-8601 for the json.log
entries.

(cherry picked from commit c65305b)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.14.0 Automated backport with mergify cleanup Team:Elastic-Agent Label for the Agent team v7.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync up logger used in Fleet server with Agent/ Beats
3 participants