Skip to content

Spring cloud influxDB service connectors to use influxDB in cloud platforms such as Cloud Foundry

License

Notifications You must be signed in to change notification settings

orange-cloudfoundry/spring-cloud-influxdb-connectors

Repository files navigation

spring-cloud-influxdb-connectors

Build Status Apache Version 2 Licence Download

Join the chat at https://gitter.im/orange-cloudfoundry/elpaaso

Spring cloud influxDB service connectors to use influxDB in CloudFoundry.

You can find an example app here: https://github.com/orange-cloudfoundry/influxdb-connectors-poc

Service Detection

The connectors will check for an existing bound service with:

  • tags including influxdb

  • label beginning with the influxdb tag

The connectors will also check for an existing bound user-provided service with:

  • name beginning with the influxdb tag

Getting started

Import repositories to your project

Maven:

<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>bintray-elpaaso-maven</id>
        <name>bintray</name>
        <url>http://dl.bintray.com/elpaaso/maven</url>
    </repository>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray</name>
        <url>http://jcenter.bintray.com</url>
    </repository>
</repositories>

Gradle:

repositories {
    // ...
    jcenter()
    maven { url "http://dl.bintray.com/elpaaso/maven" }
}

Add a connector to your project

First, make a version property:

Maven:

<properties>
    <influxdb.connectors.version>1.0.6</influxdb.connectors.version>
</properties>

Gradle:

ext {
	$influxDBConnectorsVersion = "1.0.6"
}

Add a connector to your project

Cloud Foundry

Maven:

<dependency>
    <groupId>com.orange.spring.cloud.connectors</groupId>
    <artifactId>spring-cloud-influxdb-connectors-cloudfoundry</artifactId>
    <version>${influxdb.connectors.version}</version>
</dependency>

Gradle:

dependencies {
  compile("com.orange.spring.cloud.connectors:spring-cloud-influxdb-connectors-cloudfoundry:$influxDBConnectorsVersion")
}

Use it !

Here the bootstrap for your spring boot app to get a InfluxDB java client which will help you to manipulate your influxDB database:

Usage example:

@Component
public class ScheduledInfluxDBExporter {

    Logger logger = Logger.getLogger(ScheduledInfluxDBExporter.class);
    
    @Autowired
    private InfluxDB influxDB;

    @Scheduled(fixedRate = 5000)
    public void sendData() throws Exception {
        logger.debug("sending data to influxdb");
        
        Random rand = new Random();
        int value = rand.nextInt(10);

        Point point = Point.measurement("a_metric")
                .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
                .addField("value", value)
                .build();
        this.influxDB.write(point);
    }
}

Deploy and run

Cloud Foundry

  1. Create an influxDB service Since no influxDB service offering seems to be available in any marketplace, you can use an influxDB service by creating the following user provided service.
$cf cups influxdb-service -p '{"dbname": "<DB_NAME>", "hostname": "<HOSTNAME>", "password": "<PASSWORD>", "port": "<PORT>", "uri": "<URI>", "username": "<USERNAME>"}'
  1. Push your app with cf push
  2. After the app has been pushed bind your new created service to your app (e.g: cf bs nameofmyapp influxdb-service)
  3. Restage your app: cf restage nameofmyapp

Heroku

Not supported

Locally

Not supported

Examples

You can find an example app here: https://github.com/orange-cloudfoundry/influxdb-connectors-poc

Contributing

Report any issues or pull request on this repo.

About

Spring cloud influxDB service connectors to use influxDB in cloud platforms such as Cloud Foundry

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published