开发者社区 > 云原生 > 正文

新手指南 metric 日志输出格式

按照 “新手指南” ,运行下面的代码:

public class Main { public static void main(String[] args) { // 配置规则. initFlowRules();

    while (true) {
        // 1.5.0 版本开始可以直接利用 try-with-resources 特性,自动 exit entry
        try (Entry entry = SphU.entry("HelloWorld")) {
            // 被保护的逻辑
            System.out.println("hello world");
        } catch (BlockException ex) {
            // 处理被流控的逻辑
            System.out.println("blocked!");
        }
    }
}
private static void initFlowRules(){
    List<FlowRule> rules = new ArrayList<>();
    FlowRule rule = new FlowRule();
    rule.setResource("HelloWorld");
    rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
    // Set limit QPS to 20.
    rule.setCount(20);
    rules.add(rule);
    FlowRuleManager.loadRules(rules);
}

}

打开日志文件: C:\Users\kim\logs\csp\com-study-Main-metrics.log.2021-01-29 :

1611928935000|2021-01-29 22:02:15|HelloWorld|20|1|20|0|1|0|0|0 1611928936000|2021-01-29 22:02:16|HelloWorld|20|7547|20|0|0|0|0|0 1611928937000|2021-01-29 22:02:17|HelloWorld|20|14748|20|0|0|0|0|0 1611928938000|2021-01-29 22:02:18|HelloWorld|20|26622|20|0|0|0|0|0 1611928939000|2021-01-29 22:02:19|HelloWorld|20|31882|20|0|0|0|0|0 1611928940000|2021-01-29 22:02:20|HelloWorld|20|47173|20|0|0|0|0|0 1611928941000|2021-01-29 22:02:21|HelloWorld|20|61301|20|0|0|0|0|0 1611928942000|2021-01-29 22:02:22|HelloWorld|20|71610|20|0|0|0|0|0 1611928943000|2021-01-29 22:02:23|HelloWorld|20|68487|20|0|0|0|0|0

发现|分隔的项更多,跟新手指南里面的根本对不上,不知道后面的那些分隔项到底啥意思???

但是文档描述的打印输出格式是这样的: 4.检查效果

Demo 运行之后,我们可以在日志 ~/logs/csp/${appName}-metrics.log.xxx 里看到下面的输出:

|--timestamp-|------date time----|--resource-|p |block|s |e|rt 1529998904000|2018-06-26 15:41:44|hello world|20|0 |20|0|0 1529998905000|2018-06-26 15:41:45|hello world|20|5579 |20|0|728 1529998906000|2018-06-26 15:41:46|hello world|20|15698|20|0|0 1529998907000|2018-06-26 15:41:47|hello world|20|19262|20|0|0 1529998908000|2018-06-26 15:41:48|hello world|20|19502|20|0|0 1529998909000|2018-06-26 15:41:49|hello world|20|18386|20|0|0

请指教,是我文档没看清楚,还是文档没写清楚,这对我刚开始学习并打算使用sentinel 到公司项目中,却发现文档描述对不不上,这是很大的打击,而且是最基础的入门文档。 烦请多多指点,该怎么解读理解呢???????????

原提问者GitHub用户52learn

展开
收起
学习娃 2023-05-19 15:27:22 77 0
1 条回答
写回答
取消 提交回答
  • 参考下 https://github.com/alibaba/Sentinel/wiki/实时监控#资源的秒级日志

    原回答者GitHub用户

    2023-05-19 20:31:05
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载