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
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
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" }
}
First, make a version property:
Maven:
<properties>
<influxdb.connectors.version>1.0.6</influxdb.connectors.version>
</properties>
Gradle:
ext {
$influxDBConnectorsVersion = "1.0.6"
}
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")
}
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);
}
}
- 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>"}'
- Push your app with
cf push
- After the app has been pushed bind your new created service to your app (e.g:
cf bs nameofmyapp influxdb-service
) - Restage your app:
cf restage nameofmyapp
Not supported
Not supported
You can find an example app here: https://github.com/orange-cloudfoundry/influxdb-connectors-poc
Report any issues or pull request on this repo.