11influxdb-java
22=============
33
4- A pure Java library to access the REST API of a InfluxDB database.
4+ This is the Java Client library which is only compatible with InfluxDB 0.9 and higher.
55
66This implementation is meant as a Java rewrite of the influxdb-go package.
77All low level REST Api calls are available.
@@ -10,29 +10,32 @@ Typical usage looks like:
1010
1111``` java
1212InfluxDB influxDB = InfluxDBFactory . connect(" http://172.17.0.2:8086" , " root" , " root" );
13-
14- this . influxDB. createDatabase(" aTimeSeries" );
15-
16- Serie serie1 = new Serie .Builder (" serie2Name" )
17- .columns(" column1" , " column2" )
18- .values(System . currentTimeMillis(), 1 )
19- .values(System . currentTimeMillis(), 2 )
20- .build();
21- Serie serie2 = new Serie .Builder (" serie2Name" )
22- .columns(" column1" , " column2" )
23- .values(System . currentTimeMillis(), 1 )
24- .values(System . currentTimeMillis(), 2 )
25- .build();
26- this . influxDB. write(dbName, TimeUnit . MILLISECONDS , serie1, serie2);
27-
13+ String dbName = " aTimeSeries" ;
14+ influxDB. createDatabase(dbName);
15+
16+ BatchPoints batchPoints = BatchPoints
17+ .database(dbName)
18+ .time(System . currentTimeMillis(), TimeUnit . MILLISECONDS )
19+ .tag(" async" , " true" )
20+ .retentionPolicy(" default" )
21+ .consistency(ConsistencyLevel . ALL )
22+ .build();
23+ Point point1 = Point . measurement(" cpu" ). field(" idle" , 90L ). field(" user" , 9L ). field(" system" , 1L ). build();
24+ Point point2 = Point . measurement(" disk" ). field(" used" , 80L ). field(" free" , 1L ). build();
25+ batchPoints. point(point1);
26+ batchPoints. point(point2);
27+ influxDB. write(batchPoints);
28+ Query query = new Query (" SELECT idle FROM cpu" , dbName);
29+ influxDB. query(query);
30+ influxDB. deleteDatabase(dbName)
2831```
2932
3033### Maven
3134```
3235 <dependency>
3336 <groupId>org.influxdb</groupId>
3437 <artifactId>influxdb-java</artifactId>
35- <version>1.5 </version>
38+ <version>2.0 </version>
3639 </dependency>
3740```
3841
@@ -41,7 +44,7 @@ For additional usage examples have a look at [InfluxDBTest.java](https://github.
4144
4245### Build Requirements
4346
44- * Java 1.6 +
47+ * Java 1.7 +
4548* Maven 3.0+
4649* Docker daemon running
4750
0 commit comments