大网数据广告活动
域与目录服务

Filter Fiddler Traffic Using Domain Names and Client Processes

· 52CE 我爱测

Introduces how to filter traffic that's captured by Fiddler using domain/host names owned by Microsoft Entra and client processes.

This article explains how to filter traffic that's captured by Fiddler using domain/host names owned by Microsoft Entra and client processes.

Prerequisites

Before filtering, ensure that Fiddler is configured to capture traffic for all processes. In the lower-left corner of the Fiddler window, you can select All processes to change the selection.

:::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/all-processes.png" alt-text="Screenshot that shows the 'All processes' button.":::

Filter traffic using Fiddler's built-in filter feature

To filter traffic using Fiddler's built-in filter feature, follow these steps:

  1. Open Fiddler and navigate to the right panel.

  2. Select the Filters tab, and then select the Use Filters checkbox.

  3. Under the Hosts section, select Show only the following Hosts.

  4. In the text box, enter the host name list you want to filter on, separated by semicolons, for example, localhost;login.microsoftonline.com;graph.microsoft.com.

    [!NOTE] This text box will display a yellow background while editing the list, indicating unsaved changes.

  5. Select the Actions button to save the list. The background color will change to white, confirming the list is saved.

:::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/show-only-the-following-hosts.png" alt-text="Screenshot that shows how to filter traffic based on host names.":::

Under the Client Process section, you can also select a specific process to filter on. This is particularly useful for filtering a standalone application. It might be less effective for capturing browser traffic because multiple processes with the same name can make it difficult to identify the correct one.

Filter traffic using JavaScript code in the OnBeforeRequest function

Note: This option is used especially for browser-based applications.

  1. In Fiddler, go to Rules > Customize Rules. This action will open the CustomRules.js file in the FiddlerScript editor.

  2. Locate the OnBeforeRequest function in the FiddlerScript editor.

  3. Insert the following JavaScript code at the beginning of the function:

    // begin filter
    
    // set this to false to disable filter and true to enable filter
    var filterOn = true;
    
    if (filterOn)
    {
        // hide all requests by default
        oSession["ui-hide"] = "true";
        
        // list of domain names to filter on
        var host = ["localhost", "login.microsoftonline.com", "graph.microsoft.com"];
        
        // list of processes to filter on
        var processlist = ["chrome", "microsoftedgecp", "iisexpress", "powershell"];
    
        for (var j = 0; j < processlist.length; j++)
        {
            if (oSession.LocalProcess.Contains(processlist[j]))
            {
                for (var i = 0; i < host.length; i++)
                {
                    if (oSession.HostnameIs(host[i]))
                    {
                        oSession["ui-hide"] = null;
                    }
                }
            }
        }
    }
    
    // end filter
    

    :::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/add-javascript-code-onbeforerequest-function.png" alt-text="Screenshot that shows the JavaScript code added in the OnBeforeRequest function." lightbox="media/filter-fiddler-traffic-using-domain-name-client-process/add-javascript-code-onbeforerequest-function.png":::

    Here are the explanations of some variables in the JavaScript code:

    • filterOn: Set it to true to enable the filter and false to disable it.
    • host: Contains the list of domain names to filter on.
    • processlist: Contains the list of process names to filter on.
  4. Save the changes to the CustomRules.js file.

References

Third-party information disclaimer

The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 04/08/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。