spring - 无法在使用 statsd 为 Springboot 应用程序发送的数据狗中查看自定义指标
问题描述
我有一个spring boot应用程序,我正在尝试使用statsd和meterregistry将自定义指标发送到datadog,我可以使用'/actuator/metrics' url查看指标,但在datadog中看不到任何内容。
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>java-dogstatsd-client</artifactId>
<version>2.10.1</version>
</dependency>
班级:
private final MeterRegistry meterRegistry;
public Starter(@Lazy @Autowired MeterRegistry meterRegistry) {
this.meterRegistry = new SimpleMeterRegistry();
Counter counter = Counter
.builder("test_counter")
.baseUnit("beans") // optional
.description("a description of what this counter does") // optional
.tags("region", "test") // optional
.register(meterRegistry);
Timer.builder("test.timer")
.publishPercentiles(0.95)
.register(meterRegistry);
应用程序.yml
management:
metrics:
enable:
all: true
export:
statsd:
flavor: datadog
host: localhost
port: 8125
protocol: udp
解决方案
推荐阅读
- javascript - 删除具有相同状态的重复记录并仅保留最新记录
- css - 我尝试使用横幅背景,但它不能正常工作?我已将此代码放在我的头部
- reactjs - 未找到与该模式匹配的文件:“'**/*.js'”
- python - 给定一个指示段边界的值,为张量生成段标签
- linux - 如何在 Linux 的 Monodevelop 中打开 Unity3d 类的自动完成功能?
- django - CSRF cookie 未在 chrome 中设置 Django 跨站点 iframe
- oracle - Oracle - 如何将日期时间转换为 TZ 格式?
- apache-spark - 如何从 PySpark 的嵌套目录中读取多个 CSV(省略特定的)?
- php - 将 cURL CMD 更改为 cURL PHP
- python - 正则表达式:删除不以特定字符为前缀的字符串