3

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
Ronaldo Lanhellas
  • 2,975
  • 5
  • 46
  • 92

1 Answers1

0

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.

Khwaja Sanjari
  • 455
  • 5
  • 17
  • This don't solve my problem and create another. 1) Using 10s in step accumulate the values. 2) If in 10s don't have any metric spring will sent zero. – Ronaldo Lanhellas Nov 06 '18 at 19:37
  • 1
    Please refer for now https://touk.pl/blog/2018/03/05/spring-boot-2-0-http-request-metrics-with-micrometer/ Will try to investigate more on it. – Khwaja Sanjari Nov 06 '18 at 19:55
  • I'm getting below error can you please help me and I have configured in yml file [SpringContextShutdownHook] ERROR i.m.influx.InfluxMeterRegistry - failed to send metrics to influx java.net.SocketTimeoutException: Read timed out – nitinsridar May 06 '20 at 10:26