简体   繁体   English

千分尺发送指标为零-Spring Boot

[英]Micrometer sending metrics zero - Spring Boot

I'm using Spring Boot 2 + Influx + Spring AOP to collect metrics in my system. 我正在使用Spring Boot 2 + Influx + Spring AOP来收集系统中的指标。

SO, i have: 所以我有:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>


        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-influx</artifactId>
        </dependency>

I have a class that collect this metrics and send to influx, see: 我有一个收集此指标并发送给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;
    }
}

When i send some value to influx this works very well, but spring keep sending "zero values" without my permission, filling my influx database. 当我向Influx发送一些值时,效果很好,但是在未经我允许的情况下,Spring继续发送“零值”,从而填充了我的Influx数据库。 So my influxDB show something like this: 所以我的influxDB显示如下:

0
0
0
334 (My sent value)
0
0
0
0
0

You can configure like this in yml file. 您可以在yml文件中进行这样的配置。

 management: metrics: export: influx: uri: http://localhost:8086 db: mydbName step: 10s 

step value should be related to your expected traffic. 步长值应与您的预期流量相关。 So that you dont see 90% of zeros there. 这样您就不会在其中看到90%的零。

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

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