DEV Community

Apache ShardingSphere
Apache ShardingSphere

Posted on

A Deep Dive Into Observability —Apache ShardingSphere Agent

Apache ShardingSphere follows Database Plus — our community’s guiding development concept for creating a complete data service ecosystem that allows you to transform any database into a distributed database system, and easily enhance it with sharding, elastic scaling, data encryption features & more.

Users often need to monitor Apache ShardingSphere’s performance in a real application scenario to find specific problems.

It’s a given that Application Performance Monitoring (APM) can monitor and diagnose system performance by collecting, storing, and analyzing observable data. It also integrates functions such as performance metrics, tracing analysis, application topology mapping, etc.

It retrieves the observable data from system operations by utilizing Tracing, Metrics and Logging. Apache ShardingSphere provides the Observability function for users.

Purposes

Apache ShardingSphere allows developers to configure logging output. The main objective of the current Observability feature is to provide necessary metrics and tracing data for users.

Design

We chose the common Agent method to perfectly implement Observability, with ByteBuddy (a code generation library that allows developers to modify Java classes (arbitrary included) during application runtime without using a compiler and Java Agent.

We adopt the plugin-oriented design to better support different frameworks or systems with Metrics and Tracing. Accordingly, users are allowed to customize the feature or develop more business-specific components by themselves.

Currently, the Agent module of Apache ShardingSphere supports Prometheus, Zipkin, Jaeger, SkyWalking, and OpenTelemetry.

Example

In the following instance, we deploy Prometheus and Zipkin observable data plugins on Apache ShardingSphere-Proxy to showcase how to use the Apache ShardingSphere Agent module.

Step 1: Install the Required Software
prometheus-2.32.1.linux-amd64.tar.gz(https://prometheus.io/download)

zipkin-server-2.23.9-exec.jar (https://zipkin.io/pages/quickstart.html)

apache-shardingsphere-5.1.0-SNAPSHOT-shardingsphere-proxy-bin.tar.gz

apache-shardingsphere-5.1.0-SNAPSHOT-shardingsphere-agent-bin.tar.gz

MySQL 5.7.34

Step 2: Deploy
Port
Prometheus Server:9090
Zipkin Server:9411
Apache ShardingSphere-Proxy:3307
Apache ShardingSphere Agent(Prometheus Plugin):9000

Prometheus
First, add monitoring objects to Prometheus. In this case, we need to add the Apache ShardingSphere Agent port address 9000 to the Prometheus configuration file prometheus.yml.

vi prometheus.yml
Enter fullscreen mode Exit fullscreen mode

Add the following code under static_configs in the file:

- targets: ["localhost:9000"]
Enter fullscreen mode Exit fullscreen mode

Then, initiate:

./prometheus &
Enter fullscreen mode Exit fullscreen mode

Zipkin
Zipkin is easier to use. Initiate it by input the following command in the Zipkin Server directory:

java -jar Zipkin-server-2.23.9-exec.jar &