Skip to content
back to the map
technique
stage: detectar
6 min read

Logging & detection - signals and alerts

Cloud detection starts with logs: CloudTrail, VPC flow logs, IAM audit and DNS become correlated signals that feed the SIEM, managed detection and response automation.

AWS CloudTrailAmazon GuardDutyAmazon DetectiveOpenSearchDatadog

What it is

Logging & detection is the piece of detection that lives on signal: audit trails, control plane logs, data plane logs, runtime events, DNS outputs and identity events. The job is to collect all of this in one place, retain it long enough and fire an alert when something out of the pattern appears.

scans configuration; scans workload behavior. Here the question is broader: 'what happened in this account in the last 90 days, and did it happen again just now?'. The answer lives in correlation: an AssumeRole can be legitimate on its own, and criminal when combined with kms:Decrypt five minutes later and a GetObject on a bucket that nobody in that role should open.

What to capture: audit trails

The classic pillar is the control plane log: every API call, signed, with principal ARN, source IP, user agent, request parameters and response elements. On AWS this is CloudTrail; on Azure it is the Activity Log; on GCP it is Cloud Audit Logs. This is the log that answers 'who called what, when, and what was the result'. Without it, the incident becomes guesswork.

By default CloudTrail records management events (create user, delete bucket) in the account trail, and keeps the last 90 days in the console. For real forensics, it is worth creating a multi-region trail that writes to S3 with object lock, and adding a Lake or a SIEM on top for querying and longer retention.

CloudTrail event (console.amazonaws.com)json
{
  "eventVersion": "1.09",
  "userIdentity": {
    "type": "IAMUser",
    "principalId": "AIDAEXAMPLEPRINCIPAL",
    "arn": "arn:aws:iam::111122223333:user/alice",
    "accountId": "111122223333",
    "accessKeyId": "AKIAEXAMPLEACCESSKEY",
    "userName": "alice"
  },
  "eventTime": "2026-10-09T03:17:42Z",
  "eventSource": "s3.amazonaws.com",
  "eventName": "GetObject",
  "awsRegion": "us-east-1",
  "sourceIPAddress": "203.0.113.45",
  "userAgent": "aws-cli/2.15.0",
  "requestParameters": {
    "bucketName": "loja-customer-uploads",
    "key": "billing/exports/sept-2026.csv"
  },
  "responseElements": null,
  "requestID": "6E3D4B2XAMPLE",
  "eventID": "e9c1f0a6-2b1c-4f37-9a4d-3e2b9c0b8c11",
  "readOnly": true,
  "eventType": "AwsApiCall",
  "recipientAccountId": "111122223333"
}

Data plane and network logs

CloudTrail does not see everything. It records the API call, not what happened inside it nor the packet that crossed the network. To close the gap, three sources become mandatory.

  • Flow Logs: every packet accepted or rejected on the VPC's ENIs. Source, destination, port, decision (ACCEPT/REJECT), bytes counted. When an exfiltration alert fires, this is the first place to confirm the destination.
  • S3 data events: reads and writes on specific buckets (not on by default in the trail because they are expensive). For a bucket with or secrets, this is the log that tells who took what.
  • EKS / Kubernetes audit: kube-apiserver writes every call to kube-apiserver-audit.log. ingress create, secret read, exec in a pod - everything goes in. Combined with CloudTrail, it shows the complete chain: kubelet makes a call, pod talks to the API, API returns a token, token becomes AssumeRole.
  • DNS logs (Route 53 Resolver / Cloudflare): resolver queries are kept. Useful for detecting DGA (domain generation by malware), beaconing and C2 under the firewall's radar.

Centralization and retention

Collecting everything and leaving each account with its own bucket is a recipe for the log to vanish at the first incident. The right design is fan-out: each account writes its log to S3 (or equivalent) with , and an aggregator lake or a corporate SIEM pulls everything for a single query.

Retention is where most teams slip. Management logs need 90 days hot (fast query) and 365 days cold (S3 + Glacier). VPC flow logs, depending on volume, become 30 days hot and 180 days cold. Audit logs that will become legal evidence call for object lock (WORM) to prevent retroactive tampering - without it, an attacker with write access erases their own tracks.

Detection: rules, anomalies and hunting

The detection layer comes in three flavors. Deterministic rules (signatures) fire on a known signature: ConsoleLogin without MFA, root API key in use, CloudTrail disable. ML / anomalies fire on baseline deviation (login from a never-seen region, massive bucket listing by a user who normally lists three). Hunting is the human looking for what nobody thought to write a rule for.

GuardDuty combines the three flavors in a single managed offering: it consumes CloudTrail, VPC Flow Logs and DNS, and sends findings to EventBridge or Security Hub. The typical integration is Detective coming in for investigation (entity graph + timeline), Security Hub aggregating with Prowler/Inspector, and the (Step Functions, Tines, Torq) firing a runbook. The trick is to keep rules out of the SIEM when the SIEM aggregates poorly, and use GuardDuty for the 80% of obvious findings.

EventBridge rule (AWS::Events::Rule) - critical GuardDuty alertyaml
Description: "Forwards critical GuardDuty findings to the SOAR queue"
State: ENABLED
EventBusName: default
EventPattern: |
  {
    "source": ["aws.guardduty"],
    "detail-type": ["GuardDuty Finding"],
    "detail": {
      "severity": [{ "numeric": [">=", 7] }],
      "type": [
        "Recon:EC2/PortProbeUnprotectedPort",
        "Recon:EC2/PortProbeOpenPort",
        "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration",
        "CredentialAccess:IAMUser/AnomalousBehaviors",
        "Policy:IAMUser/RootCredentialUsage",
        "Persistence:IAMUser/NetworkPermissions",
        "PrivilegeEscalation:IAMUser/AdministrativePermissions",
        "Exfiltration:S3/MaliciousIPCaller"
      ]
    }
  }
Targets:
  - Id: SOARIngestTarget
    Arn: arn:aws:sqs:us-east-1:111122223333:soar-ingest

SIEM integration

The SIEM (OpenSearch, Splunk, Elastic, Datadog Cloud SIEM) is where correlation happens. Each source (CloudTrail, GuardDuty, flow logs, k8s audit, EDR) becomes an indexed stream, with its own parser and canonical fields (time, actor, target, action, result). The SIEM rule crosses sources: new IAM AssumeRole + CloudTrail GetSecretValue + public bucket touched in <5 min = suspicious session.

To reduce cost and noise, two habits pay off. First, storage tiers: hot in the SIEM (30 days), cold in S3 (Iceberg, Parquet) with Athena or OpenSearch Serverless querying on demand. Second, managed detection for what you have no team to maintain: GuardDuty covers 80% of obvious findings, CSPM covers , CWPP covers runtime. The SIEM is left for what is house-specific.

Where it fits in day-to-day work

  • account onboarding: multi-region trail on, Lake or Firehose configured, S3 with object lock on the log bucket, and KMS with a dedicated key for the logs
  • application deploy: the app emits structured logs (JSON) to stdout or a sidecar; Fluent Bit / Datadog Agent / OpenTelemetry Collector normalizes and ships to the aggregator
  • incident response: the first command is 'search for the principal ARN in the attack window' - without an indexed log this becomes grep on text files
  • compliance: CIS Foundations, PCI, SOC 2 require an active trail and minimum retention; without an architected log, the auditor fails you before even opening the checklist

Strengths

  • total visibility of what happened: an immutable trail answers 'who, when, from where, what' for any API call in the account
  • detection by correlation reduces false positives: a rule that crosses signals from three sources has high precision and low noise
  • decent forensics: object lock + long retention guarantees that the log from the day of the incident still exists when you open the case six months later

Limitations

  • log custody is continuous work: turning a trail off to cut costs or forgetting to validate object lock turns the log into theater
  • volume eats budget: VPC Flow Logs on a large account cost on the order of USD per day; without filtering and tiering, the bill wins the conversation
  • signature-based detection only catches the known: a new attacker with unmapped TTPs gets past GuardDuty, and the defense falls to manual hunting and the senior analyst's SIEM rule
CSPMcloud security posture managementA tool that scans your cloud configuration against best practices and benchmarks (CIS, NIST), flagging public S3 buckets, overly broad IAM, exposed ports. It asks the question humans forget: 'what is misconfigured RIGHT NOW?'.see in glossary →CWPPcloud workload protection platformMonitored protection for running workloads: VMs, containers, serverless functions. It combines visibility into what runs (processes, syscalls, network) with prevention (blocking execution, isolating anomalies). It is endpoint security reworked for the ephemeral reality of the cloud.see in glossary →IAMidentity and access managementThe set of policies, roles and credentials that says who every human, service or workload is, and what each one can do. In the cloud, IAM became the new perimeter: the network edge got porous, so identity carries the authorization.see in glossary →VPCvirtual private cloudA logically isolated private network inside the public cloud: you choose the IP range, split it into public and private subnets, and control traffic with route tables and NAT. The VPC is your virtual datacenter; everything running inside it talks as if it were in the same rack.see in glossary →PIIpersonally identifiable informationPersonal data that identifies someone: name and national ID, email, phone, address, IP. When the user pastes a document with PII into the chat, or RAG indexes a CRM with 5,000 customers, the agent becomes a leak by design. Guardrails here are detection on input, redaction before sending to the LLM, and short retention, because masking after receiving the response is already too late.see in glossary →KMSkey management serviceA managed service that creates, stores and controls the use of cryptographic keys. The application rarely touches the master key: it asks the KMS to encrypt or decrypt, and the provider records every use in an auditable log. Without a KMS, the key ends up on disk and becomes a target.see in glossary →SOARSecurity orchestration, automation and response: running response steps automatically, described in playbooks, with brakes such as human approval and auditing.see in glossary →Driftconfiguration driftWhen live infrastructure moves away from the declared state: someone opened a port in the console, a bucket became public, an IAM role became admin. Drift is configuration accumulated outside version control, and the best cure is IaC with review: everything that changes goes through code.see in glossary →

connections on the map

updated on 14/10/2026 · sources to go deeper · report an error

in other domains

Unlocks

test what you learned

Loading questions…