50.8.2 示例: 导出到Open TSDB

如果提供一个OpenTsdbGaugeWriter类型的@Bean并注解@ExportMetricWriter,指标将导出到Open TSDB 完成聚合。OpenTsdbGaugeWriter有一个url属性,你需要将它设置为Open TSDB的“/put”端点,比如localhost:4242/api/put。它还有个namingStrategy,你可以自定义或配置以使指标匹配服务器上你需要的数据结构。默认它只传递指标名作为Open TSDB指标名,添加domain标签(值为org.springframework.metrics)和process(值为命名策略的对象hash值)。因此,在运行应用并产生一些指标后,你可以在TSD UI查看这些指标(默认路径为localhost:4242)。

示例:

curl localhost:4242/api/query?start=1h-ago&m=max:counter.status.200.root
[
    {
        "metric": "counter.status.200.root",
        "tags": {
            "domain": "org.springframework.metrics",
            "process": "b968a76"
        },
        "aggregateTags": [],
        "dps": {
            "1430492872": 2,
            "1430492875": 6
        }
    }
]

Last updated