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

millisecond time is not showing parsed json record. #1866

Closed
vgitk opened this issue Oct 22, 2023 · 8 comments
Closed

millisecond time is not showing parsed json record. #1866

vgitk opened this issue Oct 22, 2023 · 8 comments
Labels
question Further information is requested

Comments

@vgitk
Copy link

vgitk commented Oct 22, 2023

Question

Shalom,

I've recently come across a fantastic log-parsing tool. I need to parse extensive .log files containing JSON records on each line.

I'm attempting to parse JSON files using the "JSON log parser." I've configured the dateTime format as "yyyy.MM.dd HH:mm:ss.fff," but I'm encountering an issue where the millisecond time isn't visible in the output.

Sample JSON record1 :

{"instant":{"epochSecond":1685544384,"nanoOfSecond":611206994},"thread":"taskScheduler-3","level":"DEBUG","loggerName":"com.corp.cbu.cnc.nrfc.NRFCManagement","message":"NfInstanceId c1b51db4-7ac6-11ec-90d6-0242ac120003 present in list of configuredNfProfiles","endOfBatch":false,"loggerFqcn":"org.apache.logging.slf4j.Log4jLogger","threadId":54,"threadPriority":5,"messageTimestamp":"2023-05-31T14:46:24.611+0000"}
`
Sample JSON record2 :

{"messageTimestamp":"2023-05-31T15:06:10.497Z","logLevel":"DEBUG","pid":1,"workerId":"master","message":"Fetching data from URI: http://occnp-2310-26507-gyltj-occnp-config-server:8000/topics/common.logging.pre for topic common.logging.pre with param false"}

DateTime format:

image

If you observe, the time format in both the sample records is slightly different.

Sample 1 messageTimestamp : 2023-05-31T14:46:24.611+0000
Sample 1 messageTimestamp : 2023-05-31T15:06:10.497Z

We receive both types of files for analysis, and we need to correlate the records between these two file formats. I would greatly appreciate it if you could recommend a method for extracting the date and time from both types of records and displaying them in the "yyyy.MM.dd HH:mm:ss.fff" format.

JSON configuration:

image

Here is the parsed record view, for some reason, it does not show the millisecond time.

image

Looking forward to hearing from you.

@vgitk vgitk added the question Further information is requested label Oct 22, 2023
@vgitk
Copy link
Author

vgitk commented Oct 22, 2023

This is the error that I can see :

Error: error: Input string was not in a correct format.. Member:. Line:0. Thread (managedID):1. Start Time:10/22/2023 1:38:27 AM. Time:10/22/2023 01:38:39.126 AM. File: . Exception: System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at Microsoft.Extensions.Logging.LoggerExtensions.MessageFormatter(FormattedLogValues state, Exception error)
at Analogy.AnalogyLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter). Member:. Line:0. Thread (managedID):1. Start Time:10/22/2023 1:38:27 AM. Time:10/22/2023 01:38:39.126 AM. File:

@vgitk vgitk changed the title milisecond time is not showing parsed json record. millisecond time is not showing parsed json record. Oct 22, 2023
@LiorBanai
Copy link
Member

Hi @vgitk
This should be relative simple fix. I'll check this and update you.

@vgitk
Copy link
Author

vgitk commented Oct 22, 2023 via email

@LiorBanai
Copy link
Member

Hi @vgitk
with this example

{"instant":{"epochSecond":1685544384,"nanoOfSecond":611206994},"thread":"taskScheduler-3","level":"DEBUG","loggerName":"com.corp.cbu.cnc.nrfc.NRFCManagement","message":"NfInstanceId c1b51db4-7ac6-11ec-90d6-0242ac120003 present in list of configuredNfProfiles","endOfBatch":false,"loggerFqcn":"org.apache.logging.slf4j.Log4jLogger","threadId":54,"threadPriority":5,"messageTimestamp":"2023-05-31T14:46:24.611+0000"}
{"messageTimestamp":"2023-05-31T15:06:10.497Z","logLevel":"DEBUG","pid":1,"workerId":"master","message":"Fetching data from URI: http://occnp-2310-26507-gyltj-occnp-config-server:8000/topics/common.logging.pre for topic common.logging.pre with param false"}

after small tweak and update in Analogy the format, I'm getting this:

image

and formating:
image

Is this what you need?

@vgitk
Copy link
Author

vgitk commented Oct 25, 2023

Hi @LiorBanai,

Thanks for your efforts, yes the change looks good to me. I assume the change can handle the date and time below formats:

Sample 1 messageTimestamp : 2023-05-31T14:46:24.611+0000
Sample 2 messageTimestamp : 2023-05-31T15:06:10.497Z

basically in the final output I need the date and time below format:

yyyy-MM-DDTHH:mm:ss.fff (milliseconds in three decimal digits)

@LiorBanai
Copy link
Member

so it seems the solution is working:
image

I have used the follownig format:
image

will release new version later today.

@LiorBanai LiorBanai mentioned this issue Oct 27, 2023
@LiorBanai
Copy link
Member

I have Released new version. You can test it and report back with any problems :)
https://github.com/Analogy-LogViewer/Analogy.LogViewer/releases/tag/v5.1.1.0

@vgitk
Copy link
Author

vgitk commented Oct 28, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants