SkyWalking -- distributed application monitoring and link tracking

SkyWalking is an application performance monitoring system, especially designed for micro services, cloud native and container based (Docker, Kubernetes, Mesos) architecture. In addition to application index monitoring, it can also track distributed call links. Components with similar functions include Zipkin, Pinpoint, CAT, etc.

Take a few pictures to see the effect, and then build and use them step by step

1. Concept and structure

SkyWalking is an open source monitoring platform for collecting, analyzing, aggregating and visualizing data from services and cloud native infrastructure. SkyWalking provides an easy way to maintain a clear view of distributed systems, even across the cloud. It is a modern APM designed specifically for cloud native, container based distributed systems.  

SkyWalking monitors applications from three dimensions: service, service instance, and endpoint

Not much about services and instances. An endpoint is a path or URI in a service

SkyWalking allows users to understand the topology relationship between Services and Endpoints, to view the metrics of every Service/Service Instance/Endpoint and to set alarm rules.

SkyWalking allows users to understand the topological relationship between services and endpoints, view the metrics of each service / service instance / endpoint, and set alarm rules.

1.1. Structure


SkyWalking is logically divided into four parts: Probes, Platform backend, Storage and UI

This structure is very clear. The probe is the Agent, which is responsible for collecting data and reporting it to the server. The server processes and stores the data, and the UI is responsible for displaying it

2. Download and install

SkyWalking has two versions, ES version and non es version. If we decide to use ElasticSearch as storage, download the ES version.

The agent directory will be copied to the machine where each service is located as a probe in the future

The bin directory is the service startup script

The config directory is a configuration file

The oap LIBS directory is the jar package required for the operation of the oap service

The webapp directory is the jar package required for the operation of web services

Next, you need to select storage. The supported storage includes:

  • H2
  • ElasticSearch 6, 7
  • MySQL
  • TiDB
  • InfluxDB

As a monitoring system, H2 and MySQL are excluded first. Here we recommend InfluxDB, which is a time series database and is very suitable for this scenario

But I'm not very familiar with InfluxDB, so I'll use ElasticSearch7 first

2.1. Install ElasticSearch 

# start-up
./bin/elasticsearch -d -p pid
# stop it
pkill -F pid

ElasticSearch7.x requires Java 11 or above, but if you set the environment variable JAVA_HOME, it will use your own java version

Generally, the following three errors will be reported during startup:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured


In / etc / security / limits Add the following contents to the conf file:

* soft nofile 65536
* hard nofile 65536
* soft nproc  4096
* hard nproc  4096

You can view the modification results through the following four commands:

ulimit -Hn
ulimit -Sn
ulimit -Hu
ulimit -Su

Modify / etc / sysctl Conf file, add the following contents:


Modify es configuration file elasticsearch YML uncomment and keep one node

cluster.initial_master_nodes: ["node-1"]

In order to access ip:port mode, the network configuration needs to be modified

After modification, it is as follows:

So far, ElasticSearch has been started successfully

Next, in config / application Configure the es address in YML

  selector: ${SW_STORAGE:elasticsearch7}
    clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:}

2.2. Install Agent

Copy the agent directory to the machine where each service is located

scp -r ./agent chengjs@

Here, I copy it to each service directory

Plugins are various plug-ins used by probes. SkyWalking plug-ins are plug and play. You can put the plug-ins in optional plugins into plugins

Modify agent / config / agent Config configuration file, which can also be specified through command line parameters

It mainly configures the service name and back-end service address


Of course, it can also be set through environment variables or system attributes, for example:


Finally, when the service starts, use the command line parameter - javaagent to specify the probe

java -javaagent:/path/to/skywalking-agent/skywalking-agent.jar -jar yourApp.jar

For example:

java -javaagent:./agent/skywalking-agent.jar -Xms512m -Xmx1024m -jar demo-0.0.1-SNAPSHOT.jar

3. Start service

Modify webapp / webapp YML file, change the port number and back-end service address

  port: 8080

  path: /graphql
    ReadTimeout: 10000
    # Point to all backend's restHost:restPort, split by ,

Start service


Or start them in turn


Check the log file in the logs directory to see if it starts successfully

Browser access

4. Alarm


Edit alarm settings YML set alarm rules and notifications

Focus on the alarm notification


In order to use the nailing robot notification, next, create a new project

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
        <relativePath/> <!-- lookup parent from repository -->









Optional dependency (not recommended)


Define alarm message entity class

package com.wt.monitor.skywalking.alarm.domain;

import lombok.Data;


 * @author ChengJianSheng
 * @date 2020/12/1
public class AlarmMessageDTO implements Serializable {

    private int scopeId;

    private String scope;

     * Target scope entity name
    private String name;

    private String id0;

    private String id1;

    private String ruleName;

     * Alarm text message
    private String alarmMessage;

     * Alarm time measured in milliseconds
    private long startTime;


Send nail robot message

package com.wt.monitor.skywalking.alarm.service;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

 * @author ChengJianSheng
 * @data 2020/12/1
public class DingTalkAlarmService {

    private String webhook;
    private String secret;

    public void sendMessage(String content) {
        try {
            Long timestamp = System.currentTimeMillis();
            String stringToSign = timestamp + "\n" + secret;
            Mac mac = Mac.getInstance("HmacSHA256");
            mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
            byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
            String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8");

            String serverUrl = webhook + "&timestamp=" + timestamp + "&sign=" + sign;
            DingTalkClient client = new DefaultDingTalkClient(serverUrl);
            OapiRobotSendRequest request = new OapiRobotSendRequest();
            OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();

        } catch (ApiException e) {
            log.error(e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            log.error(e.getMessage(), e);
        } catch (UnsupportedEncodingException e) {
            log.error(e.getMessage(), e);
        } catch (InvalidKeyException e) {
            log.error(e.getMessage(), e);

package com.wt.monitor.skywalking.alarm.controller;

import com.wt.monitor.skywalking.alarm.domain.AlarmMessageDTO;
import com.wt.monitor.skywalking.alarm.service.DingTalkAlarmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.MessageFormat;
import java.util.List;

 * @author ChengJianSheng
 * @date 2020/12/1
public class AlarmController {

    private DingTalkAlarmService dingTalkAlarmService;

    public void alarm(@RequestBody List<AlarmMessageDTO> alarmMessageDTOList) {"Alarm information received: {}", JSON.toJSONString(alarmMessageDTOList));
       if (null != alarmMessageDTOList) {
           alarmMessageDTOList.forEach(e->dingTalkAlarmService.sendMessage(MessageFormat.format("-----come from SkyWalking Alarm of-----\n[[name]: {0}\n[[message]: {1}\n", e.getName(), e.getAlarmMessage())));

5. Documentation 

Posted by Pudgemeister on Wed, 04 May 2022 09:47:50 +0300