全部产品

限流日志

本文介绍如何查看限流日志。

服务限流的限流日志打印在 logs/guardian 中,该路径下存在多个日志文件,分别打印不同的日志内容。

默认日志

服务限流的默认日志是 guardian/guardian-default.log,主要打印推送下来的限流配置信息,日志内容没有固定格式。

样例:

2016-12-1219:49:09,610 INFO  RegistringGuardianCodeWrapperInterceptor
2016-12-1219:49:10,757 WARN  receive message with key=[guardianConfig]and value=[{"@type":"com.alipay.guardian.client.drm.GuardianConfig","engineConfigs":{"@type":"java.util.HashMap","LIMIT":{"@type":"com.alipay.guardian.client.engine.limit.LimitEngineConfig","actionConfigMap":{"@type":"java.util.HashMap",880:{"@type":"com.alipay.guardian.client.engine.limit.LimitActionConfig","actionType":"LIMIT_EXCEPTION","id":880,"responseContent":"限流配置-接口-多计算模型-抛出异常"}},"globalConfig":{"enable":true,"runMode":"CONTROL"},"resourceConfigList":[{"baseName":"com.alipay.guardiantestsofalite.facade.GuardianTestTrServiceFacade.testLimitBasicCondition","id":379,"resourceType":"METHOD","ruleIds":[880]}],"ruleConfigMap":{"@type":"java.util.HashMap",880:{"@type":"com.alipay.guardian.client.engine.limit.LimitRuleConfig","actionId":880,"calculationConfigs":[{"calculationType":"INVOKE_BY_TIME","maxAllow":10,"period":5000},{"calculationType":"INVOKE_BY_TIME","maxAllow":10,"period":5000},{"calculationKey":"[0].booleanValue","calculationType":"INVOKE_BY_TIME_CATEGORY","period":5000,"tairCompareKey":"true>5,false>6"}],"enable":true,"extParamConfigs":[],"id":880,"limitType":"GENERIC_LIMIT","paramConfigs":[{"checkMode":"BYVALUE","compare":"EQUALS","key":"[0].stringValue","value":"testStrMutilBasicParams"},{"checkMode":"BYVALUE","compare":"EQUALS","key":"[1].stringValue","value":"MultileCalculations"}],"paramRelation":"AND","ruleBizId":"[tr]限流配置-接口-基本参数多项-多个计算模型","runMode":"CONTROL","trafficType":"all"}}},"FUSE":{"@type":"com.alipay.guardian.client.engine.fuse.FuseEngineConfig","actionConfigMap":{"@type":"java.util.HashMap"},"ruleConfigMap":{"@type":"java.util.HashMap"}}},"version":1}]
2016-12-1219:49:10,759 WARN  after update with key=[guardianConfig]
2016-12-1219:49:11,195 INFO  GuardianConfig version=1
2016-12-1219:49:11,197 WARN  rebuild Rules,GuardianFactory:class com.alipay.guardian.client.limit.LimitGuardianFactory

运行错误日志

服务限流的运行时错误日志是 guardian/guardian-error.log,主要打印一些错误信息,其中的错误堆栈信息需要重点关注,日志内容没有固定格式。

限流统计日志

服务限流的限流统计日志是 guardian/guardian-limit-stat.log,日志内容的固定格式如下:

CONTROL/MONITOR,id,规则名称,统计间隔,开始时间,结束时间,统计类型,限流阈值,总请求数,放行数,限流数
  • MONITOR:表示当前的限流模式是监控模式

  • CONTROL:表示当前的限流模式是拦截模式

  • 倒数第四位:限流规则阈值

  • 倒数第三位:限流周期内的总请求数

  • 倒数第二位:限流周期内的放行请求数

  • 倒数第一位:表示当前限流周期内被限流的请求数

样例:

2016-11-2100:00:02,001 INFO  MONITOR,43,规则名字,1000,2016-11-21T00:00:01,2016-11-21T00:00:02INVOKE_BY_TIME,10,40,10,30