How to set signalfx.accessToken in spring application

276 Views Asked by At

I have have tried pushing custom metrics to splunk apm using below dependency and setting the properties using springboot application

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

Properties

management.metrics.export.signalfx.access-token= <token>
management.metrics.export.signalfx.enabled=true
management.metrics.export.signalfx.uri=<uri>
management.metrics.export.signalfx.source=testservice

Now there is a requirement to try pushing from spring mvc application and I have added same dependency in the pom and created custom metric code as below but I am getting error while spring application is deployed

        MeterRegistry resgRegistry = new SignalFxMeterRegistry(new SignalFxConfig() {

        @Override
        public String get(String key) {
            // TODO Auto-generated method stub
            return null;
        }
    }, Clock.SYSTEM);

    Timer myTimer = Timer.builder("surya_timer").register(Metrics.globalRegistry);
    Timer timer = Timer.builder("test").register(resgRegistry);

    timer.record(Duration.ofMillis(123));
    myTimer.record(Duration.ofMillis(567));

Error

io.micrometer.core.instrument.config.validate.ValidationException: signalfx.accessToken was 'null' but it is required
io.micrometer.core.instrument.config.validate.Validated$Either.orThrow(Validated.java:375)
io.micrometer.core.instrument.config.MeterRegistryConfig.requireValid(MeterRegistryConfig.java:49)
io.micrometer.core.instrument.push.PushMeterRegistry.<init>(PushMeterRegistry.java:42)
io.micrometer.core.instrument.step.StepMeterRegistry.<init>(StepMeterRegistry.java:43)
io.micrometer.signalfx.SignalFxMeterRegistry.<init>(SignalFxMeterRegistry.java:78)
io.micrometer.signalfx.SignalFxMeterRegistry.<init>(SignalFxMeterRegistry.java:74)

Please help me How to set this access token in the spring application

0

There are 0 best solutions below