implementing-cloud-trail-log-analysis

Analyze AWS CloudTrail logs with Athena and CloudWatch to detect unauthorized access and privilege escalation.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill implementing-cloud-trail-log-analysis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implementing-cloud-trail-log-analysis
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/cloud-security/implementing-cloud-trail-log-analysis
Command: npx skills add https://github.com/xalgord/xalgorix --skill implementing-cloud-trail-log-analysis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Security teams struggle to turn raw AWS CloudTrail logs into actionable threat detection, leaving unauthorized access, privilege escalation, and log tampering invisible across multi-account environments.

Core Features & Use Cases

  • Organization-wide trail configuration: Set up multi-region, organization-level trails with log file validation, KMS encryption, and S3/Lambda data event selectors.
  • SQL-based threat hunting: Run Athena queries to detect console logins without MFA, IAM privilege escalation, CloudTrail tampering, and AccessDenied anomalies.
  • Real-time alerting: Build CloudWatch Logs Insights queries and CIS Benchmark metric filters with alarms for root usage, IAM policy changes, and trail modifications.
  • Use Case: When GuardDuty flags a compromised access key, query CloudTrail across all regions to reconstruct the attacker's full API call timeline, identify persistence mechanisms, and verify logs were not tampered with.

Quick Start

Ask the AI to analyze CloudTrail logs for suspicious activity such as console logins without MFA and privilege escalation attempts using Athena queries.

Frequently Asked Questions about implementing-cloud-trail-log-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query AWS CloudTrail logs with Athena?

Create an external Athena table over the CloudTrail S3 bucket using the JSON SerDe, partitioned by region, year, month, and day. Add partitions for the target dates, then run SQL queries filtering on eventName, userIdentity, and errorCode to detect suspicious activity.

How to detect privilege escalation in AWS CloudTrail logs?

Query for IAM events like CreatePolicyVersion, AttachRolePolicy, PutUserPolicy, CreateAccessKey, and PassRole in CloudTrail. Correlate these with sourceIPAddress and userIdentity.arn to identify which principal attempted escalation and from where.

CloudTrail vs GuardDuty for threat detection, which should I use?

GuardDuty already analyzes CloudTrail for real-time threat detection, so use it for active alerting. CloudTrail log analysis with Athena or Logs Insights is for forensic investigation, custom detection rules, and compliance auditing rather than real-time detection.

Why are my Athena CloudTrail queries returning empty results?

Empty results usually mean partitions were never added for the queried dates, so Athena scanned nothing. Add partitions with ALTER TABLE ADD PARTITION pointing at the correct S3 prefix, or enable partition projection on the table.

Can CloudTrail logs be used for real-time incident response?

CloudTrail delivery to S3 and CloudWatch lags up to about 15 minutes, so it is not truly real-time. For live incidents, use CloudTrail Lake or CloudWatch Logs Insights, which provide faster query access to recent events.

What CloudTrail events should trigger security alarms?

CIS Benchmark recommends metric filters and alarms for unauthorized API calls, root account usage, IAM policy changes, and CloudTrail configuration changes like StopLogging, DeleteTrail, and UpdateTrail. These indicate credential misuse or attempts to disable auditing.