在执行操作时使用节点模块cloudfront-log-parser
const CloudFrontParser = require('cloudfront-log-parser');
logstr = "2019-08-29 16:43:02 ATL51-C1 4094 104.129.204.75 GET d2d3d4d5d6.cloudfront.net /static/js/partials/builder-page/builder-page.html 200 https://my.domain.com/ Mozilla/5.0%2520(Macintosh;%2520Intel%2520Mac%2520OS%2520X%252010_14_6)%2520AppleWebKit/537.36%2520(KHTML,%2520like%2520Gecko)%2520Chrome/76.0.3809.100%2520Safari/537.36 - - Miss EYtgWNYeLi6uBaTtmdNzKICvvsfcjVWEBOrFDXrGgs7XS12IuqNd7Q== my.domain.com https 559 0.046 - TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 Miss HTTP/2.0 - -"
let parsed = CloudFrontParser.parse(logstr, { format: 'web' });
我很简单
[
{
date: '2019-08-29 16:43:02 ATL51-C1 4094 104.129.204.75 GET ' +
'd2d3d4d5d6.cloudfront.net ' +
'/static/js/partials/builder-page/builder-page.html 200 ' +
'https://my.domain.com/ Mozilla/5.0 (Macintosh; Intel ' +
'Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) ' +
'Chrome/76.0.3809.100 Safari/537.36 - - Miss ' +
'EYtgWNYeLi6uBaTtmdNzKICvvsfcjVWEBOrFDXrGgs7XS12IuqNd7Q== ' +
'my.domain.com https 559 0.046 - TLSv1.2 ' +
'ECDHE-RSA-AES128-GCM-SHA256 Miss HTTP/2.0 - -'
}
]
不是解析对象...
我们在做什么错了?