latest run 54 pass 0 fail 0 skipevidence →
HKB Operations: pages
HKB OperationsKnowledge space

Starred pages

Pages

Page directory · Labels · [ hides this

Traffic job

A CodeBuild job in Prod that counts the site's visitors once a day, from CloudFront's request metrics and the access logs in Log Archive, and publishes totals only.

Flow

Traffic job flowOnce a day at 01:30 UTC, EventBridge Scheduler in the Prod account starts the hkb-site-traffic CodeBuild project. The job reads its settings from SSM Parameter Store, CloudFront's Requests metric, and the last 30 days of access logs from the bucket in the Log Archive account, decrypting them with that bucket's KMS key. It counts visitors from hashes held in memory and writes one file of totals, never addresses, to the site bucket.AWS CloudProd · hkb-prodLog Archive · hkb-log-archiveSchedulerdaily, 01:30 UTChkb-site-trafficCodeBuild, 10 minCloudFrontRequests metricParameter Storedata key, owner addressesSite bucketone file of totalsAccess logs bucketthe last 30 daysLogs keythe bucket's ownVisitors are counted from hashes held in memory. No address is published.Job logs: /aws/codebuild/hkb-site-traffic, kept 90 days. 2 retries if a run fails.Legend1Request or run orderRequest / dataEvent / logAttached / governsBlueOpens its pagestarts1settings2reads3reads, across accounts4totals only5decrypts
Traffic job flowOpen full sizeClose

Addresses stay in Log Archive and in the job's memory. Only totals reach the site.

Configuration

SettingValue
ScheduleEventBridge Scheduler, daily at 01:30 UTC, after the day before is complete; 2 retries. The scheduler's role, hkb-site-traffic-schedule, may only start this project
JobCodeBuild project hkb-site-traffic, no source, 10-minute timeout. CodeBuild rather than Lambda: the script is longer than CloudFormation's 4 KB inline code limit
ReadsThe site access logs in Log Archive (the last 30 days, across accounts) and CloudFront's Requests metric
CountsA visitor is a browser that loaded a page's files that day as well as its HTML. Visitors are counted from hashes held in memory; the logs are copied to the build's disk and go with the container
WritesOne script file of totals in the site bucket. No address is ever published, and the owner's own addresses are left out of the counts
SettingsThe data file's key and the owner's addresses are SSM parameters set by a manual step (H-7.16), so neither is in the repository
Rolehkb-site-traffic: read the log bucket and its key in Log Archive, read the metric, write the one file. Its logs go to /aws/codebuild/hkb-site-traffic, kept 90 days
Deployed byThe hkb-baseline-site-traffic StackSet, to Prod only

Sources

Page information

Owner
Platform Engineering
Status
current Current: generated from the templates and records in the repository at this build.
Generated from
baseline/hkb-baseline-site-traffic.yaml
Linked from
Prod, Site distribution