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

SC-16333 Extract fields from vercel syslog messages #325

Merged
merged 2 commits into from
May 25, 2023

Conversation

PabloB94
Copy link
Member

I added a regex to parse the kind of logs the user is asking about.

They are logs in the syslog format, vercel also provides an option to log in json format, which probably would be parsed correctly.

The regex assumes the same format the user reported, if the log doesn't match that format, it won't be parsed and it will default to the behavior we had until now

Signed-off-by: Pablo Beltran <pablo.beltrancasso@sematext.com>
Signed-off-by: Pablo Beltran <pablo.beltrancasso@sematext.com>
@PabloB94 PabloB94 requested a review from HSSalman May 24, 2023 16:31
Copy link

@HSSalman HSSalman left a comment

Choose a reason for hiding this comment

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

Looks good

@PabloB94
Copy link
Member Author

Here's an example of the behavior of the parser:

For an input log:

{
  source: 'lambda',
  message: 'START RequestId: xxxxxxxx-da1f-48df-xxxx-b432102dd448 Version: $LATEST\n' +
    '2023-05-22T02:00:31.493Z\txxxxxxxx-da1f-48df-xxxx-b432102dd448\tINFO\t{\n' +
    "  level: 'info',\n" +
    "  message: 'Healthcheck',\n" +
    "  env: 'preview',\n" +
    '  healthy: true,\n' +
    '  prisma: { healthy: true, time: 0.011350886999629438, error: undefined },\n' +
    '  kinde: { healthy: true, time: 0.05071398300025612, error: undefined },\n' +
    '  hubspot: { healthy: true, time: 0.26839886800013485, error: undefined }\n' +
    '}\n' +
    'END RequestId: xxxxxxxx-da1f-48df-xxxx-b432102dd448\n' +
    'REPORT RequestId: xxxxxxxx-da1f-48df-xxxx-b432102dd448\tDuration: 275.22 ms\tBilled Duration: 276 ms\tMemory Size: 1024 MB\tMax Memory Used: 198 MB\t\n'
}

The output of the parser will be:

{
  requestId: 'xxxxxxxx-da1f-48df-xxxx-b432102dd448',
  version: '$LATEST',
  timestamp: '2023-05-22T02:00:31.493Z',
  logLevel: 'INFO',
  message: '{\n' +
    "  level: 'info',\n" +
    "  message: 'Healthcheck',\n" +
    "  env: 'preview',\n" +
    '  healthy: true,\n' +
    '  prisma: { healthy: true, time: 0.011350886999629438, error: undefined },\n' +
    '  kinde: { healthy: true, time: 0.05071398300025612, error: undefined },\n' +
    '  hubspot: { healthy: true, time: 0.26839886800013485, error: undefined }\n' +
    '}',
  duration: 275.22,
  billedDuration: 276,
  memorySize: 1024,
  maxMemoryUsed: 198,
  source: 'lambda'
}

@PabloB94 PabloB94 merged commit 829e771 into master May 25, 2023
@PabloB94 PabloB94 deleted the pbc_SC-16333_vercel-syslog-parsing branch May 25, 2023 12:24
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.

2 participants