千分尺发送指标为零-Spring Boot [英] Micrometer sending metrics zero - Spring Boot
问题描述
我正在使用Spring Boot 2 + Influx + Spring AOP来收集系统中的指标.
I'm using Spring Boot 2 + Influx + Spring AOP to collect metrics in my system.
所以,我有:
<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的类,请参阅:
I have a class that collect this metrics and send to influx, see:
@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显示如下内容:
When i send some value to influx this works very well, but spring keep sending "zero values" without my permission, filling my influx database. So my influxDB show something like this:
0
0
0
334 (My sent value)
0
0
0
0
0
推荐答案
您可以在yml文件中进行如下配置.
You can configure like this in yml file.
management:
metrics:
export:
influx:
uri: http://localhost:8086
db: mydbName
step: 10s
步长值应与您的预期流量相关.这样您就不会在其中看到90%的零.
step value should be related to your expected traffic. So that you dont see 90% of zeros there.
这篇关于千分尺发送指标为零-Spring Boot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!