简体   繁体   English

将服务器名称添加到Datadog的指标

[英]Add server name to metrics for Datadog

I use dropwizard metrics with metrics-datadog . 我将dropwizard指标metrics-datadog一起使用

Create reported like this: 创建报告如下:

HttpTransport httpTransport = new HttpTransport.Builder().withApiKey(API_KEY).build();

DatadogReporter reporter;
reporter = DatadogReporter.forRegistry(metrics)
            .withTransport(httpTransport)
            .withPrefix(PREFIX)
            .withTags(tags)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build();

reporter.start(value, unit);

But there is no host(server name) param in datadog. 但是datadog中没有主机(服务器名称)参数。 How can I add host (server name) for metrics to filter them in datadog control panel? 如何为指标添加主机(服务器名称)以在datadog控制面板中对其进行过滤? Metrics from default datadog agent has server name attribute. 默认datadog代理的指标具有服务器名称属性。

只需为org.coursera.metrics.datadog.DatadogReporter.Builder设置主机名:

.withHost(InetAddress.getLocalHost().getCanonicalHostName())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM