How to profile the dotnetcore applications deployed in AKS(Azure Kubernetes Service) cluster?
Hi ,
I want to profile my dotnetcore application which is deployed in AKS cluster. I searched over the internet about it but did not found any solution. Please can you help me with the steps that how we can attach the application/Processes Id (deployed in AKS cluster ) and start profiling with dotMemory profiler.
Please sign in to leave a comment.
Hello,
Thank you for your interest in our products. We've investigated this possibility and posted an answer in a similar post.
Thanks Anna for your reply.
Can you please provide the the command for Windows based Container as well . In your above post the commands in every steps is linux based but I am using windows based dockerfile and container in my asp.netcore3.1 application. Really its very helpful to me if you provide those commands.
Thanks.
Hi Anna Guseva,
Waiting for your response.
Thanks.
Windows cmd doesn't provide the ability to install components from the command line without additional tools (e.g. powershell) as Linux does. Common Windows docker container doesn't contain powershell which could allow to do it.
You can download dotMemory.exe manually to the local folder and then copy it to the specific folder in your container.
After this, you can run dotMemory.exe in ENTRYPOINT section. dotMemory command line tool has similar arguments in Windows and Linux version. You can also use dotMemory.exe help <command> to get more options.
About attach case: you can't use bash script because it won't run on Windows. Besides, it's not obvious how to write a similar script to make it work in the basic windows command line.
You can try other ways, for example, write a c# application that will start your process, save its pid and then attach dotMemory to it with certain parameters; copy this app to the specific folder and insert as an ENTRYPOINT instead of a script. This application should exit only when the application with the saved pid exits.
This is just an idea, you can use your own solution if have any.
Thanks Anna for the quick response.
Not found any documentation on dotMemory with docker container. it would be very helpful if there is any documentation related to this.
Please help how to attach with the process id that running in container, and how we would save the snapshot in our local drive? Could you please also help with those command so that I can capture the snapshot in every 1 minute interval and save that snapshots in my local drive and open that snapshot by dotMemory standalone tool.
Thanks.
You can find information about dotMemory command line profiler in online help and in dotMemory clt help. The command line parameters are the same no matter where (local OS or docker) you run dotMemory clt.
Currently, dotMemory doesn't have "out of box" solution how to use it in Docker, Azure and other services. However, you can try to set up it yourself. I've described one of the possible use cases here and in the second post. This is still not a universal solution and may differ depending on your settings and how you use docker.
There is no solution to do it from command line in Windows container (unless you build it with a powershell). As I described above, you can create and use separate program to run your application and attach dotMemory to the process. This program must be started in container.
Since you're running dotmemory inside a container, it has access and saves file to the container's filesystem. You may try to find documentation how to set up your docker container to be able to save any data (not only dotMemory snapshot) to external storage or contact with Docker support team, probably they could suggest a solution. Currently, we can't say whether this is possible or not.
Here is the sample of command line where dotMemory attaches by PID and gets snapshot every 1 minute. dotMemory will detach from profiled process after 5 minutes and will save snapshot to the directory specified in --save-to-dir. You can specify any dir available from your docker container.
When snapshot is saved, you can copy it to your local machine in any available way e.g. via docker cp command.
Hi Anna Guseva/Team,
I used the command from above link to use the dotMemory profiler in docker container but getting below error.
apt-get is not recognized as a internal or external command.
My dockerfile is as below.
Can you please help me with this. How can we resolve this issue.
Thanks
Hi,
apt-get is Linux command-line tool for handling packages, it can't be used on Windows. As I mentioned here, Windows cmd doesn't provide the ability to install components from the command line without additional tools (e.g. powershell) as Linux does, but you can download package manually and copy dotMemory.exe from your local machine.