AWS SysOps Administrator Associate 2020
Triforce of Observability
CloudWatch is an umbrella service meaning
that is really a collection of monitoring tools
All CloudWatch Services Build Off of CloudWatch Logs
Cloudwatch logs is used to monitor, store and access your log file
CloudWatch is a centralized log management service
Most AWS Services are integrated with CloudWatch Logs
Logging of services sometimes need to be turned on or requires the IAM Permissions to write to CloudWatch Logs
A collection of logs stream, its common to name logs groupw wih the forware slash syntax
ex) /example/prod/app
A log stream represents a sequence of events from a application or instance being monitored
Represents a single event in a log file
Log events can be seen within a Log Stream
CloudWatch Logs Insights enables you to interactively search and analyze your CloudWatch log data and has the following advantages
CloudWatch Logs Insights support all types of logs
CloudWatch Insights has its own language called:
filter action="REJECT"
| stats count(*) as numRejections by srcAddr
| sort numRejections desc
| limit 20
When CloudWatch Insights read a logs, it will first analyzing the log events and try to structure the content by generating fields that you can then use in your query
CloudWatch Log Insights inserts the @ symbol at the start of fields that it generates
[5 system field will be automatically generated]
@message : the raw unparsed log event
@timestamp : the event timestamp contained in the log event's timestamp field
@ingestionTime : the time when the log event was received by CloudWatch Logs
@logStream : the name of the log stream that the log event was added to
@log : is a log group identifier in the form of account-id:log-group-name
CloudWatch Logs Insights automatically disovers fields in logs from AWS services such as:
A CloudWatch Metric represents a time-ordered set of data points
Its a variable that is monitored over time
ClodWatch comes with many predefined metrics that are generally name spaced by AWS Service
When an AWS Services emits data to CloudWatch the availability of the data varies based on the AWS Service
The CloudWatch Agent can be installed using AWS System Manager (SSM) Run Command onto the target EC2 instance
Install or uninstall a Distributor package.
Packages provided by AWS such as AmazonCloudWatchAgent (...) are also supported
You must attach CloudWatchAgentServerRole IAM role to the EC2 instance to be able to run the agent on the instance
Some metrics you might think are tracked by default for EC2 instances are not, and require installing the CloudWatch Agent
These are what you get without installing the Agent
These are what you get when installing the Agent
The CloudWatch Agent is also used to collect various logs from an EC2 instance and send them to a CloudWatch Log Group
You can publish your own CustomMetrics using the AWS CLI or SDK
aws cloudwatch put-metric-data \
--metric-name Enterprise-D \
--namespace Starfleet \
--unit Bytes \
--value 231213412
--dimensions HullIntegrity=100, Shield=70, Thrusters=maximum
High Resolution Metrics
When you publish a custom metric, you can define the resolution as either:
With High Resolution you can track in intervals of:
The CloudWatch Agent can send logs running on your EC2 instance to a CloudWatch Log Group
To send logs:
The Agent's configuration file is located at /etc/awslogs/awslogs.conf
[example_application_log]
log_group_name = /example/rails/logs/production
log_stream_name = {instance_id}
datetime_format = %Y-%m-%d%H:%M:%S.%f
file = /var/www/my-app/current/log/production.log*
You specify the location of the log file and what log group you want the log to be sent to
sudo service awslogsd stop
sudo service aws logsd start
What is an Event Bus?
EventBridge is a serverless event bus service that is usd for application integration by streaming real-time data to your application
EventBridge was formerly called Amazon CloudWatch Events
Hold event data, defined rules on an event bus to react to events
The top level fields listed here will always appear in every single event
The contents of fields appearing under detail will vary based on what AWS cloud service emits the event
{
"version": "0",
"id": "bfdc1220-60ff-44ad-bfa7-3b6e6ba3b2d0",
"detail-type": "CodeBuild Build State Change",
"source": "aws.codebuild",
"account": "123456789012",
"time": "2017-07-12T00:42:28Z",
"region": "us-east-1",
"resources": ["arn:aws:codebuild:us-east-1:123456789012:build/SampleProjectName:ed6aa685-0d76-41da-a7f5-6d8760f41f55"],
"detail": {
"build-status": "SUCCEEDED",
"project-name": "SampleProjectName",
"build-id": "arn:aws:codebuild:us-east-1:123456789012:build/SampleProjectName:ed6aa685-0d76-41da-a7f5-6d8760f41f55",
"current-phase": "COMPLETED",
"current-phase-context": "[]",
"version": "1"
}
}
You can create EventBridge Rules that trigger on a schedule
You can think of it as Serverless Cron Jobs
EventBridge supports cron expressions and rate expressions
+) Fine-Grained
Coarse-Grained
You specify up to five Targets for a single rule
Commonly targeted AWS Cloud Service:
You can specify what gets passed along by changing Configure Input
This acts as sort of filter
Match Events
The entire event pattern text is passed to the target when the rule is triggered (Just pass everything)
You can't use these as variable names (reserved by AWS)
EventBridge Schema Registry allows you to create, discover and manage OpenAPI Schema for events on EventBridge
+) What is a Shema?
A Schema is an outline, diagram, or model
Schemas are often used to describe the structure of different types of data
Why would you want a schema of the events int your EventBridge event bus?
A Code Binding is when the schema is wrapped in a programming Object
THis standarizes how to work with event data in code
Leading to fewer bugs and easier discovery of data
Not all AWS Services emit CloudWatch Event
For other AWS Services we can use CloudTrail
Turniging on CloudTrail allows EventBridge to track changes to AWS Services made by API calls or by AWS users
The Detail Type of CloudTrail will be called : "AWS API Call via CloudTrai"
AWS API call events that are larger than 256KB in size a re not supported
Event Patterns are used to filter what events should be used to pass along to a target
You can filter events by providing the same fields and values found in the original Events
A CloudWatch Alarm monitors a CloudWatch Metric based on a defined theshold
When alarm breaches (goes outside the defined threshold) than it changes state
Whe is changes state we can define what action it should trigger
Metric Alarm States
Then you define the condition of the alarm
Then you dfeind the threshold value
ex) You crate an CloudWatch because you want to avoid unexpected charges
You have may have reoccurring datapoints that breach a static threshold,
but this would not be considered "unusual behavior"
Using Statis Threshold Type would trigger the Alarm State and these would be false-positive
Using Anomaly detection, you can define a band as the thresdhold
Composite Alarm are alarm that watch other alarms
Using composite alarms can help you reduce alarm noise
Imagine you have 2 Alarms and you configure them to have no actions
CloudWatch Dashboards allows you to visualize your cloud Metrics in the form of various graphs
You create a widget, choose and configure a metric and add to your dashboard
CloudWatch ServiceLens gives you observability for your distributed applications by consolidating metrics, traces, logs, alarms into one unified dashboard
What is a distributed application?
Also known as a distributed system, is when network isolated services or applications that have to communicate over a network, together make a larger system/application
Applications that could be defined as distributed system generally utilize:
ServiceLens integrates CloudWatch with X-Ray to provide an end-to-end view of your application to help you efficiently
Service Map displays your service endpoints as nodes and highlights the traffic, latency, and errors for each node and its connections
To install and use Service Lens you need to
ServiceLens has 2 modes
ServiceLens lets us quickly filter trace information to open in X-Ray Analytics
Synthetics is used to test web-application by creating canaries to
+) What is a Canary?
Canaries are configurable scripts that run on a schedule to monitor your endpoints and APIs
Canaries mimic steps a real user would take so you can contiruously verify the customer experiencer
Canaries run on AWS lambdas using Node.js and Puppetteer
Puppeteer is a headless chrome browser and an automated testing framework
You can code Puppeteer to open a web-browser and click and enter information into a website
+) Headless means that there is no visible window. So you don't see the browser
Heart Beat Monitoring
API Canary
Supply API endpoint
Check if 200 is returned for success, anyting else is considered a failure
Broken Link Checker
It will log all the pages it was able to load or not load
Since Canaries use AWS Lambda it would just log to a CloudWatch Log group
GUI Workflow Builder
Container Insights collect, aggregates and summarizes information about your containers from metrics and logs
Continer Insights works with:
Container Insights can be filtered by
Contributor Insights allows you to view top contributors impacting the performance of your systems and application in real-time
Contributor Insights looks at your CloudWatch Logs and based on Insight rules you define shows real-time time-series data
AWS has a bund of sample rules you can use to get started