Set up influxdb

This commit is contained in:
2024-11-08 13:05:05 +01:00
parent ec76048ee0
commit 29f1560272
5 changed files with 88 additions and 6 deletions

View File

@@ -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,
)
}

View 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,
)

View File

@@ -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 ###