Contours of Log Metric Filter on CloudTrail Log Group via Filter Patterned
Tags: aws, awscloudwatch, awscloudtrail, awssns
Published: 2024-03-09 18:20:40

“ I have checked the documents of AWS to get the solution for setup of log metric filter on cloudtrail log group so that whenever some config changes in any service we will be notified of the activity for it. In terms of cost, there is no charge for aws cloudwatch log metric filter feature but only need to pay for services integrated with it.”

Amazon Cloudwatch monitors your Amazon Web Services resources and the applications you run on AWS in real time. Amazon Cloudwatch logs to monitor, store and access your log files from Amazon Elastic Compute Cloud instances, AWS Cloudtrail, Route53 and other sources.

Cloudwatch logs enable you to centralize the logs from all of your systems, applications and AWS services that you use, in a single, highly scalable service. You can then easily view them, search them for specific error codes or patterns, filter them based on specific fields or archive them securely for future analysis.

A log stream is a sequence of log events that share the same source. Each separate source of logs in cloudwatch logs makes up a separate log stream. A log group is a group of log streams that share the same retention, monitoring and access control settings. You can define log groups and specify which streams to put into each group. There is no limit on the number of log streams that can belong to one log group.

In this post, you will experience how contours of log metric filter on cloudtrail log group via filter patterned . Here I have created a sns topic with subscription, cloudwatch log group, cloudwatch alarm, cloudwatch log metric filter and cloudtrail.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt82i82qzskbt7qr9cdd.png)
The architecture diagram shows the overall deployment architecture with data flow, aws cloudtrail, amazon cloudwatch, amazon sns and email.

#Solution overview
The blog post consists of the following phases:
1. Create of Log Metric Filter and Alarm on Cloudwatch Log Group 
2. Output as Changes in Cloudtrail Configuration via Alarm Notification on Email

##Phase 1: Create of Log Metric Filter and Alarm on Cloudwatch Log Group
1. Open the console of Cloudwatch, create a log metric filter on cloudtrail log group with required filter pattern. Also create an alarm on the metric filter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drchpss94hbsxiiz89ea.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1c5bspwpcw3na45xxzc9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xw162q05c8by06r8j6i9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3x0un95o0nnw1ot22x0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3i888hjv1muojr356yb.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlsms558qkt07jzsn3v1.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/faw13y9ikxw6qsq5pr76.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpvuyxjouzpskktffeic.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xmds1w0kvnlnwffmvhu6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpdbbbflaoeirizxwq2j.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4s39kfubn77iy8u56om2.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr35rtmd4o9k20935kkv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkv1obq9l08gskviexsc.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pr9v9ph1apm1l4szss8.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0nk603489ed6k05i86uo.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f2pv8k55gqzm14b8nbqe.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2lfdh4ouqbta6405zug.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fc4afpk2wo4r4y61puw.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpebmipyj41zt0k3lh36.png)

##Phase 2: Output as Changes in Cloudtrail Configuration via Alarm Notification on Email 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7dmqtnuydp1iwv4xtmi.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9w8nmwyko0g4b1pfd24.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fmv2vizv4d7abskib1t.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8neuny7xsr97q0qa1v9.png)

#Clean-up
Delete of Cloudtrail, Cloudwatch and SNS.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of Simple Notification Service = $0.0

Cost of CloudWatch = $0.02

Cost of Cloudtrail = $0.0

Total Cost = $0.02

#Summary
In this post, I showed “how to contours of log metric filter on cloudtrail log group via filter patterned”.

For more details on Amazon Cloudwatch, Checkout Get started Amazon Cloudwatch, open the [Amazon Cloudwatch console](https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#home:). To learn more, read the [Amazon Cloudwatch documentation](https://docs.aws.amazon.com/cloudwatch/?icmpid=docs_homepage_mgmtgov).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)