Skip to content

Commit d94b171

Browse files
committed
Update Blog “set-up-apache-skywalking-for-k8s-and-vm-monitoring-in-hpe-greenlake-private-cloud”
1 parent bcc2560 commit d94b171

File tree

2 files changed

+101
-43
lines changed

2 files changed

+101
-43
lines changed

content/blog/set-up-apache-skywalking-for-k8s-and-vm-monitoring-in-hpe-greenlake-private-cloud.md

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ date: 2023-01-04T07:31:55.711Z
55
author: Guoping Jia
66
authorimage: /img/guoping.png
77
tags:
8-
- hpe-greenlake, kubernetes, application performance monitoring, Apache
9-
SkyWalking
8+
- hpe-greenlake, hpe-greenlake-for-private-cloud-enterprise, Kubernetes,
9+
application performance monitoring, Apache SkyWalking
1010
---
1111
## Introduction
1212

1313
[HPE GreenLake for Private Cloud Enterprise](https://www.hpe.com/us/en/greenlake/private-cloud-enterprise.html) delivers a modern private cloud to support your app workloads with bare metal, containers, and virtual machines (VMs) running in any combination across your edges, colocations, and data centers. It combines self-service resource access for developers with consumption and performance transparency for IT. Within this modern application environment, having a robust application performance monitoring (APM) tool is becoming essential. It can help IT professionals to ensure that deployed applications meet the performance, reliability and valuable user experience required by developers, partners and customers.
1414

15-
In [the first blog post](https://developer.hpe.com/blog/get-started-with-application-performance-monitoring-tools-overview/), we walked through some of the best APM tools, described their key features and discussed in details their strengths and weaknesses.
15+
In [the first blog post](https://developer.hpe.com/blog/get-started-with-application-performance-monitoring-tools-overview/), I walked through some of the best APM tools, and I described their key features and discussed in details their strengths and weaknesses.
1616

17-
In this blog post, we will start choosing one APM tool, *Apache SkyWalking*, and describe the detailed process how to set it up in HPE GreenLake for Private Cloud Enterprise for monitoring and alerting customer applications.
17+
In this blog post, I will start choosing one APM tool, *Apache SkyWalking*, and describe the detailed process how to set it up in HPE GreenLake for Private Cloud Enterprise for monitoring and alerting customer applications.
1818

1919
## Apache SkyWalking
2020

@@ -26,7 +26,7 @@ Apache SkyWalking is lightweight and scalable. It can be easily set up as a *sel
2626

2727
## Set up Apache SkyWalking for Application Monitoring
2828

29-
We will take the approach to setting up the Apache SkyWalking as a *self-managed* APM tool within the Kubernetes cluster created in HPE GreenLake for Private Cloud Enterprise. This mainly takes into account the security concerns in HPE GreenLake product environment.
29+
I will take the approach to setting up the Apache SkyWalking as a *self-managed* APM tool within the Kubernetes cluster created in HPE GreenLake for Private Cloud Enterprise. This mainly takes into account the security concerns in HPE GreenLake product environment.
3030

3131
### Prerequisites
3232

@@ -55,11 +55,11 @@ $ helm install skywalking skywalking –n skywalking \
5555
--set elasticsearch.sysctlInitContainer.enabled=false
5656
```
5757

58-
After running above commands, the Apache SkyWalking is installed to the Kubernetes cluster's namespace *skywalking*. It creates the *elasticsearch* as the `StatefulSet`, running a pod on each worker node. It runs the Apache SkyWalking OAP with replicas as 2 to provide high availability.
58+
After running above commands, the Apache SkyWalking is installed to the Kubernetes cluster's namespace *skywalking*. It creates the *elasticsearch* as the `StatefulSet` object, running a pod on each worker node. It runs the Apache SkyWalking Observability Analysis Platform (OAP) with replicas as 2 to provide high availability.
5959

60-
It should be noted that the last option *elasticsearch.sysctlInitContainer.enabled=false* is necessary. Otherwise, it will try to set up *vm.max_map_count* using a privileged container during *elasticsearch* installation. It will violate the existing *PodSecurityPolicy* deployed in the HPE GreenLake environment. It therefore will fail the Helm install.
60+
It should be noted that the last option *elasticsearch.sysctlInitContainer.enabled=false* is necessary. Otherwise, it will try to set up *vm.max_map_count* using a privileged container during *elasticsearch* installation. It will violate the existing *PodSecurityPolicy* deployed in the HPE GreenLake for Private Cloud Enterprise environment. It therefore will fail the Helm install.
6161

62-
We can check the detailed Apache SkyWalking installation by typing the following *kubectl* command:
62+
You can check the detailed Apache SkyWalking installation by typing the following *kubectl* command:
6363

6464
```markdown
6565
$ kubectl get all -n skywalking
@@ -93,7 +93,7 @@ NAME COMPLETIONS DURATION AGE
9393
job.batch/skywalking-es-init 1/1 7m27s 8m6s
9494
```
9595

96-
We can edit the deployed SkyWalking UI service *skywalking_ui* and change its type from *ClusterIP* to *NodePort*. The service will be automatically mapped to gateway host with an assigned port.
96+
You can edit the deployed SkyWalking UI service *skywalking_ui* and change its type from *ClusterIP* to *NodePort*. The service will be automatically mapped to gateway host with an assigned port.
9797

9898
```markdown
9999
$ k edit service/skywalking-ui -n skywalking
@@ -123,13 +123,13 @@ External Traffic Policy: Cluster
123123
Events: <none>
124124
```
125125

126-
The SkyWalking UI can then be accessed in the browser by typing the address *gl2-caas.gl-hpe.local:10037*:
126+
As shown in the ***Annotations*** section of the service description above, the SkyWalking UI can then be accessed in the browser by typing the address *gl2-caas.gl-hpe.local:10037*:
127127

128128
![](/img/sw-ui.png)
129129

130-
### Deploy a Sample SpringBoot Application
130+
### Deploy a sample application: *SpringBoot*
131131

132-
As the first demo application, create a *SpingBoot* Web app that provides a REST endpoint **/message** to print some nice message. Then generate a *jar* file *springboot-k8s-demo.jar* to the target folder:
132+
As the first demo application, create a *SpingBoot* Web app that provides a REST endpoint **/message** to print some nice message. Then generate a *jar* package using the [Apache Maven](https://maven.apache.org/what-is-maven.html) command *mvn* with the *pom.xml* file:
133133

134134
```markdown
135135
├── Dockerfile
@@ -142,9 +142,58 @@ As the first demo application, create a *SpingBoot* Web app that provides a R
142142
└── target
143143
├── springboot-k8s-demo.jar
144144
└── test-classes
145+
146+
$ cat pom.xml
147+
<?xml version="1.0" encoding="UTF-8"?>
148+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
149+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
150+
<modelVersion>4.0.0</modelVersion>
151+
<parent>
152+
<groupId>org.springframework.boot</groupId>
153+
<artifactId>spring-boot-starter-parent</artifactId>
154+
<version>2.6.1</version>
155+
<relativePath/> <!-- lookup parent from repository -->
156+
</parent>
157+
<groupId>com.javatechie</groupId>
158+
<artifactId>springboot-k8s-demo</artifactId>
159+
<version>0.0.1-SNAPSHOT</version>
160+
<name>springboot-k8s-demo</name>
161+
<description>Demo project for Spring Boot</description>
162+
<properties>
163+
<java.version>1.8</java.version>
164+
</properties>
165+
<dependencies>
166+
<dependency>
167+
<groupId>org.springframework.boot</groupId>
168+
<artifactId>spring-boot-starter-web</artifactId>
169+
</dependency>
170+
171+
<dependency>
172+
<groupId>org.springframework.boot</groupId>
173+
<artifactId>spring-boot-starter-test</artifactId>
174+
<scope>test</scope>
175+
</dependency>
176+
</dependencies>
177+
178+
<build>
179+
<plugins>
180+
<plugin>
181+
<groupId>org.springframework.boot</groupId>
182+
<artifactId>spring-boot-maven-plugin</artifactId>
183+
</plugin>
184+
</plugins>
185+
<finalName>springboot-k8s-demo</finalName>
186+
</build>
187+
188+
</project>
189+
190+
$ mvn compile
191+
$ mvn package
192+
$ ls target/springboot-k8s-demo.jar
193+
target/springboot-k8s-demo.jar
145194
```
146195

147-
By building a *Docker* image using the generated *jar* file, this *SpringBoot* app can be easily deployed as a containerized application to the Kubernetes cluster.
196+
You can see the *jar* package *springboot-k8s-demo.jar* is built to the *target* folder. By building a *Docker* image using this generated *jar* file, the *SpringBoot* Web app can be easily deployed as a containerized application to the Kubernetes cluster.
148197

149198
Apache SkyWalking provides a list of agents for instrumenting applications. A specific agent per programming language can be used for building into corresponding service which collects application data and exports them to the SkyWalking OAP server.
150199

@@ -168,9 +217,9 @@ WORKDIR /app
168217
ENTRYPOINT ["java","-javaagent:/opt/agent/skywalking-agent.jar=agent.namespace=default,agent.service_name=springboot-k8s-app,collector.backend_service=skywalking-oap.skywalking.svc.cluster.local:11800, plugin.jdbc.trace_sql_parameters = true,profile.active=true","-jar","/app/springboot-k8s-app.jar"]
169218
```
170219

171-
### Monitor SpringBoot Application from SkyWalking UI
220+
### Monitor SpringBoot application from SkyWalking UI
172221

173-
After build the Docker image *guopingjia/springboot-k8s-demo:pce* and push it to the *DockerHub* registry, we deploy the *SpringBoot* Web app to the Kubernetes cluster:
222+
After build the Docker image *guopingjia/springboot-k8s-demo:pce* and push it to the *DockerHub* registry, we deploy the *SpringBoot* Web app to the Kubernetes cluster with the *deployment.yaml* manifest file:
174223

175224
```markdown
176225
$ cat deployment.yaml
@@ -199,21 +248,23 @@ spec:
199248
$ kubectl apply -f deployment.yaml
200249
```
201250

202-
Upon the Web app gets deployed, the built-in Java agent will start collecting application data and post it to the SkyWalking OAP. All the application metrics will be available in the SkyWalking UI, under _General Service_ tab:
251+
Upon the Web app gets deployed, the built-in Java agent will start collecting application data and post it to the SkyWalking OAP. All the application metrics will be available in the SkyWalking UI, under *General Service* tab:
203252

204253
![](/img/java-app.png)
205254

206-
Below is the *SpingBoot* Web app topology map:
255+
Below is the *SpringBoot* Web app topology map:
207256

208257
![](/img/java-app-map.png)
209258

210-
### Deploy a Multi-tier Application
259+
### Deploy a multi-tier application
211260

212-
As the second demo application, we will deploy a multi-tier *music* application, available as part of [Apache SkyWalking showcase application](https://github.com/apache/skywalking-showcase). This multi-tier music application consists of a frontend app server and its UI, backend gateway service, recommendation service and songs service, together with a *H2* database. Each microservice is coding with different programming languages, *NodeJS*, *React*, *Spring*, *Python*, etc.
261+
As the second demo application, I will deploy a multi-tier *music* application, available as part of [Apache SkyWalking showcase application](https://github.com/apache/skywalking-showcase). This multi-tier music application consists of a frontend app server and its UI, backend gateway service, recommendation service and songs service, together with a *H2* database. Each microservice is implemented with different programming language, *NodeJS*, *React*, *Spring*, *Python*, etc.
213262

214263
![](/img/multl-tier-app-music.png)
215264

216-
In order to monitor this multi-tier *music* application from Apache SkyWalking, we need to pick up the SkyWalking agent per programming language and rebuild corresponding service to instrument the application to the SkyWalking OAP server.
265+
In order to monitor this multi-tier *music* application from Apache SkyWalking, you need to pick up the SkyWalking agent per programming language and rebuild corresponding service to instrument the application to the SkyWalking OAP server.
266+
267+
You can rebuild the *Docker* image per service using the agent version file _**Dockerfile**_ in each service's folder from the multi-tier *music* application repo:
217268

218269
```markdown
219270
├── app
@@ -254,7 +305,7 @@ In order to monitor this multi-tier *music* application from Apache SkyWalkin
254305
└── src
255306
```
256307

257-
After image files are rebuilt with the agents, the multi-tier *music* application can be deployed to the K8s cluster:
308+
After image files are rebuilt with the agents, the multi-tier *music* application can be deployed to the Kubernetes cluster:
258309

259310
```markdown
260311
$ envsubst < resources.yaml | kubectl create -f -
@@ -269,9 +320,9 @@ deployment.apps/app-deployment created
269320
deployment.apps/loadgen-deployment created
270321
```
271322

272-
### Monitor Multi-tier Application from SkyWalking UI
323+
### Monitor multi-tier application from SkyWalking UI
273324

274-
When the multi-tier *music* app gets deployed, the agents built with each microservice will start collecting application data and post it to the SkyWalking OAP. The multi-tier *music* application metrics will be available in the SkyWalking UI, under _General Service_ tab:
325+
When the multi-tier *music* app gets deployed, the agents built with each microservice will start collecting application data and post it to the SkyWalking OAP. The multi-tier *music* application metrics will be available in the SkyWalking UI, under *General Service* tab:
275326

276327
![](/img/multl-tier-app.png)
277328

@@ -283,42 +334,49 @@ You can also check the following multi-tier *music* application trace page. It's
283334

284335
![](/img/sw-app-trace.png)
285336

286-
### Application Alerting
337+
### Application alerting
287338

288-
Apache SkyWalking provides an alerting mechanism to measure application performance according to a list of pre-defined metrics, e.g., _service_resp_time_, _database_access_resp_time_, and _service_sla_. It will trigger alerting when some metrics reach its pre-defined thresholds. We can define new metrics or customize the existing metrics with new thresholds.
339+
Apache SkyWalking provides an alerting mechanism to measure application performance according to a list of pre-defined metrics, e.g., *service\_resp\_time*, *database\_access\_resp\_time*, and *service\_sla*. It will trigger alerting when some metrics reach its pre-defined thresholds. You can define new metrics using Observability Analysis Language (OAL) or customize the existing metrics with new thresholds.
289340

290-
Here is the alarms page from SkyWalking UI showing all the triggered alerting for deployed multi-tier *music* app:
341+
Here is the alarms page from SkyWalking UI showing all the triggered alerts for deployed multi-tier *music* application:
291342

292343
![](/img/sw-app-alarms.png)
293344

294345
The alarms page shows *Successful rate of service agent::app is lower than 80% in 2 minutes of last 10 minutes*. It indicates issue from the frontend app server in multi-tier *music* application.
295346

296-
The alerts are triggered by the following metric alerting rule _service_sla_:
347+
Apache SkyWalking configures the alerting using a collection of alerting rules located in */skywalking/config/alarm-settings.yml* from the SkyWalking OAP pod. You can check the content by running the following command:
348+
349+
```markdown
350+
$ kukectl exec pod/skywalking-skywalking-helm-oap-bfb57fbf8-5g7k7 -n skywalking -it -- cat /skywalking/config/alarm-settings.yml
351+
```
352+
353+
Comparing to the output of the _alarm-settings.yml_, you can see the alerts from the alarms page are triggered by the following metric alerting rule *service\_sla*:
297354

298355
```markdown
299-
service_sla_rule:
300-
# Metrics value need to be long, double or int
301-
metrics-name: service_sla
302-
op: "<"
303-
threshold: 8000
304-
# The length of time to evaluate the metrics
305-
period: 10
306-
# How many times after the metrics match the condition, will trigger alarm
307-
count: 2
308-
# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.
309-
silence-period: 3
310-
message: Successful rate of service {name} is lower than 80% in 2 minutes of last 10 minutes
356+
service_sla_rule:
357+
# Metrics value need to be long, double or int
358+
metrics-name: service_sla
359+
op: "<"
360+
threshold: 8000
361+
# The length of time to evaluate the metrics
362+
period: 10
363+
# How many times after the metrics match the condition, will trigger alarm
364+
count: 2
365+
# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.
366+
silence-period: 3
367+
message: Successful rate of service {name} is lower than 80% in 2 minutes of last 10 minutes
311368
```
312-
We can go to the frontend app by clicking the service `agent::app` from SkyWalking UI Service page. From the below service `agent::app` overview page, it shows **Success Rate 66.66%**.
369+
370+
You can go to the frontend app by clicking the service `agent::app` from SkyWalking UI Service page. From the below service `agent::app` overview page, it shows **Success Rate 66.66%**.
313371

314372
![](/img/sw-svc-app-overview.png)
315373

316-
We may check further the service's trace page and try to figure out the root cause for this issue.
374+
You may check further the service's trace page and try to figure out the root cause for this issue.
317375

318-
![](/img/sw-svc-app-trace.png)
376+
![](/img/sw-svc-app-trace.png)
319377

320378
## Conclusion
321379

322380
This blog post took the Apache SkyWalking as the application performance monitoring (APM) tool and showed the detailed process to set it up, as a *self-managed* environment in HPE GreenLake for Private Cloud Enterprise, for monitoring and alerting applications. Using the instrumentation of multiple supported agents from Apache SkyWalking, the application workloads can be easily monitored through the integrated Apache SkyWalking UI, with nice application topology map, tracing details and real-time alarms for any application performance issues.
323381

324-
In the next blog, we will show you how to use Apache SkyWalking for Kubernetes monitoring in HPE GreenLake for Private Cloud Enterprise.
382+
In [the next blog post of the series](https://developer.hpe.com/blog/set-up-apache-skywalking-for-k8s-monitoring-in-hpe-greenlake-for-private-cloud-enterprise/) , I will show you how to use Apache SkyWalking APM tool for monitoring of Kubernetes clusters provisioned on HPE GreenLake for Private Cloud Enterprise.

static/img/java-agent.png

5.26 KB
Loading

0 commit comments

Comments
 (0)