Skip to main content
Cloud DevOps Solutions
Get a quote Talk to an engineer

Logging & Tracing

Audit Log Collection for Compliance: CloudTrail, Azure Monitor and Kubernetes

Audit log collection gathers the records of who did what in your cloud and clusters, such as CloudTrail, Azure Activity Logs and Kubernetes audit events, into a separate, protected store. We centralise them, make them tamper-evident, set retention and make them searchable for auditors.

Key takeaways

  • Audit logs record administrative and access actions, and auditors expect them complete, retained and protected from the people they describe.
  • Store them in a separate account or subscription with write-once or versioned storage and tight access.
  • Collection covers cloud control plane, identity, Kubernetes API, databases and critical applications.
  • Searchability matters: raw files in a bucket do not answer an auditor's question in time.
  • Retention comes from your frameworks and contracts, and we do not guess what a standard requires.

What an auditor (or an incident) will ask

Sooner or later someone asks: who deleted that database snapshot, when did this role gain admin rights, and who read that customer export last quarter? If the answer needs a week of archaeology, or the evidence was overwritten, the logging is not doing its job. Audit logs are the record of administrative and access actions, and unlike debug logs, their value comes from being complete, trustworthy and available when needed.

This work belongs in our wider logging, ELK, Loki and OpenTelemetry service, and it supports compliance programmes such as CIS-based hardening under Managed DevOps. We do not certify anything ourselves. We build the technical evidence trail.

What good looks like

  • Control plane activity from every account and subscription is captured, including read access to sensitive resources where required.
  • Logs are delivered to a separate, restricted location that the monitored accounts cannot modify.
  • Records are retained for the agreed period and are tamper-evident.
  • Authorised people can answer “who did what, when” in minutes.
  • Risky actions, such as disabling logging or creating an access key for the root user, raise alerts.

What to collect

SourceWhat it recordsTypical destination
AWS CloudTrailAPI calls across AWS accounts, management and optionally data eventsS3 in a log archive account
Azure Activity Log and diagnostic settingsSubscription level operations and resource logsLog Analytics workspace and storage account
Kubernetes audit logRequests to the API server, with who, what and responseCollector to Loki or Elasticsearch
Identity providerSign-ins, MFA events, role and group changesSIEM or log platform
Databases and storageAccess to sensitive tables and objectsLog platform and archive
Your applicationBusiness audit events such as permission changesDedicated audit index or stream

How it works in practice

AWS: organisation trail to a log archive account

With AWS Organizations, an organisation trail records events for all member accounts into one S3 bucket in a dedicated log archive account. Key settings are multi-region coverage, log file validation, KMS encryption and a bucket policy that allows CloudTrail to write and almost nobody to delete.

resource "aws_cloudtrail" "org" {
  name                          = "org-audit"
  s3_bucket_name                = aws_s3_bucket.audit_logs.id
  is_organization_trail         = true
  is_multi_region_trail         = true
  include_global_service_events = true
  enable_log_file_validation    = true
  kms_key_id                    = aws_kms_key.audit.arn
}

The bucket should have versioning, encryption and, where your requirements demand write-once storage, S3 Object Lock configured at bucket creation. Lifecycle rules move older logs to colder classes. The structure is created with Terraform so that it is reviewed and reproducible, and a multi-account setup is easier to do before workloads sprawl.

Azure: diagnostic settings

In Azure, the Activity Log is exported with diagnostic settings to a Log Analytics workspace for query and to a storage account for retention, possibly with immutability policies. Resource logs (Key Vault, SQL, storage) need their own diagnostic settings, which is easy to miss, so we enforce them with Azure Policy and code. This pairs with our Azure DevOps consulting work.

Kubernetes audit logs

The API server writes audit events according to an audit policy. A policy that logs everything at request body level is huge, so we tune levels: metadata for most resources, request bodies for sensitive ones, and omit noisy reads such as health checks. On managed Kubernetes (EKS, AKS, GKE) audit logs are delivered through the provider’s logging feature and then routed to your platform. See the RBAC glossary entry for what these events relate to.

Making it searchable

Files in a bucket are an archive, not an investigation tool. We provide a query path: Athena over CloudTrail in S3, Log Analytics queries in Azure, or ingestion of selected events into Elasticsearch or Loki through the patterns on the log routing page. Fields such as actor, action, resource, source_ip and outcome are normalised so one query works across clouds.

Integrity and alerts

Log file validation in CloudTrail lets you prove files were not altered after delivery. Access to the audit store is logged and alerted. We also alert on actions that weaken the trail itself: stopping a trail, changing a bucket policy, disabling diagnostic settings, or deleting a key. Alert design follows the principles of log-based alerting.

Decisions and trade-offs

Data events or management events only. Management events are cheap and essential. Data events (object-level S3 access, for example) can generate huge volume and cost, so enable them for specific sensitive buckets, not everything.

Search platform or query-in-place. Query-in-place with Athena or Log Analytics is cheaper for rare investigations. A log platform is better for frequent search and alerting.

Immutability and the right to erasure. Write-once storage can conflict with deletion duties for personal data. Audit logs should minimise personal data and avoid content, and the question should be agreed with your legal advisers, as discussed on the log scrubbing page.

When this is too much. An early stage company with no compliance commitments may only need CloudTrail enabled with sensible retention. We scale to what is needed.

Common failure modes

  • Logging enabled in some regions or accounts only, leaving blind spots.
  • Logs stored in the same account the attacker or an administrator controls.
  • No restore or query test, so the first search happens under audit pressure.
  • Retention shorter than the commitment because a lifecycle rule was copied from an application bucket.
  • Cost surprise from data events or verbose Kubernetes audit levels.

Delivery and handover

You receive the Terraform code, a source inventory with owners, retention settings with their rationale, sample queries for typical audit requests, and alerts for tampering. We walk your security lead through the evidence so they can explain it to an auditor.

How to tell it is working

Pick a random administrative action from last month and trace it to a person within minutes. Confirm every account appears in the trail, validation passes, and an attempt to change the audit bucket as an ordinary admin is blocked and alerted. To scope this for your frameworks, book a consultation.

References

How we deliver it

  1. 01

    Map audit obligations

    We list your frameworks, customer commitments and the actions that must be traceable, then agree scope and retention with you.

  2. 02

    Create a protected store

    A dedicated account or subscription holds logs in versioned, encrypted storage with object lock where appropriate.

  3. 03

    Enable and centralise sources

    CloudTrail, Azure Monitor, Kubernetes audit, identity provider and database audit logs are switched on and delivered.

  4. 04

    Make them searchable

    Logs are ingested into Elasticsearch, Loki or a query engine such as Athena, with fields normalised.

  5. 05

    Add integrity and alerts

    Integrity validation, access logging on the store itself and alerts for risky actions are configured.

  6. 06

    Prepare evidence

    We document the setup and produce sample queries and reports that answer common auditor requests.

Tools and technologies

AWS CloudTrailAmazon S3 Object LockAWS OrganizationsAmazon AthenaAzure MonitorAzure Activity LogLog AnalyticsKubernetes audit loggingElasticsearchGrafana LokiTerraformAWS KMS

Frequently asked questions

What are audit logs and how do they differ from application logs?
Audit logs record security-relevant actions: who changed a permission, who accessed data, which API call created or deleted a resource. Application logs record software behaviour for debugging. Audit logs need stronger protection, longer retention and restricted access, because their value is as evidence.
How do you protect audit logs from tampering?
We deliver them to a separate account or subscription, use encrypted versioned storage, enable features such as S3 Object Lock or immutability policies where required, turn on CloudTrail log file validation, and restrict deletion rights to a tiny break-glass role. Access to the store is itself logged.
Which sources should we collect?
At minimum: cloud control plane logs (CloudTrail, Azure Activity Log), identity provider events, Kubernetes API audit logs, and database or storage access logs for sensitive data. Add application-level audit events for actions like permission changes or data exports in your own product.
How long must we keep audit logs?
It depends on your frameworks, contracts and local law, and we do not guess. SOC 2, ISO 27001, PCI DSS and HIPAA each have different expectations, and your auditor interprets them. We set retention with you and your auditor, then implement and prove it technically.
Will this make us SOC 2 or ISO 27001 compliant?
No tool or service does that alone. Audit logging is one control among many, and certification depends on your policies, processes and an independent auditor. We build the logging evidence well and document it, so it supports your assessment rather than becoming a gap.

Talk to an engineer about audit log collection compliance

Book a free 30-minute call. We review your current setup and tell you honestly whether and how we can help.

Written by Saddique Khan, DevOps / SRE / Cloud Consultant Engineer. Last updated 2026-10-08.