akshay-scaler
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Script for Class 11 - Advanced AWS CloudWatch Concepts and Integration ## Agenda * Advanced Concepts in CloudWatch * Log Monitoring & Analysis using AWS CloudWatch * Integration of AWS CloudWatch with Various Services * Understanding AWS CloudWatch Event (Now EventBridge) * Overview of Application Signals * QnA * MCQ * Scenario based Questions --- # Advanced Concepts in CloudWatch ### **CloudWatch Agent for Custom Metrics** CloudWatch Agent is a software package that enables you to collect **custom metrics** from EC2 instances, on-premises servers, and applications. It provides system-level metrics that go beyond the default CloudWatch metrics. #### **Why Use CloudWatch Agent?** - Collect custom metrics such as **memory usage, disk space, and application-specific logs**, which are not available by default in CloudWatch. - Monitor both **Linux and Windows instances** as well as on-premises servers. - Forward logs to **CloudWatch Logs** for further analysis. #### **Setting Up CloudWatch Agent for Custom Metrics** 1. **Install the CloudWatch Agent** on your EC2 instance or on-premises server. - Download and install the agent using AWS Systems Manager or manually from the AWS repository. 2. **Configure the CloudWatch Agent** using the configuration wizard (`amazon-cloudwatch-agent-config-wizard`). - Define which metrics (e.g., memory, disk, swap usage) should be collected. 3. **Start the CloudWatch Agent** and push metrics to CloudWatch. - Use the command: ```bash sudo amazon-cloudwatch-agent-ctl -a start ``` 4. **Visualize the custom metrics** on the CloudWatch console under "Custom Namespaces." --- ### **CloudWatch Contributor Insights** CloudWatch Contributor Insights is a **log analysis feature** that helps identify which specific users, hosts, or resources contribute the most to performance issues, high latency, or system failures. #### **Use Cases of Contributor Insights** - **Identifying API abuse** by analyzing the top requesters in API Gateway logs. - **Detecting traffic spikes** that impact system performance. - **Understanding failure patterns** in application logs. #### **How to Use CloudWatch Contributor Insights** 1. **Enable Contributor Insights** in the CloudWatch console. 2. **Select the log group** you want to analyze (e.g., VPC Flow Logs, CloudTrail Logs, or application logs). 3. **Define contributor rules** based on key fields like `sourceIP`, `userID`, or `requestPath`. 4. **Analyze results** to identify which entities contribute the most to high latency or error rates. 5. **Set alerts** to detect anomalies and trigger automation if a threshold is breached. --- ### **CloudWatch Logs Insights** CloudWatch Logs Insights is a **powerful query tool** that helps analyze large volumes of log data quickly. It provides **real-time insights** from logs to troubleshoot issues and improve operational efficiency. #### **Key Features of CloudWatch Logs Insights** - **Query large datasets efficiently** using a purpose-built query language. - **Filter logs** based on patterns such as error messages, IP addresses, or specific timestamps. - **Visualize log trends** with built-in charts and dashboards. - **Integrate with CloudWatch Alarms** to automatically trigger alerts based on log data. #### **Using CloudWatch Logs Insights to Analyze Logs** 1. **Go to CloudWatch Logs Insights** in the AWS console. 2. **Select a log group** (e.g., Lambda logs, VPC Flow Logs, or application logs). 3. **Run a query** to extract relevant data: - Example: Identify the top 10 IPs making requests to an application. ```sql SELECT sourceIP, COUNT(*) as request_count FROM myAppLogGroup GROUP BY sourceIP ORDER BY request_count DESC LIMIT 10 ``` 4. **Analyze the query results** to detect anomalies, failures, or performance issues. 5. **Export findings** for deeper investigation or automation. These advanced CloudWatch features enhance observability, enabling **proactive monitoring, efficient troubleshooting, and automated actions** based on real-time system insights. --- # Log Monitoring & Analysis using AWS CloudWatch ### **Setting Up Logs and Metric Filters** #### **Log Collection and Aggregation in CloudWatch** CloudWatch **Logs** enables you to collect, store, and analyze logs from AWS services like **EC2, Lambda, RDS, API Gateway**, and even on-premises applications. #### **How to Set Up Log Collection in CloudWatch** 1. **Enable CloudWatch Logs for AWS Services:** - For **EC2 Instances**: Install and configure the **CloudWatch Agent** to collect logs. - For **AWS Lambda**: Logs are automatically sent to CloudWatch Logs. - For **Custom Applications**: Use the **AWS SDK or CloudWatch Logs API** to send logs. 2. **Create a Log Group & Log Stream:** - A **Log Group** organizes logs for a specific application or resource. - A **Log Stream** stores log events generated by a particular instance or function. 3. **Define Retention Policies** to control log storage duration. --- ### **Creating Custom CloudWatch Metrics Using Log Data** CloudWatch **Metric Filters** allow you to extract specific data from logs and convert them into CloudWatch metrics for real-time monitoring. #### **Steps to Create a Metric Filter in CloudWatch** 1. **Navigate to CloudWatch Logs** in the AWS console. 2. **Select the Log Group** where you want to extract metrics. 3. **Create a Metric Filter** and define a pattern to match log events. - Example: Extract HTTP 500 errors from web server logs. ``` { $.statusCode = 500 } ``` 4. **Map the filter to a CloudWatch metric** to track occurrences. 5. **Use CloudWatch Dashboards** to visualize custom metrics. --- ### **CloudWatch Alarms for Logs** CloudWatch Alarms enable **proactive monitoring** by sending notifications or triggering actions when a specific log pattern or threshold is met. #### **How to Set Up CloudWatch Alarms for Logs** 1. **Go to CloudWatch Alarms** in the AWS console. 2. **Create a new alarm** and select the metric derived from log data. 3. **Define alarm conditions:** - Example: Trigger an alarm if HTTP 500 errors exceed 10 per minute. 4. **Set up actions** such as sending notifications via **Amazon SNS** or triggering AWS Lambda for automated responses. 5. **Monitor and respond** to alerts in real-time. CloudWatch Logs and Alarms **improve observability, help troubleshoot issues, and ensure application reliability** by providing actionable insights from log data. --- # Integration of AWS CloudWatch with Various Services ### **CloudTrail Integration with CloudWatch** AWS **CloudTrail** captures API activity across your AWS account, recording user actions and resource changes. **Integrating CloudTrail with CloudWatch** helps in **real-time monitoring and compliance tracking**. #### **Steps to Integrate CloudTrail with CloudWatch** 1. **Enable CloudTrail Logging** for API activity. 2. **Create a CloudWatch Log Group** to store CloudTrail logs. 3. **Configure CloudTrail to send logs to CloudWatch** using a Log Stream. 4. **Set up Metric Filters** to monitor key security-related events. - Example: Detect unauthorized access attempts. ``` { $.eventName = "UnauthorizedOperation" } ``` 5. **Create CloudWatch Alarms** for security-critical actions like unauthorized API calls or root account logins. --- ### **Lambda Integration with CloudWatch** AWS **Lambda** generates logs and performance metrics that CloudWatch can track to analyze execution time, errors, and resource usage. #### **Key CloudWatch Metrics for Lambda** - **Invocations** – Number of times a Lambda function is executed. - **Duration** – Execution time of the function. - **Error Rate** – Count of function failures. - **Throttles** – Number of times execution was throttled due to concurrency limits. #### **Steps to Monitor Lambda with CloudWatch** 1. **Enable CloudWatch Logs** for Lambda functions. 2. **View Lambda Metrics** in the CloudWatch dashboard. 3. **Set CloudWatch Alarms** for performance issues, such as high execution duration. --- ### **VPC Flow Logs Integration with CloudWatch** VPC Flow Logs capture network traffic data and can be stored in CloudWatch for **real-time traffic monitoring and anomaly detection**. #### **Steps to Integrate VPC Flow Logs with CloudWatch** ## Steps to Configure VPC Flow Logs with Amazon CloudWatch Logs ### **1. Navigate to the VPC Dashboard** - Go to the **AWS Management Console** - Open the **Amazon VPC** service - In the left-hand menu, select **“Your VPCs”**, **“Subnets”**, or **“Network Interfaces”** based on what you want to monitor - Select the desired resource (VPC, Subnet, or ENI) ### **2. Create a New Flow Log** - Click on the **“Actions”** dropdown - Select **“Create flow log”** ### **3. Specify Flow Log Settings** - **Filter:** Choose the type of traffic to log: - `All` – logs all traffic - `Accept` – logs only accepted traffic - `Reject` – logs only rejected traffic - **Maximum Aggregation Interval:** Choose: - `10 minutes` (default) - `1 minute` (more granular but higher cost) ### **4. Set Destination to CloudWatch Logs** - **Destination:** Select **Send to CloudWatch Logs** - **Log Group:** - Choose an existing CloudWatch **Log Group** - Or create a new one (e.g., `/vpc/flowlogs`) - **IAM Role:** - Select an existing IAM role with permission to publish to CloudWatch Logs - Or create a new one from the console: - Click on **“Set permissions”** - Choose **“Create new role”** - AWS will automatically attach the necessary policies (e.g., `AWSVPCFlowLogs` managed policy) ### **5. Review and Create** - Review all settings - Click **“Create flow log”** ### **6. Verify Log Stream in CloudWatch Logs** - Go to **Amazon CloudWatch > Logs** - Open the specified **Log Group** - You will see **log streams** created for each ENI - Open a stream to inspect raw VPC flow log records ### **7. (Optional) Add Metric Filters and Alarms** - In **CloudWatch Logs**, create **metric filters** for specific patterns (e.g., rejected traffic) - Create **CloudWatch Alarms** to get notified when thresholds are exceeded ### **Key Notes** - Flow logs capture metadata about traffic, not the content of the packets - IAM role must have `logs:PutLogEvents` and `logs:CreateLogStream` permissions - Logs are delivered with some delay; not real-time but near real-time ### **IAM Policy Example (if creating manually)** ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogGroups", "logs:DescribeLogStreams" ], "Resource": "*" } ] } ``` --- ### **RDS Monitoring with CloudWatch** CloudWatch provides **database performance metrics** for **Amazon RDS** to track read/write operations, connections, and resource utilization. #### **Key RDS Metrics in CloudWatch** - **CPUUtilization** – Tracks CPU usage. - **DatabaseConnections** – Monitors active connections. - **FreeStorageSpace** – Ensures storage capacity does not run out. - **ReadIOPS/WriteIOPS** – Measures database read and write performance. #### **Steps to Monitor RDS with CloudWatch** 1. **Enable Enhanced Monitoring** for detailed RDS metrics. 2. **View Metrics in CloudWatch** to analyze database performance. 3. **Create Alarms for Critical Metrics**, such as high CPU utilization or low storage space. CloudWatch’s integration with these AWS services enhances **monitoring, security, and operational efficiency**, helping identify issues proactively. --- # Understanding CloudWatch Event and EventBridge ### **What is Amazon EventBridge?** Amazon **EventBridge** (previously known as CloudWatch Events) is a **serverless event bus** that helps in routing events from AWS services and third-party applications to targets such as Lambda, SQS, or Step Functions. It enables automation and real-time event-driven applications. --- ### **How CloudWatch Events Relate to EventBridge** - **CloudWatch Events** was the original AWS service for event-driven automation. - AWS **rebranded and enhanced it** into **EventBridge** to support a broader range of integrations, including third-party applications. - **EventBridge extends CloudWatch Events** by adding features like schema discovery and cross-account event sharing. --- ### **Scheduling Cron Jobs with EventBridge** EventBridge allows scheduling **automated recurring tasks** using **cron expressions** or **rate expressions**. #### **Common Use Cases for Scheduled Events** - **Automating Backups** – Trigger AWS Backup or S3 replication. - **EC2 Auto Scaling** – Start/stop instances at specific times to save costs. - **Log Cleanup** – Automatically delete old CloudWatch logs to optimize storage. --- ### **How to Create a Scheduled Event with EventBridge** Amazon EventBridge allows you to create scheduled events using CRON expressions, similar to traditional CRON jobs in Linux. These schedules can trigger targets such as AWS Lambda, Step Functions, EC2 actions, or SNS topics, enabling automated workflows. #### **Step 1: Navigate to EventBridge** 1. Open the **AWS Management Console**. 2. Go to **Amazon EventBridge** → **Rules**. 3. Click **Create rule**. #### **Step 2: Define Rule Details** - **Rule name** – Provide a meaningful name (e.g., `daily-log-cleanup`). - **Rule type** – Choose **"Schedule"**. #### **Step 3: Define the Schedule Pattern** AWS supports two types of schedules: 1. **Rate Expression** (Runs at a fixed interval) ``` rate(5 minutes) # Runs every 5 minutes rate(1 hour) # Runs every hour rate(1 day) # Runs once per day ``` 2. **Cron Expression** (Runs at a specific time) ``` cron(0 12 * * ? *) # Runs every day at 12:00 PM UTC cron(30 22 * * 1 *) # Runs every Monday at 10:30 PM UTC ``` #### **Step 4: Select Target for the Event** - **Amazon Lambda** – Run a function (e.g., start an EC2 instance). - **Amazon SQS** – Send messages to a queue. - **Step Functions** – Orchestrate workflows. - **AWS Backup** – Automate snapshots of resources. #### **Step 5: Configure Permissions** - Ensure the **EventBridge rule has permissions** to invoke the target service. - IAM roles should allow `events.amazonaws.com` to trigger the service. #### **Step 6: Review and Create Rule** - Verify all configurations and click **Create Rule**. ## CRON Job vs EventBridge Schedule | Feature | CRON Job (Linux) | EventBridge Scheduled Rule | |------------------------|--------------------------------------------|-----------------------------------------------| | **Platform** | Runs on on-premises or EC2 Linux servers | Fully managed AWS service | | **Trigger Target** | Executes shell commands or scripts | Triggers AWS services (Lambda, EC2, etc.) | | **Timezone** | Uses local system timezone | Uses UTC by default | | **Syntax Format** | 5 fields (`min hour dom month dow`) | 6 fields (`min hour dom month dow year`) | | **Management** | Requires system-level configuration | Configured via AWS Console, CLI, or SDK | | **Monitoring** | Manual log setup required | Integrated with CloudWatch for logs/metrics | | **Scaling** | Not scalable without manual intervention | Automatically scales with target service | | **Reliability** | Depends on system uptime and maintenance | High availability and fault-tolerant | | **Security** | Managed at OS level | IAM-based permissions and fine-grained access | | **Use Case** | Local task automation | Cloud-native task automation and orchestration | --- ### **Example Use Case: Auto-Stop EC2 Instances at Night** Scenario: Stop non-production EC2 instances at 7 PM daily to reduce costs. **Cron Expression:** ``` cron(0 19 * * ? *) # Runs every day at 7:00 PM UTC ``` **Target:** AWS Lambda function that stops EC2 instances. #### **Lambda Function to Stop EC2 Instances** ```python import boto3 def lambda_handler(event, context): ec2 = boto3.client('ec2') response = ec2.stop_instances(InstanceIds=['i-xxxxxxxxxxxx']) print("Stopping instances:", response) ``` EventBridge makes it easy to **automate cloud operations** without requiring manual intervention, improving efficiency and cost optimization. --- ## **Advanced Concepts – Good to Know** ### **Service Map and Transaction Search** #### **Service Map** - A **visual representation** of how different services in your application interact with each other. - Helps **identify dependencies** between AWS resources such as EC2, Lambda, API Gateway, and databases. - Used for **troubleshooting** latency issues, failed transactions, and misconfigured services. - **AWS X-Ray Service Map** provides an interactive visualization of how requests flow through your application. **Benefits:** - Quickly **detect performance bottlenecks** and troubleshoot slow API responses. - Understand the **architecture and dependencies** of a microservices-based system. - Helps in **optimizing service-to-service communication** for better performance. --- #### **Transaction Search** - Allows **filtering and analyzing** transactions across distributed applications. - Helps in identifying **which request paths** are slow or causing failures. - Useful for **tracing an individual request** across multiple services. **Example Use Case:** - In a **shopping cart application**, you can track a transaction from a user adding a product to checkout completion. - If a request takes longer than expected, **Transaction Search** helps pinpoint which microservice caused the delay. --- ### **Service Level Objectives (SLO) and Synthetics Canaries** #### **Service Level Objectives (SLOs)** - **SLOs** define performance targets based on **Service Level Indicators (SLIs)** such as response time, error rate, or availability. - Helps businesses measure **how reliable** their applications are in meeting customer expectations. - Example: - **SLO Target:** API response time should be **below 500ms** for 99.9% of requests. - **SLA (Service Level Agreement):** If response time exceeds 500ms in 1% of requests, **users may get compensation**. **Key Metrics Monitored for SLOs:** - **Latency** (Response Time) - **Availability** (% Uptime) - **Error Rate** (5xx errors, request failures) - **Throughput** (Requests per second) --- #### **Synthetics Canaries** - **Simulated automated tests** that mimic real user interactions with an application. - Helps ensure that critical workflows (such as login, checkout, or API requests) **work as expected**. - Uses **Amazon CloudWatch Synthetics** to test applications **before customers face an issue**. **Example Use Case:** - A Synthetics Canary runs a **scripted test** every 5 minutes to check if an API is responding within **200ms**. - If the test **fails**, an **alert is triggered** before users are affected. --- ### **Real User Monitoring (RUM)** #### **What is Real User Monitoring?** - **RUM** is a technique to monitor **actual end-user interactions** with a web application. - Helps analyze: - Page load time - User experience across different devices - JavaScript errors affecting performance #### **AWS Tool for RUM:** - **Amazon CloudWatch RUM** helps developers measure how fast webpages load and where **latency issues** exist. **Key Benefits of RUM:** - **Detect slow-loading pages** and optimize frontend performance. - **Identify geographical performance differences** (e.g., users in one region experiencing more latency). - **Track JavaScript errors** that may impact the user experience. **Example Use Case:** - If users in **Europe** experience slow page loads, RUM can help pinpoint whether the issue is related to **CDN configuration, backend API response time, or network latency**. --- # **Q&A** ### **Advanced Concepts in CloudWatch** **Q1: What is the purpose of the CloudWatch Agent, and how does it help in monitoring?** **A:** The CloudWatch Agent collects system metrics (CPU, memory, disk usage) and application logs from EC2 instances, on-premise servers, and containers, providing deeper visibility beyond default CloudWatch metrics. **Q2: What is CloudWatch Contributor Insights, and how does it improve log analysis?** **A:** CloudWatch Contributor Insights helps identify the top contributors to high latency, errors, or traffic spikes by analyzing structured log data. It is useful for troubleshooting performance bottlenecks. **Q3: How does CloudWatch Logs Insights help in analyzing logs?** **A:** CloudWatch Logs Insights provides a powerful query language to filter, aggregate, and analyze logs, making it easier to troubleshoot issues and extract meaningful insights from large log datasets. --- ### **Log Monitoring & Analysis using AWS CloudWatch** **Q4: How can CloudWatch Metric Filters be used for log monitoring?** **A:** Metric Filters allow you to extract and convert specific log patterns into CloudWatch metrics, enabling real-time tracking of custom application events such as error counts or authentication failures. **Q5: What is the benefit of setting up CloudWatch Alarms for logs?** **A:** CloudWatch Alarms notify users when a specific log pattern or threshold (e.g., “error” count exceeding 5 in a minute) is detected, allowing proactive response to potential issues. --- ### **Integration of AWS CloudWatch with Various Services** **Q6: How does AWS CloudWatch integrate with AWS CloudTrail?** **A:** CloudWatch can track CloudTrail logs to monitor API activity, detect security threats, and generate alerts for suspicious actions, ensuring compliance and security monitoring. **Q7: How does CloudWatch help in monitoring AWS Lambda functions?** **A:** CloudWatch provides Lambda execution metrics (invocation count, duration, error rate) and logs function execution details, helping in debugging and performance optimization. **Q8: Why would you use VPC Flow Logs with CloudWatch?** **A:** VPC Flow Logs help monitor network traffic patterns, detect unauthorized access attempts, and troubleshoot connectivity issues by analyzing flow log data in CloudWatch. **Q9: How can CloudWatch assist in RDS database performance monitoring?** **A:** CloudWatch provides key RDS metrics such as CPU utilization, connection count, read/write latency, and disk space usage, allowing proactive database performance tuning. --- ### **Understanding AWS CloudWatch Event (Now EventBridge)** **Q10: What is the purpose of Amazon EventBridge (formerly CloudWatch Events)?** **A:** EventBridge is an event bus service that routes events from AWS services or custom applications to targets such as Lambda, SQS, or Step Functions for automated workflows. **Q11: How can EventBridge be used to automate operational tasks?** **A:** EventBridge can trigger automated responses such as scaling EC2 instances, starting backups, or notifying administrators when specific AWS service events occur. **Q12: How do you schedule automated tasks using EventBridge?** **A:** EventBridge allows scheduling cron-based rules to trigger Lambda functions or EC2 actions at predefined intervals, such as daily report generation or log cleanups. --- ### **Overview of Application Signals** **Q13: What are Application Signals in AWS CloudWatch?** **A:** Application Signals refer to key performance indicators (KPIs) like request latency, error rates, and throughput that help assess an application's health and responsiveness. **Q14: How does Real User Monitoring (RUM) help in understanding user experience?** **A:** RUM collects performance data from real user sessions, tracking page load times, latency, and error rates to identify bottlenecks in the user experience. **Q15: Why are Service Level Objectives (SLOs) important in CloudWatch monitoring?** **A:** SLOs define performance and availability targets (e.g., 99.9% uptime) to ensure applications meet reliability expectations and trigger alerts when thresholds are breached. --- ### **Open Q&A Session** Now, the floor is open for any questions related to CloudWatch, observability, and integration with AWS services. Feel free to ask for clarifications or discuss real-world use cases. --- # MCQ **Q1: Which of the following is used to measure custom metrics in AWS CloudWatch?** - a) CloudWatch Logs - **b) CloudWatch Metrics** - c) CloudWatch Dashboards - d) CloudWatch Events **Q2: What is the purpose of AWS CloudWatch Contributor Insights?** - a) To monitor network traffic in real-time - **b) To identify contributors to latency or errors in your application** - c) To view API calls made through CloudTrail - d) To monitor Lambda function logs **Q3: Which AWS service allows you to automate tasks based on events in your AWS environment?** - **a) AWS EventBridge (CloudWatch Events)** - b) AWS CloudTrail - c) AWS Lambda - d) AWS X-Ray **Q4: What can be monitored using AWS Real User Monitoring (RUM)?** - a) Server resource utilization - **b) User interactions and their experience with the application** - c) API call latency - d) System logs **Q5: What is a key benefit of AWS Synthetics Canaries?** - a) Predicting AWS service costs - **b) Monitoring the performance and availability of your application** - c) Running backups automatically - d) Scaling EC2 instances automatically --- # Scenario based Questions ## **Scenario 1: Monitoring Lambda Performance with CloudWatch** ### **Problem Statement:** You have an AWS Lambda function that handles user uploads for a web application. You need to monitor its performance and error rates and set up automatic alerts if the error rate exceeds a threshold. ### **Step-by-Step Solution:** 1. **Enable CloudWatch Logs for Lambda:** - Navigate to AWS Lambda in the AWS Management Console. - Configure logging by enabling CloudWatch Logs for the Lambda function. 2. **Capture Invocation Details:** - CloudWatch Logs will record execution details, including success and failure events. 3. **Create CloudWatch Metrics:** - Define custom CloudWatch Metrics based on Lambda function invocations, success rates, and error rates. 4. **Set Up CloudWatch Alarms:** - Define a threshold for error rate (e.g., if errors exceed 5% of total invocations). - Configure CloudWatch Alarms to notify administrators via SNS when the threshold is breached. --- ## **Scenario 2: Automating EC2 Health Checks and Scaling** ### **Problem Statement:** You need to ensure that your EC2 instance is healthy and automatically scale when CPU utilization crosses 80%. Additionally, you need to set up a cron job to run backups every night. ### **Step-by-Step Solution:** 1. **Monitor EC2 Health and Performance:** - Enable CloudWatch Logs to track EC2 instance health, system logs, and application logs. 2. **Set Up CloudWatch Alarms for Auto Scaling:** - Configure CloudWatch Metrics to track CPU utilization. - Create a CloudWatch Alarm that triggers Auto Scaling when CPU utilization exceeds 80%. - Attach the alarm to an Auto Scaling policy that launches additional instances when needed. 3. **Schedule Nightly Backups with EventBridge (CloudWatch Events):** - Navigate to AWS EventBridge. - Create a scheduled rule using cron expressions (e.g., `0 2 * * *` for a nightly backup at 2 AM). 4. **Trigger Backup Using AWS Lambda:** - Integrate AWS Lambda with EventBridge to execute backup scripts automatically. - Store backups in Amazon S3 or another storage solution for redundancy. ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully