Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miwurster/spring-data-influxdb
Spring Data InfluxDB
https://github.com/miwurster/spring-data-influxdb
Last synced: 4 months ago
JSON representation
Spring Data InfluxDB
- Host: GitHub
- URL: https://github.com/miwurster/spring-data-influxdb
- Owner: miwurster
- License: apache-2.0
- Created: 2016-03-31T13:27:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-06-04T22:01:17.000Z (over 3 years ago)
- Last Synced: 2024-08-02T16:38:15.657Z (7 months ago)
- Language: Java
- Homepage:
- Size: 73.2 KB
- Stars: 165
- Watchers: 24
- Forks: 60
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://travis-ci.org/miwurster/spring-data-influxdb)
[](https://www.codacy.com/app/miwurster/spring-data-influxdb?utm_source=github.com&utm_medium=referral&utm_content=miwurster/spring-data-influxdb&utm_campaign=Badge_Grade)
[](https://maven-badges.herokuapp.com/maven-central/com.github.miwurster/spring-data-influxdb)
[](https://jitpack.io/#miwurster/spring-data-influxdb)Spring Data InfluxDB
--------------------The primary goal of the [Spring Data](http://projects.spring.io/spring-data/) project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
This modules provides integration with the [InfluxDB](https://influxdata.com/) database and wraps the capabilities of the official [influxdb-java](https://github.com/influxdata/influxdb-java) library.
## Artifacts
### Maven
```xml
com.github.miwurster
spring-data-influxdb
1.8```
## Usage (Spring Boot)
* Following properties can be used in your `application.yml`:
```yml
spring:
influxdb:
url: http://localhost:8086
username: user
password: ~
database: test
retention-policy: autogen
```
Optionally, you can also configure connections, read, and write timeouts (in seconds):
```yml
spring:
influxdb:
connect-timeout: 10
read-timeout: 30
write-timeout: 10
```Furthermore, one can enable gzip compression in order to reduce size of the transferred data:
```yml
spring:
influxdb:
gzip: true
```* Create `InfluxDBConnectionFactory` and `InfluxDBTemplate` beans:
```java
@Configuration
@EnableConfigurationProperties(InfluxDBProperties.class)
public class InfluxDBConfiguration
{
@Bean
public InfluxDBConnectionFactory connectionFactory(final InfluxDBProperties properties)
{
return new InfluxDBConnectionFactory(properties);
}@Bean
public InfluxDBTemplate influxDBTemplate(final InfluxDBConnectionFactory connectionFactory)
{
/*
* You can use your own 'PointCollectionConverter' implementation, e.g. in case
* you want to use your own custom measurement object.
*/
return new InfluxDBTemplate<>(connectionFactory, new PointConverter());
}
@Bean
public DefaultInfluxDBTemplate defaultTemplate(final InfluxDBConnectionFactory connectionFactory)
{
/*
* If you are just dealing with Point objects from 'influxdb-java' you could
* also use an instance of class DefaultInfluxDBTemplate.
*/
return new DefaultInfluxDBTemplate(connectionFactory);
}
}
```* Use `InfluxDBTemplate` to interact with the InfluxDB database:
```java
@Autowired
private InfluxDBTemplate influxDBTemplate;influxDBTemplate.createDatabase();
final Point p = Point.measurement("disk")
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag("tenant", "default")
.addField("used", 80L)
.addField("free", 1L)
.build();
influxDBTemplate.write(p);
```## Building
Spring Data InfluxDB uses Maven as its build system.
```bash
mvn clean install
```