Before you can view the trace data of your application in the Tracing Analysis console, you must use a client to submit the trace data to Tracing Analysis. This topic shows how to use SkyWalking to report the data of Java applications.

Prerequisites

  • SkyWalking 6.X.X or later is downloaded from SkyWalking download page. We recommend that you download the latest stable version. The decompressed folder Agent is placed in a directory that can be accessed by Java processes.
  • All plug-ins are saved in the /plugins directory. If you add a plug-in to the directory during startup, the plug-in takes effect. If you delete a plug-in from the directory, the plug-in becomes ineffective. By default, log files are saved in the /logs directory.
Warning Logs, plug-ins, and configuration files are all saved in the Agent folder. Do not change the folder.
To obtain an endpoint of SkyWalking, perform the following steps:
  1. Log on to the Tracing Analysis console.
  2. In the left-side navigation pane, click Cluster Configurations. Then, click the Access point information tab.
  3. In the top navigation bar, select a region. In the Cluster Information section, turn on Show Token.
  4. In the Client section, click SkyWalking.

    Obtain an endpoint of SkyWalking in the Related Information column of the table in the lower part.

    Endpoint of SkyWalking
    Note If your application is deployed in an Alibaba Cloud production environment, use a private endpoint. Otherwise, use a public endpoint.

Background information

SkyWalking is a popular application performance monitoring (APM) service developed in China. SkyWalking is designed for microservices, cloud-native architectures, and containers, such as Docker, Kubernetes, and Mesos. SkyWalking is also a distributed tracing system.

To use SkyWalking to report Java application data to the Tracing Analysis console, you must first instrument the application. SkyWalking not only provides auto-instrument agents such as Dubbo, gRPC, JDBC, OkHttp, Spring, Tomcat, Struts, and Jedis, but also allows you to manually instrument applications. This topic shows how to automatically instrument an application.

The following figure shows how to report data by using SkyWalking.Use SkyWalking to report data

Use SkyWalking to automatically instrument a Java application

  1. Open the config/agent.config file and configure an endpoint and a token:
    Important Replace <endpoint> with the endpoint of the region where the SkyWalking client resides. Replace <auth-token> with the authentication token of the client. You can obtain the endpoint and the authentication token on the Overview page in the Tracing Analysis console. For more information, see the Prerequisites topic.
    collector.backend_service=<endpoint>
    agent.authentication=<auth-token>
  2. Use one of the following methods to set the service name of the application:
    Important Replace <ServiceName> with your application name. If you use both of the following methods, only the second method that adds a parameter to the startup command takes effect.
    • Open the config/agent.config file and set the application name:

      agent.service_name=<ServiceName>
    • Add the -Dskywalking.agent.service_name parameter to the startup command of the application:

      java -javaagent:<skywalking-agent-path> -Dskywalking.agent.service_name=<ServiceName> -jar yourApp.jar
  3. Use one of the following methods to specify the path to the Agent folder based on the runtime environment of the application:
    Note Replace <skywalking-agent-path> in the following sample code with the absolute path of the skywalking-agent.jar file in the Agent folder.
    • Linux Tomcat 7 / Tomcat 8

      Add the following content as the first line in the tomcat/bin/catalina.sh file:

      CATALINA_OPTS="$CATALINA_OPTS -javaagent:<skywalking-agent-path>"; export CATALINA_OPTS
    • Windows Tomcat 7 / Tomcat 8

      Add the following content as the first line in the tomcat/bin/catalina.bat file:

      set "CATALINA_OPTS=-javaagent:<skywalking-agent-path>"
    • JAR File or Spring Boot

      Add the -javaagent parameter to the startup command of the application.

      Important The -javaagent parameter must be written before the -jar parameter.
      java -javaagent:<skywalking-agent-path> -jar yourApp.jar
    • Jetty

      Add the following content to the {JETTY_HOME}/start.ini configuration file:

      --exec    # Remove the number sign (#) to uncomment the code. 
      -javaagent:<skywalking-agent-path>
  4. Restart the application.

FAQ

Q: Why am I unable to create an application after SkyWalking is properly connected to the server?

A: The data may not be reported to Tracing Analysis. You must check whether the data is reported to Tracing Analysis. For example, you can check the content in the {skywalking agent path}/logs/skywalking-api.log file. If the result in the following figure is returned, the data is reported. pg_xtrace_skywalking

No data may be reported because sampling is enabled, the data is filtered, or the request for using Tracing Analysis is not triggered.