Monitoring Applications with Apache SkyWalking

Naveen Kumar Ravi
2 min readAug 4, 2023

--

Apache SkyWalking is an open-source observability platform for monitoring, tracing and diagnosing distributed systems. It provides an easy way to capture metrics and traces from applications written in various languages including Java, Node.js, .NET Core, PHP and more.

In this article, we’ll learn how to set up SkyWalking locally, and configure Java and Node.js applications to report data to it.

Introduction to SkyWalking

SkyWalking provides the following key capabilities:

  • Distributed tracing — trace requests across services and visualize call flows.
  • Application metrics monitoring — CPU, memory, IO, network etc.
  • Automatic service topology visualization
  • Performance and error monitoring
  • Root cause analysis for problems
  • Support for various languages and frameworks

It is used for monitoring cloud-native infrastructures, microservices, distributed systems, and even traditional monoliths.

Setting Up SkyWalking on Ubuntu

Let’s go through installing SkyWalking on a local Ubuntu system step-by-step:

  1. Install Java 8+ on your system if not already installed.
  2. Download the latest SkyWalking tarball from their website
  3. Extract the tarball — tar xzf skywalking-bin.tar.gz
  4. Navigate to the /bin directory
  5. Start the SkyWalking server with ./startup.sh
  6. SkyWalking backend will start on port 8080
  7. Access the Web UI at http://localhost:8080

This completes the basic setup. Now we can configure our applications to report data.

Monitoring a Java Application

Sample Application Setup

Let’s go through an example of setting up a simple Java REST API and Node.js frontend to work with SkyWalking.

Java Sample App

  1. Create a Maven project
  2. Add SkyWalking agent and toolkit dependencies:
<!-- in pom.xml -->

<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-trace</artifactId>
</dependency>

<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-agent-core</artifactId>
</dependency>

3. Create a simple REST endpoint:

@RestController 
public class SampleController {

@GetMapping("/api")
public String hello() {
return "Hello World!";
}

}

4. Start the app with the SkyWalking agent:

java -javaagent:/path/to/agent.jar -jar app.jar

5. Start the application, and SkyWalking will automatically receive metrics and traces. The Java app topology and metrics should now show up in the SkyWalking UI.

Monitoring a Node.js Application

Node.js Sample App

  1. Initialize Node.js project
  2. Install SkyWalking module
npm install @skyapm/nodejs

3. Add tracing code:

// index.js
const tracer = require('@skyapm/nodejs');

tracer.start({
serviceName: 'frontend'
})

// express server
app.get('/', (req, res) => {
res.send('Hello from Node.js!');
});

4. Start the server, SkyWalking will automatically trace requests.

This completes the basic local setup and instrumentation for Java and Node.js apps. SkyWalking offers many more advanced features for distributed tracing, diagnostics and visualizations. Do refer the official documentation for more details.

Conclusion

Apache SkyWalking provides an effective open-source solution for monitoring cloud-native applications and microservices environments. It can provide observability for polyglot systems with support for many languages. The simple local setup and integration with popular frameworks makes it easy to get started.

--

--

Naveen Kumar Ravi
Naveen Kumar Ravi

Written by Naveen Kumar Ravi

Technical Architect | Java Full stack Developer with 9+ years of hands-on experience designing, developing, and implementing applications.

No responses yet