🕳️
The Cyber Security Library
  • The Library
  • Offensive Security
    • Solar, Exploiting log4j
      • Reconnaissance
      • Discovery
      • Proof of Concept
      • Exploitation
    • Basic Authentication Bypass
      • Username Enumeration
      • Brute Force
      • Logic Flaw
      • Cookie Tampering
    • Insekube
      • Recon with Nmap
      • Checking out the web address
      • Creating a Reverse shell
      • Inside the Kubernetes pod
      • CVE-2021-43798
    • Snort
      • What is Snort? (For the uninitiated)
      • Task exercise
      • Traffic Generator
      • Brief overview of IDS and IPS
      • Checking Snort
      • Snort Sniffer mode
      • Packet Logger mode
    • Runtime Detection Evasion
      • Learning Objectives of AMSI
      • Runtime detections
      • AMSI Overview
      • AMSI Instrumentation
      • Powershell Downgrade
      • Powershell Reflection
      • Patching AMSI
    • Red team recon using OSINT
      • Taxonomy of Reconnaissance
      • Built-in tools
      • Advanced Searching
      • Specialized Search Engines
  • Malware
    • Introduction to Malware Analysis
      • What are the different types of malware analysis
      • Doing different types of analysis
      • Anti analysis techniques
    • Ransomeware: Maze
    • Exploring Steganography
    • Simple Trojan with Python
      • The Python Trojan
      • Breaking down the python code
  • Vulnerability Management
    • Nessus
      • Introduction
      • Nessus Essentials
      • Scans
      • Authenticated Scans
      • Results
      • Running custom scans
  • Cloud
    • AWS
      • AWS CDK: Deploy and using amazon SQS Que from Repo
        • Node modules and Bootstrapping troubleshooting
        • Sending and Receiving information from the stack
        • Destroying the stack and cleaning up
      • Using Different AWS Services with Splunk
        • AWS Config
          • How Does Config work?
          • How to enable Config
          • Settings
          • Aggregation
          • Creating Config Resource
          • Creating Aggregator
          • Adding Rules
        • CloudTrail
          • What is CloudTrail?
          • Features of CloudTrail
          • Benefits of CloudTrail
          • CloudTrail Event History
          • Securing CloudTrail
        • EventBridge
          • Configuring EventBridge and Event Patterns
          • EventBridge Targets
        • CloudWatch
          • The CloudWatch Dashboard
            • Virtual Machine
          • CloudWatch Alarms and Metric Filters
            • Searching logs using metric filters
            • CloudWatch Alarms
          • CloudWatch CIS Alarms
            • SNS
        • Configuring VPC Flow Logs
          • An introduction to VPC flow logs
        • Automating Incident Response with EventBridge
          • Creating Lambda functions
        • CloudTrail SIEM Integration (Splunk)
          • AWS architecture for integrating with Splunk
      • AWS DevOps EBS Volumes
        • CloudWatch
        • EBS Volume
        • Lambda
      • EKS Creating a deployment with AWS in the command Line
        • Setting up AWS Cloud9
        • Creating a Cluster
        • Creating Deployment
      • How to CloudShell SSH in to ec2 Instances
    • Azure
      • Worker CTF (Azure DevOps)
        • Enumeration
        • Using SVN
        • Exploring the Domain
        • Cracking Azure DevOps console
      • Software development environments and Azure DevOps pipeline abuse
        • Accessing Azure Devops
        • Exploring Project Pages
  • Splunk
    • Splunk SIEM Integration
      • AWS architecture for integrating with Splunk
    • Splunk Threat Hunting Ep.6 Credential Access
  • DevOps
    • Using AWS, Docker, Jenkins and SonarQube to improve code quality
      • Updating the Cloud Instance and Getting Docker
      • Installing SonarQube
      • Creating Jenkins Server
      • Manaing SonarQube and Jenkins
    • Creating a Codebuild project and getting the output with CloudWatch Logs
      • IAM
      • CodeBuild
  • CTF's
    • THM Wonderland
      • Nmap and Gobuster
      • Entering Wonderland
      • Privilege Escalation
    • Healthcare OpenEMR system -THM Plotted EMR
      • Recon with Nmap
      • Exploring the ports found
      • Gobuster
      • Searchsploit Open emr
    • Steam Cloud CTF Exploiting Kubernetes
      • SteamCloud Privilege Escalation
    • THM Flatline CTF
      • Recon with Nmap
      • Searchsploit for freeswitch
      • Using the exploit
      • Escalating my privileges
      • Gaining access inside the Windows RDP
    • Biteme CTF
      • Recon
      • Looking into the PHP code and decoding hexadecimal
      • Python script and Bash script
      • Bruteforcing MFA Code
      • Trying to gain access via SSH
      • Inside SSH
      • Fail2ban Privilege Escalation
    • Devoops CTF
      • Enumeration
      • Exploiting Web Page
      • Creating Python exploit
    • GoBox CTF
      • Enumeration
      • Using Burpsuite and creating Reverse shell
    • Explore: Android Box
      • Enumeration
      • Initial foothold
      • Privilege escalation
Powered by GitBook
On this page
  • CloudWatch metric filters
  1. Cloud
  2. AWS
  3. Using Different AWS Services with Splunk
  4. CloudWatch

CloudWatch Alarms and Metric Filters

PreviousVirtual MachineNextSearching logs using metric filters

Last updated 1 year ago

CloudWatch allows you to search through the vast quantity of logs likely generated in your AWS account using metric filters. This can be especially useful when carrying out investigations into what has been happening in your environment. CloudWatch alarms let you automate notification when logs that match these filters occur, making the path to improving incident response that much quicker.

CloudWatch metric filters

Metric filters are one of the features of CloudWatch Logs. Metric filters tell CloudWatch to find log files that match a specific pattern and then publish numerical metrics when it detects matching logs. Once you've stored your logs in CloudWatch, metric filters allow you to automate observations to reduce the time it takes to search through them and generate data. You can apply filters at a log group level, meaning they apply to all log streams in that log group.

The syntax

The exact syntax for the metric filter depends upon the log files being put in the log group. You can use a simple text filter for all log types. For example, a filter ERROR will return all log files with the word ERROR in them (case-sensitive). If you want to match multiple terms, you can put them in the filter separated by spaces (the equivalent of and logic), and if you want to match exact phrases, you can put them in quotation marks.

we’ll be using logs forwarded by CloudTrail, which arrive as JSON log events. This allows us to use more precise string-based metric filters.

If we wanted to create a metric filter to find all events where a bucket was created, we can use the following metric syntax:

{$.eventName = CreateBucket}

When filtering JSON, curly braces always surround the pattern. To define the key we want to match with, we use $. and then specify the name of the key from the JSON.

We can handle nested values by adding keys to the filter pattern. For example, if we wanted to filter all events attributed to the user with the username Alice, we would use the following metric syntax:

{$.userIdentity.userName = Alice}

You can then use compound expressions to be more selective in your filter patterns. The and expression lets you specify that you want to match both patterns you’ve been given. To filter all events where the user Alice creates a bucket, we can use the following:

{$.eventName = CreateBucket && $.userIdentity.userName = Alice}

If you want the filter to look for one expression or the other, we can use the or operator. The following filter pattern will filter log events attributed to Alice, or where a user has created a bucket:

To add a metric filter to your log group, select it in the CloudWatch console and click on Create metric filter from the Actions drop-down menu.

You'll then be able to enter your filter pattern using the syntax discussed in the previous section. You can also use a test event log to see if it works as expected.

The next screen will take you through the configuration options for your metric filter. The namespace specifies where CloudWatch will store the metric. This is to ensure that similar metrics are kept together. The metric name will be what the metric is called within the namespace and should be unique.

The Metric value is what CloudWatch publishes when it finds logs that match the filter pattern. In this lab, we'll be using it to post a value of 1 every time it finds a matching log event. Other values can be used when you're directly monitoring values in the logs. For example, if you're monitoring specific IP addresses, you may want to publish the IP address for the metric. The default value is what CloudWatch publishes when it sees a log event that doesn’t match the pattern – we’ll be leaving this blank so that nothing gets published if the log file doesn’t fit.

{$.eventName = CreateBucket || $.userIdentity.userName = Alice} Other operators that can be used in metric filters are detailed in the .

CloudWatch documentation