Skip to content

Instantly share code, notes, and snippets.

@deptno
Last active May 25, 2018 08:22
Embed
What would you like to do?
aws-cwlog cloudwatch log transform oneline format
// aws-cwlog trnasform script <https://www.npmjs.com/package/aws-cwlog>
// CloudWatch Log to oneline format eg."2018-05-25T04:41:58 log message"
map(
pipe(
dissoc('ingestionTime'),
over(
lensProp('timestamp'),
pipe(
x => new Date(x).toISOString(),
slice(0, -5),
)
),
over(
lensProp('message'),
pipe(
tryCatch(JSON.parse, identity),
)
),
x => `${x.timestamp} ${pipe(prop('msg'), JSON.stringify)(x.message)}`
),
)
@deptno
Copy link
Author

deptno commented May 25, 2018

map(x => [
  new Date(x.timestamp).toISOString().slice(0, -5),
  JSON.parse(x.message).msg
].join(' '))

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