Logging & Monitoring & Audit Flashcards
What is CloudWatch Metrics used for?
Provides metrics for every service in AWS
Metric is a time-stamped variable to monior, e.g. CPU, networking, etc.
Metrics belong to namespaces
Metrics have attributes called dimensions, e.g. instance id, environment
Up to 10 dimenions per metric
Metrics have timestamps
CloudWatch Dashboard can provide nice graphs of Metrics
What is CloudWatch Detailed Monitoring for EC2?
EC2 instances send metrics every 5 minutes, by default
Detailed Monitoring can be applied to get metrics every minute
Costs more, 10 in free tier
What are CLoudWatch Custom Metrics?
Possibility to define own custom metrics
Ability to segment them using dimensions
Metric Resolution: 1 minute, by default - 1 second, high resolution (StorageSolution Api parameter), costs more
to send a metric to CLoudWatch use API call PutMetricData
use exponential backoff in case of Throttle Errors
What are CloudWatch Alarms?
Alarms are triggered by pre-defined Metrics thresholds
Can trigger:
AutoScaling Actions
EC2 Actions
SNS Notifications
Alarm States: OK, INSUFFICIENT_DATA, ALARM
Period: Length of time to evaluate metric - high resolution custom metrics can only choose 10 or 30 seconds
What are CloudWatch Logs?
Applications can send logs to CloudWatch Logs
CloudWatch can collect logs from many services such as:
EC2 instances using the CloudWatch Logs Agent
ECS, logs from containers
Lambda, logs from functions
Beanstalk, app logs
VPC Flow Logs
Route53, DNS query logs
CloudWatch Logs can be sent to S3 for archieving or
Streamed to an ElasticSearch cluster for furhter analytics
What is the CloudWatch Logs Agent?
by default EC2 does not send any logs to CloudWatch (only Metrics)
The CloudWatch Agent has to run on the EC2 instance to send logs to CloudWatch
Needed permissions are required
Can also be set up for on-premises instances
CloudWatch Logs Agent vs. CloudWatch Unified Agent
Logs Agent:
old version
Can only send to CloudWatch Logs
Unified Agent:
Collects additional system-level Metrics, such as RAM, …
Sends logs to CloudWatch
Centralized configuration using SSM Parameter Store
What are CloudWatch Metric Filters?
CloudWatch Logs can use FIlter Expressions
count errors, find specific ip, trigger alarms
Filters do not retroactively filter data
Filter only publish the metric data points for events after the filter was created
WHat can you do with CloudWatch Events?
Schedule events, such as Cron Jobs
Event pattern: define event rules that are triggered by a aws service
Triggers to Lambda, SNS, Kinesis
Creates a JSON file to document the change that triggered the event
What is EventBridge?
An evolution of CloudWatch Events
Default Event Bus: generated by AWS services - cloudwatch events
Parnter Event Bus: receive events from SaaS or other apps (ZenDesk, Auth0)
Custom Event Bus: Create my own event bus
event busses can be accessed by other accounts
Rules: how to process the events
What is EventBridge Schema Registry?
EventBridge can analyze events from my bus and infer the schema
Schema Registry allows to generate code, that will know in advance how data is structured in the event bus
Schema can be versioned
EventBridge vs. Events
Eventbridge builds upon and extends Events
Eventbridge uses the same service api and endpoint
Eventbridge lets us add custom event busses and event busses from third parties
EventBridge has Schema Registry capability
What is AWS X-Ray?
Good to visualize dependencies and detect service issues in a microservice architecture
Compatible with:
ECS, EC2, Lambda, Beanstalk, ELB, GateWay
leverages Tracing:
How to enable X-Ray?
Application code must use the X-Ray SDK, correctly
Service running the instance must run the X-Ray Daemon or enable X-Ray integration - lambda and other services use the daemon by default
Each service requires permission to use interact with X-Ray
X-Ray Instrumentation and Concepts
Instrumentation is some useless garbage
Concepts:
Segments: Each app/service will send them
Subsegments: If more details are required in the segments
Trace: Segments collected together to form an end-to-end trace
Sampling: Decrease the amount of requests send to xray
Annotations: Key-Value pairs used to index traces and use with filters
Metadata: Key-Value paris not indexed, not used for searching
X-Ray daemon has a config to send traces cross-account