Net core link tracking skywalking installation and simple use tutorial

Time:2022-6-8

When we use many services, what is the calling relationship between the services? How about the monotonous sequence / time performance of each service? A service error occurred. Which service caused the error? What solutions can we use to solve these problems? In the past, each system made its own log. If there was a problem, it would be time-consuming and labor-consuming to start troubleshooting one by one from the service that broke the problem. Some logs are incomplete, and they may not be found out. Fortunately, there is a skywalking link tracking system, which can track the calling relationship and performance status between various services without writing any code.

This article will start from 0 to build two webapi projects, and use skywalking to track the call relationship and response time between them. The development environment is visualstudio2019

1.1. Installing skywalking

Installing skywalking will encounter many problems. First, the installation may not be successful. There will be many problems when accessing the 8080 port monitoring page. Even if the monitoring page is normal, the NETCORE program may not be able to monitor it, because the link 11800 will fail. Most of them are caused by problems with the skwwalking and elasticsearch versions. Because most storage options are elasticsearch, this is the main choice here. As shown below, install through docker compose.

The documents are as follows:


version: '3.3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
    container_name: elasticsearch
    restart: always
    ports:
      - 9200:9200
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  oap:
    image: apache/skywalking-oap-server:7.0.0-es7
    container_name: oap
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    restart: always
    ports:
      - 11800:11800
      - 12800:12800
    environment:
      SW_STORAGE: elasticsearch7
      SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
  ui:
    image: apache/skywalking-ui:7.0.0
    container_name: ui
    depends_on:
      - oap
    links:
      - oap
    restart: always
    ports:
      - 8080:8080
    environment:
      SW_OAP_ADDRESS: oap:12800

After installation, check whether the service is normal. The three programs are elastic, skwwalking, and skwwalkingui:

1.2 check whether the elastic and monitoring pages are normal

, the connection is to install the skwwalking server ip:9200 and install the skwwalking server ip:8080. If the port is occupied, replace it in advance:

2. go to the NETCORE program. Here, run two programs first

2.1. The first NETCORE program is added. This is net5.

2.2 installation dependency

SkyAPM. Agent. Aspnetcore, the best version I choose is 0.9.0. (it is necessary to ensure that the installation service is normal and the program monitoring is normal before upgrading other versions.)

2.3 add skyapm JSON file

Remember to copy the attribute to the output directory and set it to always copy to prevent the profile modification from stepping on the pit. The two things to note here are 1 Servicename should be the name of the current program, and services should be the skwwalking server ip:11800.

{
  "SkyWalking": {
    "ServiceName": "SkyWalkingDemo",
    "Namespace": "",
    "HeaderVersions": [
      "sw6"
    ],
    "Sampling": {
      "SamplePer3Secs": -1,
      "Percentage": -1.0
    },
    "Logging": {
      "Level": "Debug",
      "FilePath": "logs/skyapm-{Date}.log"
    },
    "Transport": {
      "Interval": 3000,
      "ProtocolVersion": "v6",
      "QueueSize": 30000,
      "BatchSize": 3000,
      "gRPC": {
        "Servers": "skywalking server ip:11800",
        "Timeout": 10000,
        "ConnectTimeout": 10000,
        "ReportTimeout": 600000
      }
    }
  }
}

2.4 program launchsettings json

Add a line “aspnetcore_hostingstartupassemblies”: “skyapm.agent.aspnetcore”. If IIS express is used for startup, it needs to be added to the IIS express configuration. As follows:

2.5 after running, the monitoring screen is as follows:

3 add another program

3.1 the procedure for creating a new program is the same as that in 2.1

The following settings will not be repeated. I have changed the startup address. The address of the second one after the first one is started cannot be the same. The procedure is as follows:

3.2 a controller is added here for testing

The code is as follows. What to do is clear:

3.3 the monitoring results are as follows:

Having said that, this is just a simple installation and demonstration. If there is a practical need, you need to do further research, because there are so many actual projects.

https://github.com/liuzhixin405

This is the end of this article about the installation and simple use of link tracking skywalking under net core. For more information about net core link tracking skywalking, please search the previous articles of developepaer or continue to browse the following articles. I hope you will support developepaer in the future!