我正在使用 Spring Boot 2 + Influx + Spring AOP 在我的系统中收集指标。
所以,我有:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-influx</artifactId>
</dependency>
我有一个收集这些指标并发送到 influx 的类,请参阅:
@Aspect
@Configuration
@RequiredArgsConstructor
@Slf4j
public class TimerCounterAspect {
private final MicrometerFactory micrometerFactory;
@Around("@annotation(br.com.myproject.TimerCount)")
public Object around(ProceedingJoinPoint joinPoint) {
Timer.Sample sample = micrometerFactory.starTimer();
micrometerFactory.counterIncrement(joinPoint.getTarget().getClass());
Object oReturn;
try {
oReturn = joinPoint.proceed();
} catch (Throwable throwable) {
micrometerFactory.counterErrorIncrement(joinPoint.getTarget().getClass());
log.error("Falha ao processar JoinPoint", throwable);
throw new RuntimeException(throwable);
} finally {
micrometerFactory.stopTimer(joinPoint.getTarget().getClass(), sample);
}
return oReturn;
}
}
当我向 influx 发送一些值时,效果很好,但是 spring 未经我的许可不断发送“零值”,填满了我的 influx 数据库。所以我的 influxDB 显示如下:
0
0
0
334 (My sent value)
0
0
0
0
0
最佳答案
你可以在yml文件中这样配置。
management:
metrics:
export:
influx:
uri: http://localhost:8086
db: mydbName
step: 10s
步长值应与您的预期流量相关。这样您就不会在那里看到 90% 的零。
关于spring - 千分尺发送指标为零 - Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53177649/