'Google CDN - Get Country and Device
currently I'm using an AWS CDN, that works pretty fine for me. But we would like to move from AWS to Google Clou CDN and it seems some parts are not working for us or the setup is not correct.
My Setup
My idea is to implement the serverless Pixel Tracking (https://cloud.google.com/architecture/serverless-pixel-tracking).
- Google Storage with a simple GIF Image
- Load Balancer created
- Backend Configuration created. I added a Backend Service to a google storage Bucket, with enabled CDN
- Frontend Configuration with HTTPS
So the chain is working fine for me. I can load the Pixel from CDN. I took a look in the Log Explorer, and looks like:
{
httpRequest: {
cacheHit: true
cacheLookup: true
latency: "0.000752s"
referer: "xxxxxx"
remoteIp: "xxx.xxx.xxx.xxx"
requestMethod: "GET"
requestSize: "217"
requestUrl: "https://xxx.xxxx.com/xxx.gif?param1=param"
responseSize: "870"
status: 200
userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
}
insertId: "xxxx"
jsonPayload: {
@type: "type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry"
cacheId: "MUC-3ec5f666"
statusDetails: "response_from_cache"
}
logName: "projects/xxxxx/logs/requests"
receiveTimestamp: "2022-04-22T20:52:43.770534804Z"
resource: {
labels: {
backend_service_name: ""
forwarding_rule_name: "xxxx-pixel-lb-forwarding-rule-2"
project_id: "xxx-xxx-xx"
target_proxy_name: "xx-xx-lb-target-proxy-2"
url_map_name: "xxx-pixel-lb"
zone: "global"
}
type: "http_load_balancer"
}
severity: "INFO"
spanId: "xxxxx"
timestamp: "2022-04-22T20:52:43.276527Z"
trace: "projects/secxxxxret-xxxx-xxx/traces/xxxxxxx"
}
Device Detection
AWS provides some Header for Device Detection (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-cloudfront-headers.html) but it seems this is not available in Google CDN. Is this correct ? I would like to see the Device in the Log.
Geo Location Detection
In AWS i can check for example CloudFront-Viewer-Country-Name. There is a documentation https://cloud.google.com/appengine/docs/standard/go/reference/request-response-headers with X-Appengine-Region. Is it possible to get this Information somehow into the log ?
Background:
I am exporting the Log into BigQuery for further analyses
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
