×
Community Blog SLS Plug-In in Alibaba Cloud Toolkit Helps Troubleshoot Online Services

SLS Plug-In in Alibaba Cloud Toolkit Helps Troubleshoot Online Services

This article discusses the benefits of the Alibaba Cloud Toolkit plug-in.

By Taiye , from Alibaba Cloud Storage Team

Product Introduction

Alibaba Cloud Toolkit is an IDE-targeted plug-in for developers that helps them efficiently develop and deploy applications for cloud environments. After completing the development, debugging, and testing of your application locally, you can install Alibaba Cloud Toolkit in the IDE, such as Eclipse or IntelliJ. You can connect to a cloud environment and deploy your application to the cloud through graphical configuration.

Pain Points Resolved by SLS Plug-In

Online troubleshooting is an essential experience for a software developer. In services of different maturity levels, the processes of online troubleshooting vary slightly. For software developed by some small start-up companies, its service may still be single-point, or a cluster is built by several machines. Therefore, we need to go to each server and check the logs of each service through SSH. Companies with higher maturity will build their own log service platform or use a mature log platform like SLS to organize and manage online logs. This saves the trouble of checking logs on the server through SSH and significantly improves troubleshooting efficiency.

However, it is still not perfect. Here is a common scenario. When an exception occurs online, we will find the service log on the page of the log service platform, such as the Java Stack Trace. The Java Stack Trace is usually long. So, we need to switch back and forth between the page and IDE of the log service platform to accurately find the exception from the codebase. In some cases, when the log takes too long, we also need to copy the log to the local file. Switching back and forth between different windows wastes a lot of precious time.

Alibaba Cloud Toolkit integrates the functions of the SLS log platform to conveniently and accurately associate the logs of the Log Service platform with the code, helping software developers easily query the desired logs in IDE. Log Service is a cloud-native monitoring and analysis platform. It provides large-scale, low-cost, and real-time services to process multiple types of data, such as Log, Metric, and Trace. Log Service allows you to collect, transform, query, analyze, visualize, ship, and consume data. You can also configure alerts in the console. It also helps enterprises improve their digital capabilities in terms of R&D, O&M, and data security.

Let's look at a common Java service exception troubleshooting scenario and see how convenient SLS is in the Alibaba Cloud Toolkit plug-in.

Scenario Simulation

Service Simulation

First, we can simulate a service with an online exception. Create a simple springboot service and implement a Component bean of ApplicationRunner. This is very simple. It prints a line of NPE logs every second to simulate the service of NPE online.

@Component
@Slf4j
public class LogDemoService implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        while (true) {
            try {
                String field = null;
                System.out.println(field.length());
                Thread.sleep(1000);
            } catch (Exception e) {
                log.error("write exception log :", e);
            }
        }
    }
}

After the service is packaged, start the service on the server.

SLS Collection, Deployment, and Verification

Then, we can deploy the log collection service of SLS on the server. Please see this link for specific operation files.

This step will collect logs to the logstore of SLS:

1
After we confirm the logs have been successfully collected on the SLS page, the service simulation and the access to the log platform have been completed. Let's return to IDE.

IDE Configuration and Instructions

First, we can find the Alibaba Cloud Toolkit through the marketplace of plug-ins of IntelliJ. Click install and then restart IDE for it to take effect:

2

Click Tools → Alibaba Cloud → Preference to configure the account information. You need to enter the Access Key Id and Access Key Secret of the account that has permission to view SLS logs.

3

4

Click Tools → Alibaba Cloud → Alibaba Cloud View → Alibaba Cloud SLS

5

Now, you can see the log query interface of SLS at the bottom of the IDE window.

6

After selecting the corresponding region and project, click the view button on the right side of the corresponding logstore.

7

Just like the SLS page, you can view the logs of the services in IDE. This interface also supports the filtering of log time ranges and the filtering of query and analysis statements, which can help developers quickly and accurately find the desired log data. Please refer to this link for SLS query and analysis statements.

It is impossible to see the complete information at one time in this interface with long logs like the Java Stack Trace. There is an "Open in Editor" button on the right side of each log in the query results.

8

Click it, and you can view this log on the new page of IDE, which is convenient for developers to obtain the complete information.

9

Summary

Alibaba Cloud Toolkit is an excellent plug-in. It adds the function of the Log Service and integrates the functions of the Log Service platform into IDE for common problem troubleshooting scenarios in software developers' daily work. This saves the time of switching back and forth between windows and improves the daily work efficiency.

0 0 0
Share on

Alibaba Cloud Community

438 posts | 23 followers

You may also like

Comments