This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 6462436ae9 Add an http endpoint wrapper for health check (#12485)
6462436ae9 is described below
commit 6462436ae97404cdcaa8770a6d3197bd0156ff14
Author: kezhenxu94 <[email protected]>
AuthorDate: Mon Jul 29 15:16:55 2024 +0800
Add an http endpoint wrapper for health check (#12485)
---
.licenserc.yaml | 6 +--
dist-material/release-docs/LICENSE | 32 +++++++--------
docs/en/api/health-check.md | 9 +++++
docs/en/changes/changes.md | 2 +
docs/en/setup/backend/backend-health-check.md | 4 +-
docs/menu.yml | 2 +
oap-server-bom/pom.xml | 8 +++-
.../oap/server/core/query/type/HealthStatus.java | 2 +
.../checker/provider/HealthCheckerHttpService.java | 45 ++++++++++++++++++++++
.../checker/provider/HealthCheckerProvider.java | 15 +++++++-
.../oap/server/library/server/http/HTTPServer.java | 2 -
11 files changed, 102 insertions(+), 25 deletions(-)
diff --git a/.licenserc.yaml b/.licenserc.yaml
index e9f54c0804..48421ae282 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -106,10 +106,10 @@ dependency:
version: 2.13.4
license: Apache-2.0
- name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
- version: 2.16.1
+ version: 2.17.1
license: Apache-2.0
- name: com.fasterxml.jackson.datatype:jackson-datatype-jdk8
- version: 2.16.1
+ version: 2.17.1
license: Apache-2.0
- name: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml
version: 2.15.2
@@ -139,7 +139,7 @@ dependency:
version: 0.6.13
license: Apache-2.0
- name: com.aayushatharva.brotli4j:service
- version: 1.15.0
+ version: 1.16.0
license: Apache-2.0
- name: io.vertx:vertx-grpc
version: 4.5.1
diff --git a/dist-material/release-docs/LICENSE
b/dist-material/release-docs/LICENSE
index 7cbf202b27..6e0abc9d70 100644
--- a/dist-material/release-docs/LICENSE
+++ b/dist-material/release-docs/LICENSE
@@ -210,8 +210,8 @@ The following components are provided under the Apache-2.0
License. See project
The text of each license is the standard Apache 2.0 license.
https://mvnrepository.com/artifact/build.buf.protoc-gen-validate/pgv-java-stub/0.6.13
Apache-2.0
https://mvnrepository.com/artifact/build.buf.protoc-gen-validate/protoc-gen-validate/0.6.13
Apache-2.0
-
https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/brotli4j/1.15.0
Apache-2.0
-
https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/service/1.15.0
Apache-2.0
+
https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/brotli4j/1.16.0
Apache-2.0
+
https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/service/1.16.0
Apache-2.0
https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-auth-plugin/2.3.2
Apache-2.0
https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client/2.3.2
Apache-2.0
https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-encryption-plugin/2.3.2
Apache-2.0
@@ -222,8 +222,8 @@ The text of each license is the standard Apache 2.0 license.
https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.16.0
Apache-2.0
https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.2
Apache-2.0
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-guava/2.12.0
Apache-2.0
-
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.16.1
Apache-2.0
-
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.16.1
Apache-2.0
+
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.17.1
Apache-2.0
+
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.17.1
Apache-2.0
https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-kotlin/2.13.4
Apache-2.0
https://mvnrepository.com/artifact/com.fasterxml/classmate/1.5.1 Apache-2.0
https://mvnrepository.com/artifact/com.google.api.grpc/proto-google-common-protos/2.29.0
Apache-2.0
@@ -238,12 +238,12 @@ The text of each license is the standard Apache 2.0
license.
https://mvnrepository.com/artifact/com.google.inject/guice/4.1.0 Apache-2.0
https://mvnrepository.com/artifact/com.google.j2objc/j2objc-annotations/2.8
Apache-2.0
https://mvnrepository.com/artifact/com.graphql-java/java-dataloader/3.2.0
Apache-2.0
- https://mvnrepository.com/artifact/com.linecorp.armeria/armeria/1.27.3
Apache-2.0
-
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-graphql/1.27.3
Apache-2.0
-
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-graphql-protocol/1.27.3
Apache-2.0
-
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-grpc/1.27.3
Apache-2.0
-
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-grpc-protocol/1.27.3
Apache-2.0
-
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-protobuf/1.27.3
Apache-2.0
+ https://mvnrepository.com/artifact/com.linecorp.armeria/armeria/1.29.3
Apache-2.0
+
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-graphql/1.29.3
Apache-2.0
+
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-graphql-protocol/1.29.3
Apache-2.0
+
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-grpc/1.29.3
Apache-2.0
+
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-grpc-protocol/1.29.3
Apache-2.0
+
https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-protobuf/1.29.3
Apache-2.0
https://mvnrepository.com/artifact/com.orbitz.consul/consul-client/1.5.3
Apache-2.0
https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/3.14.9
Apache-2.0
https://mvnrepository.com/artifact/com.squareup.okio/okio/1.17.2 Apache-2.0
@@ -297,12 +297,12 @@ The text of each license is the standard Apache 2.0
license.
https://mvnrepository.com/artifact/io.grpc/grpc-netty/1.63.0 Apache-2.0
https://mvnrepository.com/artifact/io.grpc/grpc-protobuf/1.63.0 Apache-2.0
https://mvnrepository.com/artifact/io.grpc/grpc-protobuf-lite/1.63.0
Apache-2.0
- https://mvnrepository.com/artifact/io.grpc/grpc-services/1.61.0 Apache-2.0
+ https://mvnrepository.com/artifact/io.grpc/grpc-services/1.64.0 Apache-2.0
https://mvnrepository.com/artifact/io.grpc/grpc-stub/1.63.0 Apache-2.0
https://mvnrepository.com/artifact/io.grpc/grpc-util/1.63.0 Apache-2.0
- https://mvnrepository.com/artifact/io.micrometer/micrometer-commons/1.12.2
Apache-2.0
- https://mvnrepository.com/artifact/io.micrometer/micrometer-core/1.12.2
Apache-2.0
-
https://mvnrepository.com/artifact/io.micrometer/micrometer-observation/1.12.2
Apache-2.0
+ https://mvnrepository.com/artifact/io.micrometer/micrometer-commons/1.13.0
Apache-2.0
+ https://mvnrepository.com/artifact/io.micrometer/micrometer-core/1.13.0
Apache-2.0
+
https://mvnrepository.com/artifact/io.micrometer/micrometer-observation/1.13.0
Apache-2.0
https://mvnrepository.com/artifact/io.netty/netty-buffer/4.1.108.Final
Apache-2.0
https://mvnrepository.com/artifact/io.netty/netty-codec/4.1.108.Final
Apache-2.0
https://mvnrepository.com/artifact/io.netty/netty-codec-dns/4.1.108.Final
Apache-2.0
@@ -416,7 +416,7 @@ CC0-1.0 and BSD-2-Clause licenses
The following components are provided under the CC0-1.0 and BSD-2-Clause
License. See project link for details.
The text of each license is also included in licenses/LICENSE-[project].txt.
- https://mvnrepository.com/artifact/org.hdrhistogram/HdrHistogram/2.1.12
CC0-1.0 and BSD-2-Clause
+ https://mvnrepository.com/artifact/org.hdrhistogram/HdrHistogram/2.2.1
CC0-1.0 and BSD-2-Clause
========================================================================
ISC licenses
@@ -548,7 +548,7 @@ The text of each license is also included in
licenses/LICENSE-[project].txt.
https://npmjs.com/package/nanoid/v/3.3.7 3.3.7 MIT
https://mvnrepository.com/artifact/org.checkerframework/checker-qual/3.33.0 MIT
https://mvnrepository.com/artifact/org.codehaus.mojo/animal-sniffer-annotations/1.23
MIT
-
https://mvnrepository.com/artifact/org.curioswitch.curiostack/protobuf-jackson/2.2.0
MIT
+
https://mvnrepository.com/artifact/org.curioswitch.curiostack/protobuf-jackson/2.5.0
MIT
https://npmjs.com/package/pinia/v/2.0.28 2.0.28 MIT
https://npmjs.com/package/pinia/node_modules/vue-demi/v/0.13.11 0.13.11 MIT
https://npmjs.com/package/postcss/v/8.4.33 8.4.33 MIT
diff --git a/docs/en/api/health-check.md b/docs/en/api/health-check.md
new file mode 100644
index 0000000000..16927d5142
--- /dev/null
+++ b/docs/en/api/health-check.md
@@ -0,0 +1,9 @@
+# Check OAP healthiness
+
+This is an http wrapper of the [health
checker](../setup/backend/backend-health-check.md),
+make sure to set necessary configurations required by the health checker
before using this endpoint,
+otherwise 404 will be returned.
+
+> GET http://localhost:12800/healthcheck
+
+When the OAP server is healthy, the request returns status 200, otherwise, the
request returns status 503.
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index b137a366d4..497296faac 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -40,6 +40,8 @@
* BanyanDB: Zipkin Module set service as Entity for improving the query
performance.
* MQE: check the metrics value before do binary operation to improve
robustness.
* Replace workaround with Armeria native supported context path.
+* Add an http endpoint wrapper for health check.
+* Bump up Armeria and transitive dependencies.
#### UI
diff --git a/docs/en/setup/backend/backend-health-check.md
b/docs/en/setup/backend/backend-health-check.md
index 5c718cceeb..c717851ca1 100644
--- a/docs/en/setup/backend/backend-health-check.md
+++ b/docs/en/setup/backend/backend-health-check.md
@@ -17,8 +17,10 @@ health-checker:
```
Note: The `telemetry` module should be enabled at the same time. This means
that the provider should not be `-` and `none`.
-After that, we can check the OAP server health status by querying GraphQL:
+After that, we can check the OAP server health status by querying the http
endpoint: `/healthcheck`,
+see [the health check http endpoint doc](../../api/health-check.md).
+You can also query the healthiness via other methods like GraphQL, see
following.
```
query{
checkHealth{
diff --git a/docs/menu.yml b/docs/menu.yml
index 7e9a4ccbca..50e0a29277 100644
--- a/docs/menu.yml
+++ b/docs/menu.yml
@@ -322,6 +322,8 @@ catalog:
path: "/en/api/promql-service"
- name: "LogQL APIs"
path: "/en/api/logql-service"
+ - name: "Health Check API"
+ path: "/en/api/health-check"
- name: "Customization"
catalog:
- name: "Overview"
diff --git a/oap-server-bom/pom.xml b/oap-server-bom/pom.xml
index 6f4e6845cb..96e40db308 100644
--- a/oap-server-bom/pom.xml
+++ b/oap-server-bom/pom.xml
@@ -68,7 +68,7 @@
<postgresql.version>42.4.4</postgresql.version>
<jetcd.version>0.6.1</jetcd.version>
<testcontainers.version>1.17.6</testcontainers.version>
- <armeria.version>1.27.3</armeria.version>
+ <armeria.version>1.29.3</armeria.version>
<awaitility.version>3.0.0</awaitility.version>
<httpcore.version>4.4.13</httpcore.version>
<httpasyncclient.version>4.1.5</httpasyncclient.version>
@@ -548,7 +548,11 @@
</exclusion>
<exclusion>
<groupId>com.aayushatharva.brotli4j</groupId>
- <artifactId>native-osx-x86_64</artifactId>
+ <artifactId>native-linux-x86_64</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.aayushatharva.brotli4j</groupId>
+ <artifactId>native-osx-aarch64</artifactId>
</exclusion>
</exclusions>
</dependency>
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HealthStatus.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HealthStatus.java
index f32ccf73c3..ac83e8bfb0 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HealthStatus.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/HealthStatus.java
@@ -20,9 +20,11 @@ package org.apache.skywalking.oap.server.core.query.type;
import lombok.Getter;
import lombok.Setter;
+import lombok.ToString;
@Getter
@Setter
+@ToString
public class HealthStatus {
// score == 0 means healthy, otherwise it's unhealthy.
private int score;
diff --git
a/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerHttpService.java
b/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerHttpService.java
new file mode 100644
index 0000000000..356d76a79e
--- /dev/null
+++
b/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerHttpService.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.health.checker.provider;
+
+import com.linecorp.armeria.common.HttpRequest;
+import com.linecorp.armeria.common.HttpResponse;
+import com.linecorp.armeria.common.HttpStatus;
+import com.linecorp.armeria.server.ServiceRequestContext;
+import com.linecorp.armeria.server.annotation.Get;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@RequiredArgsConstructor
+public class HealthCheckerHttpService {
+ private final HealthQueryService healthQueryService;
+
+ @Get("/healthcheck")
+ public HttpResponse healthcheck(ServiceRequestContext ctx, HttpRequest
req) throws Exception {
+ final var status = healthQueryService.checkHealth();
+ log.info("Health status: {}", status);
+
+ if (status.getScore() == 0) {
+ return HttpResponse.of(HttpStatus.OK);
+ }
+ return HttpResponse.of(HttpStatus.SERVICE_UNAVAILABLE);
+ }
+}
diff --git
a/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerProvider.java
b/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerProvider.java
index 557cb01782..29760f02ac 100644
---
a/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerProvider.java
+++
b/oap-server/server-health-checker/src/main/java/org/apache/skywalking/oap/server/health/checker/provider/HealthCheckerProvider.java
@@ -20,12 +20,16 @@ package
org.apache.skywalking.oap.server.health.checker.provider;
import com.google.common.util.concurrent.AtomicDouble;
import io.vavr.collection.Stream;
+
+import java.util.Arrays;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegister;
import
org.apache.skywalking.oap.server.health.checker.module.HealthCheckerModule;
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
@@ -36,6 +40,8 @@ import
org.apache.skywalking.oap.server.telemetry.TelemetryModule;
import org.apache.skywalking.oap.server.telemetry.api.MetricsCollector;
import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
+import com.linecorp.armeria.common.HttpMethod;
+
/**
* HealthCheckerProvider fetches health check metrics from telemetry module,
then calculates health score and generates
* details explains the score. External service or users can query health
status by HealthCheckerService.
@@ -48,6 +54,7 @@ public class HealthCheckerProvider extends ModuleProvider {
private MetricsCollector collector;
private MetricsCreator metricsCreator;
private ScheduledExecutorService ses;
+ private HealthQueryService healthQueryService;
@Override public String name() {
return "default";
@@ -75,13 +82,19 @@ public class HealthCheckerProvider extends ModuleProvider {
@Override public void prepare() throws ServiceNotProvidedException,
ModuleStartException {
score.set(-1);
ses = Executors.newSingleThreadScheduledExecutor();
- this.registerServiceImplementation(HealthQueryService.class, new
HealthQueryService(score, details));
+ healthQueryService = new HealthQueryService(score, details);
+ this.registerServiceImplementation(HealthQueryService.class,
healthQueryService);
}
@Override public void start() throws ServiceNotProvidedException,
ModuleStartException {
ModuleServiceHolder telemetry =
getManager().find(TelemetryModule.NAME).provider();
metricsCreator = telemetry.getService(MetricsCreator.class);
collector = telemetry.getService(MetricsCollector.class);
+
+ final var service = getManager().find(CoreModule.NAME)
+ .provider()
+ .getService(HTTPHandlerRegister.class);
+ service.addHandler(new HealthCheckerHttpService(healthQueryService),
Arrays.asList(HttpMethod.HEAD, HttpMethod.GET));
}
@Override public void notifyAfterCompleted() throws
ServiceNotProvidedException, ModuleStartException {
diff --git
a/oap-server/server-library/library-server/src/main/java/org/apache/skywalking/oap/server/library/server/http/HTTPServer.java
b/oap-server/server-library/library-server/src/main/java/org/apache/skywalking/oap/server/library/server/http/HTTPServer.java
index 5c787f673f..3f4410e779 100644
---
a/oap-server/server-library/library-server/src/main/java/org/apache/skywalking/oap/server/library/server/http/HTTPServer.java
+++
b/oap-server/server-library/library-server/src/main/java/org/apache/skywalking/oap/server/library/server/http/HTTPServer.java
@@ -26,7 +26,6 @@ import com.linecorp.armeria.server.Route;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.server.docs.DocService;
import com.linecorp.armeria.server.encoding.DecodingService;
-import com.linecorp.armeria.server.healthcheck.HealthCheckService;
import com.linecorp.armeria.server.logging.LoggingService;
import java.io.FileInputStream;
@@ -61,7 +60,6 @@ public class HTTPServer implements Server {
.builder()
.baseContextPath(config.getContextPath())
.serviceUnder("/docs", DocService.builder().build())
- .service("/internal/l7check", HealthCheckService.of())
.workerGroup(config.getMaxThreads())
.http1MaxHeaderSize(config.getMaxRequestHeaderSize())
.idleTimeout(Duration.ofMillis(config.getIdleTimeOut()))