Configuring to use InfluxDB Cloud

I have a Spring Boot application and would like to use InfluxDB Cloud to store application metrics. Facade Micrometer seems a popular choice and has instructions for connection to an Influx DB server; The configuration options include uri, db, user-name and password. Influx DB Cloud configuration options are url, organisation id, bucket and access token. Are these directly substitutable? Please could someone point me to documentation or an example of configuring Micrometer to use InfluxDB Cloud?

Hi @NickDarlow,

currently the Micrometer doesn’t support InfluxDB v2 out of box. There is an issue about it - Could you add a comment there?

It will be help us to escalate our PR with InfluxDB v2 supports -

I will try prepare a workaround for you… stay tuned :wink:


Thanks @bednar. I’ve commented on your PR as requested.

Thanks @NickDarlow for comment.

I’ve prepared an example how to use a current version of Spring Boot to sent metrics into the InfluxDB v2.

We had to use a custom HttpSender to add required parameters into a HTTP request:

Custom HttpSender

package io.micrometer.boot2.samples;

import io.micrometer.boot2.samples.components.PersonController;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.ipc.http.OkHttpSender;
import io.micrometer.influx.InfluxConfig;
import io.micrometer.influx.InfluxMeterRegistry;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication(scanBasePackageClasses = PersonController.class)
public class InfluxSample {
    public static void main(String[] args) {
        new SpringApplicationBuilder(InfluxSample.class).profiles("influx").run(args);

    private String org;

    private String bucket;

    private String token;

    public InfluxMeterRegistry influxMeterRegistry(InfluxConfig influxConfig, Clock clock) {

        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {
            Request original = chain.request();

            // skip others than write
            if (!original.url().pathSegments().contains("write")) {
                 return  chain.proceed(original);

            HttpUrl url = original.url()
                    .addQueryParameter("org", org)
                    .addQueryParameter("bucket", bucket)

            Request request = original.newBuilder()
                    .header("Authorization", "Token " + token)

            return chain.proceed(request);

        return InfluxMeterRegistry.builder(influxConfig)
                .httpClient(new OkHttpSender(

Application configuration

    enabled: true
    step: PT10S
    readTimeout: PT30S
    batchSize: 20000
    uri: "http://localhost:9999"
    org: "my-org"
    bucket: "my-bucket"
    token: "my-token"
1 Like

Thanks very much for your assistance @bednar :+1:

You are welcome :handshake:

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.