DEV Community

Tsuyoshi Ushio
Tsuyoshi Ushio

Posted on

Using Fiddler for Application Insights codeless java agent with docker on WSL2

I'm working on Application Insights - Java codeless agent working on a docker container on WSL2. It works on the other guys machine, however, on my laptop, it sometimes work, most of the times, it doesn't work.

My colleague gave me an advice to use Fiddler. I use it for watching network requests that is coming from a docker container on WSL2.

Let's see how to configure it.

Strategy Overview

We are configure the Java Application Insights agent for proxying to the Fiddler. We need to answer these questions.

  • How to extract a root certificate from Fiddler and import it to JVM KeyStore on Docker. (I use zulu)
  • How to send request from WSL2 to Windows 10
  • How to configure Application Insights agent to proxy to the Fiddler.
  • Is there any other configuration required?

Export a root certificate from Fiddler

Go to Tools > Options > HTTPS > Actions then select Export Root Certificate to Desktop. Then move the file to WSL2 side.

Alt Text

From the wsl2 side I do this after the moving the file to Download.

$ mv /mnt/c/Users/tsushi/Download/FiddlerRoot.crt
Enter fullscreen mode Exit fullscreen mode

Import the certificate to the KeyStore on JVM

We can use keytool for import the certificate to the JVM KeyStore. In case of zulu, the KeyStore is /usr/lib/jvm/zre-8-azure-amd64/lib/security/cacerts by default. The default password of the KeyStore is changeit.

COPY FiddlerRoot.cer /
RUN /usr/lib/jvm/zre-8-azure-amd64/bin/keytool -import -noprompt -trustcacerts -alias FiddlerRoot -file /FiddlerRoot.cer -keystore /usr/lib/jvm/zre-8-azure-amd64/lib/security/cacerts -storepass changeit
Enter fullscreen mode Exit fullscreen mode

Configure Application Insights Codeless Agent for Proxy

Find IPAddress for accessing from WSL2 to Windows 10

To accessing from WSL2 to Windows 10, you can open Network Connection from your Type here to search box on your Windows 10.
You can find a network adopter vEthernet (WSL), Find the IP address. The IP Address is the address that is seen it as Windows10 from WSL2. In my case it is, 172.20.64.1.

Alt Text

You can find the Fiddler port number in here.

Alt Text

Configure the codeless agent

Configure the proxy section with the IP Address and port number. Then the Java codeless agent will send request to the proxy (Fiddler).

{
  "proxy":{
    "host": "172.20.64.1",
    "port": 8888
  },
  "selfDiagnostics": {
    "destination": "file+console",
    "level": "INFO",
    "file": {
      "path": "/var/log/applicationinsights/applicationinsights.log",
      "maxSizeMb":  5,
      "maxHistory": 1
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Configure Fiddler to accept the request from WSL2

Configure the Allow remote computers to connect From the Windows 10 Fiddler, WSL2 is different computer.

Alt Text

Start the Fiddler, and run the Docker container. You will find the two requests. These are the Application Insights telemetry.

  • rt.services.visualstudio.com
  • {location}-{number}.in.applicationinsights.azure.com

Resources

Top comments (0)