Skip to content

Conversation

drummerjoe
Copy link

Created a new format handler for support of AWS S3 access logs. Based on the ELBv2 handler which only required modifications to the field list and a bit of formatting of the date to match ISO-8601.

Fixes #25

@coveralls
Copy link

coveralls commented Aug 2, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 85f09a2 on drummerjoe:feature/s3access into 20705f5 on arithmetric:master.

}
item.time = item.time.replace(/:/, ' ').replace(/\[/, '');
item.zone = item.zone.replace(/\]/, '');
item[config.dateField] = new Date(item.time + item.zone);
Copy link
Owner

Choose a reason for hiding this comment

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

I'd recommend using new Date(...).toISOString() to explicitly set this field as an ISO-formatted date string. This is what is implicitly done through the JSON stringify later.

See the pattern from: https://github.com/arithmetric/lambda-stash/blob/master/handlers/formatCloudwatchLogs.js#L54

Copy link
Author

Choose a reason for hiding this comment

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

Awesome catch.

@arithmetric
Copy link
Owner

This is great, thanks @drummerjoe.

I will merge this PR, and then I plan to make two changes:

  • For consistent capitalization, I'd like to rename the handler file to handlers/formatS3Access.js.
  • As recommended above, I will add toISOString to the date field output.

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.

S3 bucket access logs?
3 participants