In a microservice architecture, service diagnostics faces an increasing number of challenges. You can configure a local registry so that you can use Alibaba Cloud Toolkit to diagnose microservices. Alibaba Cloud Toolkit allows you to diagnose microservices in the High-speed Service Framework (HSF) and Apache Dubbo frameworks. The feature of diagnosing microservices in the Spring Cloud framework is being developed.
Prerequisites
- IntelliJ IDEA version 2018.3 or later is installed.
- Alibaba Cloud Toolkit is installed and configured in IntelliJ IDEA. For more information, see Install and configure Alibaba Cloud Toolkit in IntelliJ IDEA.
Notice You must select Alibaba Cloud Toolkit V2020.4.1 or later.
Configure and start a registry
Separately configure a registry for a provider application and a consumer application.
http://<IP address of the instance>:8080
in Step 2 to view the microservice version and microservice group.
Start a local registry for a provider application
Configure a custom registry for a consumer application
- Open a consumer project in IntelliJ IDEA.
- In the top navigation bar of IntelliJ IDEA, choose .
- In the Settings dialog box, choose .
- On the registry configuration page, select Join Self-managed Nacos Registry, enter the IP address of the registry to be used in the text box, and then click OK.
Diagnose microservices
This section uses a Dubbo microservice as an example to describe how to diagnose microservices. The procedure for diagnosing HSF microservices is the same as that for diagnosing Dubbo microservices.
Diagnostic logs
Check whether you can connect to a registry
You can use logs to diagnose network connections between an on-premises server and a registry. If the registry fails to be connected, an error message appears.
If the preceding error logs appear, check whether the IP address and port of the registry are valid. If the diagnostics is successful, the system returns a valid IP address of the registry.
Check whether a microservice can be called
You can use logs to check whether a microservice in a registry can be called. You can obtain microservice information, including the microservice interface, version, and group, from logs. If a microservice cannot be found, an error message appears.
If the preceding error logs appear, check microservice information, including the microservice type, interface, version, and group. The microservice type can be HSF or Dubbo. If the diagnostics is successful, the system returns the microservice that can be called in the registry.
Check whether a microservice is running on an instance
You can use logs to check whether a microservice is running on an instance. You can obtain the IP address and port of the instance from logs. If the microservice cannot be found, an error message appears, which indicates that no instance that runs the microservice is found.
Check whether you can connect to an instance that runs a microservice
You can use logs to check whether your on-premises server can connect to an instance that runs a microservice. If the connection fails, an error message appears, which indicates that the instance cannot be connected.