Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add SkyWalking+SkyApm-dotnet distributed Link tracking system in Micro Service Framework Demo.MicroServer

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to add SkyWalking+SkyApm-dotnet distributed link tracking system to the micro-service framework Demo.MicroServer. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Code address:

GitHub address: https://github.com/PeyShine/Demo.MicroServer

There are many Apm monitoring tools, and here we choose a Skywalking that is more popular on the Internet.

Skywalking is an application performance monitoring (APM) system. Skywalking is divided into server Oap, management interface UI, and probe Agent embedded in the program. Probably the work flow is to add probes in the program to collect all kinds of data and send them to the server for storage, and then you can see all kinds of collected monitoring data in the UI interface to complete its core mission: performance monitoring and distributed call chain tracking. The following picture is an official picture of skywalking, which can also illustrate the relationship between the three.

1. Installation of server side (OAP) and interface (UI)

Here, a version 6.6.0 zip file is downloaded directly from the apache address: http://skywalking.apache.org/downloads/. As it was previously installed on the local windows, it is found that there are two startup files in the installation package: startup.bat and startup.sh, which are used for startup on window and linux startup respectively. Here I upload the previously downloaded files directly to linux for installation.

After uploading and unzipping, you will get several files with the following screenshots

Go to the config configuration directory and there is a file called application.yml

Edit this configuration file, vim application.yml

We go directly to the data storage part, that is, the node storage, and there are also instructions in the official documentation. For quick start, the configuration file defaults to H2 storage, but it is recommended to use ElasticSearch storage. Because I have installed Exceptionless before, elasticsearch has been installed on this machine (if it is not installed, you can find it online, there are many articles about this), so I will comment out the H2 part here. Then release part of the elasticsearch and modify the two configuration files in the red box:

NameSpace: ${SW_NAMESPACE: "exceptionless"} clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9300}

It should be noted that the first SW_NAMESPACE needs to be the same as the cluster_name name configured by ElasticSearch

Starting skywalking takes up four ports: 8080 apollo,8080ui 10800, 11800, and 12800. Since the port I installed on this machine has already been occupied, I have to modify port 8080 used by the UI interface before I can start it.

Start modifying port 8080 used by the UI interface (if your port 8080 is not occupied, you can skip it and do not need to modify it)

Go back to the next level of the configuration directory: cd..

You can see a folder of webapp

Enter this directory: cd webapp/

Then modify the webapp.yml file

Here I change the port under the original server interface from 8080 to 8088, and then save it.

After the configuration file is modified, start the skywalking server and UI interface, and put the startup script in the directory: apache-skywalking-apm-bin/bin

It is mentioned above that startup.bat and startup.sh are used to start on windows and linux respectively. / startup.sh is used here

After the startup command execution is completed, you can see the prompt that the OAP and Web projects started successfully, which is what we call the server and the UI interface.

Verify that the interface is accessed through the configured ip+8088 port (default 8080 if not modified), as shown in the figure:

Now that we have finished our preparation, let's install a probe in the program to collect data.

two。 Install probe (Agent) to collect data

Because Skywalking itself is written in java, the SkyApm-dotnet project is a probe specially developed for .NET, which currently supports ASP.NET Core and ASP.NET. Let's integrate SkyApm-dotnet non-intrusively into the microservice project implemented by .net Core.

Step 1: use the following command to install Agent, which is said to be run as an administrator

Dotnet tool install-g SkyAPM.DotNet.CLI

Step 2: add environment variables, which can be set directly by adding the following code to the launchSettings.json file

"environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore", "SKYWALKING__SERVICENAME": "Demo.MicroServer.UserService"}

Step 3: install NuGet package: SkyAPM.Agent.AspNetCore in the program

Step 4: use the following command to generate the configuration file for skyapm.json under the application root directory, replace [service name] with the name of the service, and [server] with the counter ip installed by Skywalking.

Dotnet skyapm config [service name] [server]: 11800

After the execution is completed, you can see that a skyapm.json file has been generated under the directory. Copy its properties to the output directory and set it to copy if newer. I am testing here in an instance of the micro-service framework published on github. All the code has been uploaded. You can get the code through the Github address at the beginning of the article (welcome star).

3. Collect data and view

Call a few interfaces randomly in Swagger to test the data collection, and then go to the UI interface to view the data.

If the process goes smoothly, you can see that all the data have been collected.

The above content is how to add SkyWalking+SkyApm-dotnet distributed link tracking system to the micro-service framework Demo.MicroServer. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report