Master Sentinel Console: Real‑Time Monitoring, Flow Control & Rule Configuration Guide
This tutorial walks you through Sentinel's lightweight console, showing how to view machine health, monitor real‑time metrics, configure flow, degrade, hotspot, and system rules, handle exceptions with custom handlers, enable authentication, and push rules in a Spring Boot microservice environment.
Console Overview
Sentinel provides a lightweight open‑source console for machine discovery, health monitoring, real‑time metrics, rule management and push, as well as authentication.
Environment
jdk 1.8 sentinel 1.8.0 spring-boot 2.3.5.RELEASE spring-cloud Hoxton.SR8 spring-cloud-alibaba 2.2.5.RELEASEMachine List & Health
After successful integration, the
Machine Listmenu displays each service node's health status.
If Sentinel integration fails, refer to the official documentation or FAQ for troubleshooting.
Service Monitoring
1. Real‑time Monitoring
Metrics from all machines under the same service are aggregated and displayed under "Real‑time Monitoring" with a 5‑minute data retention window.
Ensure the console machine time matches the application machine time, otherwise real‑time data cannot be fetched.
2. Cluster Call Chain
The cluster call chain page shows resource call relationships in two modes: a tree structure or a flat view of real‑time resource status.
Again, synchronize the console and application machine times.
3. Flow Control Rules
Flow control monitors QPS or concurrent threads and blocks traffic when thresholds are exceeded, protecting application availability.
Key slots involved:
FlowSlot,
NodeSelectorSlot,
ClusterBuilderSlot,
StatisticSlot.
When a rule is triggered,
Entry nodeA = SphU.entry(resourceName)throws a
FlowException, which is a subclass of
BlockException. Custom handlers can catch
BlockExceptionto define fallback logic.
<code>@Component
public class SentinelBlockHandler implements BlockExceptionHandler {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
CommonResult<Void> result = new CommonResult<>();
if (e instanceof FlowException) {
result = CommonResult.error(101, "接口限流了");
} else if (e instanceof DegradeException) {
result = CommonResult.error(102, "服务降级了");
} else if (e instanceof ParamFlowException) {
result = CommonResult.error(103, "热点参数限流了");
} else if (e instanceof SystemBlockException) {
result = CommonResult.error(104, "系统规则(负载/...不满足要求)");
} else if (e instanceof AuthorityException) {
result = CommonResult.error(105, "授权规则不通过");
}
response.setStatus(500);
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Type", "application/json;charset=utf-8");
response.setContentType("application/json;charset=utf-8");
new ObjectMapper().writeValue(response.getWriter(), result);
}
}
</code>Example curl results:
{"code":1,"message":"this is a success message","data":{"id":1,"code":"STOCK==>1000"}}
{"code":101,"message":"接口限流了","data":null}Threshold Types
Thread Count : Limits concurrent threads to protect thread pools. Configuration is usually done on the caller side.
Flow Control Modes
Direct : Immediate rejection when QPS exceeds the threshold (default behavior).
Warm‑up : Gradually ramps up traffic to avoid sudden spikes on cold systems.
Rate Limiter : Enforces a uniform request interval using a leaky‑bucket algorithm (not supported for QPS > 1000).
4. Degrade Rules
Degrade (circuit‑breaker) protects services from unstable downstream calls. Strategies include slow‑call ratio, error ratio, and error count.
Example configuration screenshot omitted for brevity.
5. Hotspot Rules
Hotspot (parameter) flow control limits frequently accessed parameter values (e.g., hot product IDs). Resources must be annotated with
@SentinelResourceand parameters must be primitive types.
6. Authorization Rules
Origin‑based black‑/white‑list control restricts access based on the request's
origin. Implement
RequestOriginParserto extract the origin, then configure rules in the console.
7. System Rules
System protection monitors load, CPU usage, average RT, concurrent threads, and inbound QPS at the application entry level. Only entry traffic (
EntryType.IN) is affected.
Supported modes: Load adaptive, CPU usage, average RT, concurrent threads, entry QPS.
8. Cluster Flow Control
Cluster flow control centralizes token distribution to enforce global QPS limits across multiple instances, solving uneven traffic distribution.
Roles: Token Client (requests tokens) and Token Server (issues tokens).
Rule Push
The console supports three push modes: raw, Pull, and Push. Rules are stored in memory by default; for production, use dynamic rule sources (e.g., Nacos, Apollo) and the push mode.
Authentication
Since Sentinel 1.5.0, a generic
AuthServiceinterface allows custom authentication. From 1.6.0, a basic login (default user/password:
sentinel) is provided, configurable via JVM arguments or Spring properties.
Reference
Official documentation: https://github.com/alibaba/Sentinel/wiki/控制台
Ops Development Stories
Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.