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

JSON Log format missing milliseconds #545

Closed
dfredell opened this issue Jan 29, 2018 · 5 comments
Closed

JSON Log format missing milliseconds #545

dfredell opened this issue Jan 29, 2018 · 5 comments

Comments

@dfredell
Copy link

  • what is happening and what you expect to see
    When using the logging-format of "json" the time field doesn't include milliseconds.
    Example:
{
"job":"myjob",
"level":"info",
"msg":"Handle [org.skife.jdbi.v2.BasicHandle@37d92cac] released",
"pid":52704,
"time":"2018-01-29T14:06:40Z"
}

I expect the log to look like the one in the JSON logging example https://github.com/joyent/containerpilot/blob/master/docs/30-configuration/38-logging.md it has a ms in the time "time":"2014-03-10 19:57:38.562527896 -0400 EDT"

  • the output of containerpilot -version
    Version: 3.6.2 GitHash: c73f47f
  • the ContainerPilot configuration you're using
{
  "consul": "localhost:8500",
  "logging": {
    "level": "INFO",
    "format": "json",
    "output": "stdout"
  },"jobs":[ {
      "name": "myjob",
      "port": 8080
........
  }]
}

I have narrowed it down to containerpilot taking the default format https://github.com/sirupsen/logrus/blob/d682213848ed68c0a260ca37d6dd5ace8423f5ba/formatter.go#L5 We can override the format easily at https://github.com/joyent/containerpilot/blob/7208e025644e9d9b0ca06d26ee97a4c612af7788/config/logger/logging.go#L60 with

	case "json":
		formatter = &logrus.JSONFormatter{
			TimestampFormat: time.RFC3339Nano,
			}
@dfredell dfredell changed the title JSON Format missing milliseconds JSON Log format missing milliseconds Jan 30, 2018
@jwreagor
Copy link
Contributor

jwreagor commented Feb 2, 2018

I really appreciate the feedback here. This issue seemed to slip by most users including myself. 😅

And while I strongly agree with the ease of the solution... I can imagine that this change will break some log parsing that ContainerPilot users might rely on.

For everyone following along this proposal is to change our timestamp...

  • From 2018-02-02T13:23:22-05:00
  • To 2018-02-02T13:23:48.092392961-05:00

I'd like to leave this issue open for a little longer (max 2 weeks). I'll post the PR as we wait in case anyone wants a custom build and can't change the source themselves.

Fair enough @dfredell?

@dfredell
Copy link
Author

dfredell commented Feb 3, 2018

@cheapRoc
I agree, changing the default behavior of any open source project requires notifying people. We can wait a bit to see if anyone else has an opinion.

@dfredell
Copy link
Author

@cheapRoc
Have you heard anything on this issue outside of GitHub?

@jwreagor
Copy link
Contributor

I think we're good for getting my change merged and released. I'll get to that either tomorrow or early next week.

@jwreagor
Copy link
Contributor

Just released in ContainerPilot v3.7.0.

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

No branches or pull requests

2 participants