Micrometer sending metrics zero - Spring Boot

Viewed 1795

I'm using Spring Boot 2 + Influx + Spring AOP to collect metrics in my system.

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:

@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. So my influxDB show something like this:

0
0
0
334 (My sent value)
0
0
0
0
0
1 Answers

You can configure like this in yml file.

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.

Related