This is a quick post to share a useful KQL query for Azure Firewalls that I’ve been using. It’s based on the default Firewall query from Microsoft, but with some added variables to allow for a more focused analysis of source and destination traffic. I’m putting it here for my future reference and in case it’s helpful for anyone else.
Azure Firewall Query with Variables
This query allows you to analyze Azure Firewall logs, focusing on specific source and destination IP addresses within a defined time range. It’s particularly useful for troubleshooting and security analysis.
|
|
Key Features of the Query
- Variable Declarations: The query starts with variables for time range, source IP, target IP, and result limit. This makes it easy to customize without changing the main query logic.
- Log Filtering: It focuses on Azure Firewall Network and Application rules.
- Data Parsing: The query uses a series of
parse
andextend
operations to extract structured information from the log messages. - Field Extraction: Important fields like Protocol, Source/Target IP and Port, URL, Action, and various rule details are extracted.
- Custom Filtering: The query filters results based on the specified source and target IP addresses.
How to Use This Query
- Adjust the
timeAgo
,sourceIP
,targetIP
, andtheLimit
variables at the beginning of the query to suit your needs. - Run the query in your Azure Log Analytics workspace.
- The results will show you detailed information about firewall actions, including source and destination details, protocols used, and the specific rules applied.
Wrapping Up
This query has been a handy tool for me when working with Azure Firewall logs. It’s particularly useful for:
- Troubleshooting connectivity issues between specific hosts
- Investigating potential security incidents
- Auditing Firewall Rule Effectiveness
- Monitoring traffic patterns
Remember, this is just a starting point. Feel free to modify the query to better fit your specific needs. As you work more with Azure Firewall and KQL, you’ll probably come up with your own variations that work even better for your environment.
A few final thoughts:
- Keep an eye on performance, especially if you’re looking at a large time range or have a busy environment.
- Always test your queries, especially after making modifications.
- Don’t forget to update the placeholders (like
sourceIP
andtargetIP
) with actual values when you use this query.
Hopefully, this query will save future me, (👋 Hello again future Russ, and maybe you sometime when digging into Azure Firewall logs.
Happy querying!