Quick start guide for common Java project

Update time: 2019-06-21

Quick start for client

Common Java Project

Add the Maven dependency of the client to the application:


Lookout-client relies on the lookout-reg-server module by default (supports reporting metrics data to the lookout server). If you want to use a different type of registry (such as lookout-reg-prometheus), then add the corresponding dependency.

Before starting to use the SOFALookout Client, you must firstly build a global client instance (com.alipay.lookout.client.DefaultLookoutClient).

LookoutConfig lookoutConfig = new LookoutConfig();

DefaultLookoutClient client = new DefaultLookoutClient("appName");
// Choose to build the Registry you need to use (if you need multiple registry types, it is recommended to use the same lookoutConfig instance for centralized management).
LookoutRegistry lookoutRegistry = new LookoutRegistry(lookoutConfig);
// Client can add a registry instance (at least one) after the client is created.
// (Optional) Uniformly register the metrics of extended modules for the registry instances that have been added or will be added to the client.

Then get the Registry instance through the client and use it:

// The registry is a "combination" registry
Registry registry = client.getRegistry();
Id id = registry.createId("http_requests_total");
Counter counter = registry.counter(id);

For the use of the client, see Project sample.