You have a CloudWatch Logs group with a retention period set to 7 days. What happens to the logs older than 7 days?
Think about how retention policies work in CloudWatch Logs.
CloudWatch Logs retention policies automatically delete logs older than the set retention period. They do not archive or move logs to other storage services.
You want to create a metric filter in CloudWatch Logs to count the number of ERROR messages in your application logs. Which filter pattern correctly matches lines containing the word 'ERROR'?
Metric filter patterns use simple string matching or JSON syntax.
The pattern "ERROR" matches any log line containing the word ERROR. The other options are either invalid syntax or incorrect pattern types.
You have multiple AWS accounts generating logs. You want to centralize all logs into a single CloudWatch Logs account for monitoring and analysis. Which architecture best achieves this?
Think about streaming logs in real-time to a central location.
Subscription filters can stream logs from multiple accounts to a central Kinesis Data Firehose, which then delivers logs to the central account's storage or analysis tools.
You want to restrict access so that only a specific IAM role can read logs from a CloudWatch Logs group. Which policy element correctly restricts access?
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["logs:GetLogEvents", "logs:FilterLogEvents"],
"Resource": "arn:aws:logs:us-east-1:123456789012:log-group:MyAppLogs:*",
"Condition": {
"StringEquals": {
"aws:PrincipalArn": "arn:aws:iam::123456789012:role/SpecificRole"
}
}
}
]
}Look at the Condition element restricting access by principal ARN.
The Condition element restricts access to only the specified IAM role by matching the principal ARN. This ensures only that role can perform the allowed actions.
You have a high volume of logs generating in CloudWatch Logs. To reduce costs and improve query performance, which approach is best?
Think about offloading logs to cheaper storage and using efficient query tools.
Exporting logs to S3 with lifecycle policies reduces storage costs. Querying logs with Athena is cost-effective and performant compared to querying directly in CloudWatch Logs.