1.1 Configuring Workload Observability
Key Takeaways
- CloudWatch standard monitoring publishes at 5-minute intervals at no charge, while detailed monitoring publishes at 1-minute intervals for EC2 instances and Auto Scaling launch templates
- High-resolution custom metrics support collection down to 1-second intervals via PutMetricData, with retention tiers: 1-second (3 hours), 1-minute (15 days), 5-minute (63 days), and 1-hour (455 days)
- Metric filters extract structured metrics from CloudWatch Logs using filter patterns, and configuring a default value of 0 prevents sparse metrics and false alarms
- AWS CloudTrail separates management events (control plane, enabled by default) from data events (S3 object-level and Lambda invocations, charged per event), with log file integrity validated via SHA-256 and RSA signatures
- Amazon Managed Service for Prometheus (AMP) provides serverless, Prometheus-compatible time-series storage scraped by AWS Distro for OpenTelemetry (ADOT) and queried via PromQL
Workload Observability Across Compute, Serverless, and AI/ML
Production cloud operations require full-stack visibility across compute, serverless, and AI/ML workloads. In AWS, observability relies on metrics, logs, and traces. Effective monitoring configures workload-specific telemetry reflecting true operational health.
For Amazon EC2 compute workloads, the AWS hypervisor monitors virtual hardware metrics (CPU, basic disk, network) without host-installed agents. However, guest operating system internals—memory utilization, file system space, and network sockets—require the unified CloudWatch Agent.
For serverless architectures, AWS Lambda automatically emits operational metrics to Amazon CloudWatch:
Invocations: Total execution requests triggered by event sources.Errors: Invocations resulting in unhandled exceptions, runtime crashes, or timeouts.Duration: Execution elapsed wall-clock time in milliseconds.Throttles: Invocations rejected due to exceeding reserved concurrency or account limits.ConcurrentExecutions: Simultaneous active execution environments.
Amazon API Gateway monitors API traffic via Count (request volume), 4XXError (client errors), 5XXError (backend failures or gateway timeouts), Latency (total response time from client request to delivery), and IntegrationLatency (time spent waiting for the backend integration to respond). Comparing Latency against IntegrationLatency isolates whether delays originate in backend code or API Gateway overhead.
For AI/ML workloads on Amazon SageMaker real-time inference endpoints (AWS/SageMaker namespace), primary operational metrics include Invocations, ModelLatency (inference processing duration inside the container), OverheadLatency (request payload handling and network transmission), and hardware accelerators GPUUtilization and GPUMemoryUtilization.
CloudWatch Metrics Architecture & Storage Retention Tiers
CloudWatch Metrics stores timestamped time-series data defined by a MetricName, Namespace (e.g., AWS/EC2 or custom App/Billing), and up to 30 Dimensions (identifying key-value pairs).
EC2 supports two monitoring frequencies:
- Standard Monitoring: 5-minute metric publication included at no additional charge.
- Detailed Monitoring: 1-minute metric publication enabled per instance or launch template for an additional fee, allowing Auto Scaling groups to respond quickly to traffic surges.
Custom Metrics & High-Resolution Publishing
Workloads emit custom metrics using the PutMetricData API, specifying namespace, metric name, dimensions, timestamp, value, and unit (such as Seconds, Percent, or Bytes). Setting --storage-resolution 1 configures high-resolution metrics with 1-second intervals (standard metrics use 60-second intervals).
CloudWatch retains data across four distinct duration tiers:
| Resolution Tier | Retention Period | Aggregation & Rollup Behavior |
|---|---|---|
| 1-second | 3 hours | Full sub-minute resolution for debugging transient latency spikes |
| 1-minute | 15 days | 1-minute intervals for active operational alerting |
| 5-minute | 63 days | 5-minute intervals for medium-term capacity planning |
| 1-hour | 455 days (15 months) | 1-hour rollup intervals for long-term historical analysis |
CloudWatch Logs & CloudWatch Logs Insights
Amazon CloudWatch Logs organizes log ingestion through two core components:
- Log Groups: Define retention rules (1 day to 10 years, or Never Expire), AWS KMS customer managed key (CMK) encryption, and access policies.
- Log Streams: Discrete sequences of log events from the same source (such as an EC2 instance, ECS task, or Lambda container).
Metric Filters and Transformations
Metric filters scan incoming logs in real time against filter patterns:
- JSON pattern:
{ $.statusCode = 500 || $.statusCode = 502 } - Space-delimited pattern:
[ip, user, timestamp, request, status_code = 5*, response_size]
The metric transformation maps matched tokens to a custom metric. Administrators must set the Default Value parameter to 0. Without a default value, filters emit nothing when logs contain no matching events, creating sparse metrics that leave alarms in INSUFFICIENT_DATA or stale states.
CloudWatch Logs Insights
Logs Insights provides an interactive query syntax to analyze logs across groups:
fields: Selects fields to display.filter: Evaluates boolean or regex conditions.stats: Calculates aggregations grouped by time bins.sortandlimit: Orders and caps result sets.
fields @timestamp, @message, status_code, response_time
| filter status_code >= 500
| stats count() as error_count by bin(5m)
| sort error_count desc
| limit 20
AWS CloudTrail: Governance, Data Events & CloudTrail Lake
AWS CloudTrail audits API calls across accounts:
- Management Events: Record control plane operations (e.g.,
RunInstances,CreateBucket). Captured by default across all Regions in a 90-day free event history. - Data Events: Record high-volume data plane operations (e.g., S3
GetObject/PutObject, LambdaInvokeFunction). Disabled by default; billed per event.
Multi-Region trails record events across all Regions and capture global services (IAM, STS, CloudFront) in us-east-1. Log File Integrity Validation generates SHA-256 digest files signed with RSA keys, enabling cryptographic tampering verification via aws cloudtrail validate-logs. CloudTrail Lake provides a managed SQL data lake for querying audit logs with configurable retention up to 10 years (3,653 days).
Amazon Managed Service for Prometheus (AMP)
Amazon Managed Service for Prometheus (AMP) delivers serverless, scalable, Prometheus-compatible monitoring for containerized workloads. The AWS Distro for OpenTelemetry (ADOT) collector runs as an EKS DaemonSet, scraping Prometheus endpoints and forwarding metrics to AMP via remote_write with AWS SigV4 authentication. AMP evaluates alerting and recording rules using native PromQL, routing alerts to Amazon SNS topics.
Operational Best Practices
- Batch Custom Metrics: Batch up to 1,000 metrics or 1 MB per
PutMetricDatacall, or use Embedded Metric Format (EMF) via logs to avoid API throttling. - Log Retention Governance: Define explicit log retention policies (such as 30 or 90 days) in Infrastructure as Code to eliminate unbounded storage costs.
A CloudOps engineer needs to monitor sub-second latency spikes in a high-frequency trading application hosted on Amazon EC2. The engineer configures a custom metric with a 1-second storage resolution using the PutMetricData API. What is the maximum duration that CloudWatch retains these 1-second metric datapoints at full resolution before aggregating them?
An operations team creates a CloudWatch metric filter to monitor HTTP 500 error spikes from an NGINX access log group. When configuring the metric transformation, the team observes that alarms based on this metric fail to clear back to the OK state during periods of zero traffic because no log events are ingested. Which configuration change resolves this issue?
A compliance mandate requires auditing all read and write interactions with sensitive customer files stored in an Amazon S3 bucket, as well as verifying that audit log files have not been tampered with or modified after delivery. Which combination of AWS CloudTrail configurations fulfills these requirements?