Search code examples
amazon-web-servicesamazon-cloudfront

Additional Device type columns like CloudFront-Is-Mobile-Viewer in aws cloudfront


How can I Configuring aws cloudfront Distribution log with additional Device type columns like CloudFront-Is-Mobile-Viewer, CloudFront-Is-Desktop-Viewer, or CloudFront-Is-Tablet-Viewer.

I have static objects in S3 like images and these are replicated in cloudfront. The access logs are populating in cloudfront Distribution logs as per AWS Configuring and Using Access logs of cloudfront . I want additional columns in cloudfront Distribution log which is populate with device type like Desktop , mobile , Tablet .

I am wondering the exact steps required to accomplish this.


Solution

  • CloudFront doesn't provide these columns in the access logs.

    However, these values are derived from the value that is present in the cs(User-Agent) column of the log files.

    You will need to derive them yourself, when processing the logs. It isn't possible to configure CloudFront to log them. The log format does not support customization.

    Search the web for a user-agent parsing library in your scripting language of choice.

    Random example.