Set up influxdb
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package ltd.hlaeja.configuration
|
||||
|
||||
import com.influxdb.client.InfluxDBClient
|
||||
import com.influxdb.client.InfluxDBClientFactory
|
||||
import ltd.hlaeja.properties.InfluxDbProperties
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(InfluxDbProperties::class)
|
||||
class InfluxDbConfiguration(
|
||||
private val properties: InfluxDbProperties,
|
||||
) {
|
||||
|
||||
@Bean
|
||||
fun influxDBClient(): InfluxDBClient = InfluxDBClientFactory.create(
|
||||
properties.url,
|
||||
properties.token.toCharArray(),
|
||||
properties.org,
|
||||
properties.bucket,
|
||||
)
|
||||
}
|
||||
11
src/main/kotlin/ltd/hlaeja/properties/InfluxDbProperties.kt
Normal file
11
src/main/kotlin/ltd/hlaeja/properties/InfluxDbProperties.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package ltd.hlaeja.properties
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties(prefix = "influxdb")
|
||||
data class InfluxDbProperties(
|
||||
val url: String,
|
||||
val token: String,
|
||||
val org: String,
|
||||
val bucket: String,
|
||||
)
|
||||
@@ -10,6 +10,10 @@ spring:
|
||||
name: "%APP_BUILD_OS_NAME%"
|
||||
version: "%APP_BUILD_OS_VERSION%"
|
||||
|
||||
influxdb:
|
||||
bucket: device-data
|
||||
org: hlaeja_ltd
|
||||
|
||||
---
|
||||
###############################
|
||||
### Development environment ###
|
||||
@@ -19,6 +23,10 @@ spring:
|
||||
activate:
|
||||
on-profile: development
|
||||
|
||||
influxdb:
|
||||
token: %INFLUXDB_TOKEN%
|
||||
url: http://localhost:8086
|
||||
|
||||
---
|
||||
##########################
|
||||
### Docker environment ###
|
||||
@@ -28,6 +36,9 @@ spring:
|
||||
activate:
|
||||
on-profile: docker
|
||||
|
||||
influxdb:
|
||||
url: http://InfluxDB:8086
|
||||
|
||||
---
|
||||
##############################
|
||||
### Production environment ###
|
||||
|
||||
Reference in New Issue
Block a user