Query Details
**Hunting OneOnOne chats by Domains**
The following KQL query helps detect domains interacting with OneOnOne Teams Chats in your tenant, and allows to whitelist trusted or known domains while flagging suspicious ones.
```
CloudAppEvents
| where Application has "Microsoft Teams" and isnotempty(IPAddress)
| extend Geo_IP = tostring(geo_info_from_ip_address(IPAddress).country)
| extend ChatName = todynamic(RawEventData).ChatName
| extend TeamName = todynamic(RawEventData).TeamName
| extend ChannelName = todynamic(RawEventData).ChannelName
| extend Operation = todynamic(RawEventData).Operation
| extend CommunicationType = todynamic(RawEventData).CommunicationType
| where Operation has "ChatCreated" and CommunicationType has "OneOnOne"
| mv-expand ParticipantsInfo = (todynamic(parse_json(RawEventData).ParticipantInfo))
| mv-expand ParticipatingDomains = (ParticipantsInfo).ParticipatingDomains
| mv-expand ParticipatingSIPDomains = (ParticipantsInfo).ParticipatingSIPDomains
| mv-expand ParticipatingSIPDomains = (ParticipatingSIPDomains).DomainName
| where Operation has "ChatCreated" and CommunicationType has "OneOnOne"
| where (ParticipatingDomains!="" or ParticipatingSIPDomains!="") and (ParticipatingDomains !in ("microsoft.com") or ParticipatingSIPDomains !in ("microsoft.com"))
| project AccountDisplayName,ChatCreatedFrom= IPAddress,ChannelName,ChatName, TeamName,Geo_IP, CountryCode,Operation,ParticipatingSIPDomains,ParticipatingDomains, ISP
```
This KQL (Kusto Query Language) query is designed to monitor and analyze interactions with One-on-One chats in Microsoft Teams within a specific tenant. Here's a simplified breakdown of what the query does:
Data Source: It starts by looking at events from the CloudAppEvents table, specifically those related to Microsoft Teams that have an associated IP address.
Extracting Information: The query extracts various pieces of information from the raw event data, such as:
Geo_IP).Filtering:
Output: The query projects (selects) specific fields to display, including:
In summary, this query is used to identify and flag potentially suspicious domains interacting with one-on-one Teams chats, while allowing known and trusted domains (like "microsoft.com") to be whitelisted. This helps in monitoring and securing communication within the organization.

Sergio Albea
Released: March 5, 2025
Tables
Keywords
Operators