springspring-bootinfluxdbspring-micrometertelegraf-output-plugins

Import data from Influxdb_V2 to Spring Boot application


I am trying to fetch data from influxdb(version 2) bucket into my Spring Boot application. I have not found any references on google to implement this feature. Can anyone help me in this my providing any references or documentation so I can implement this feature.


Solution

  • String token = "tokenDetails";
            String bucket = "test123";
            String org = "test";
            InfluxDBClient client = InfluxDBClientFactory.create("https:localhost:8086/",
                    token.toCharArray());
    
            String query = String.format("from(bucket: \"%s\") |> range(start: -15m)", bucket);
            List<FluxTable> tables = client.getQueryApi().query(query, org);
    

    Iterate on tables and records to operate on data.