diff --git a/README.md b/README.md index c3d2b10..a0795aa 100644 --- a/README.md +++ b/README.md @@ -4,31 +4,24 @@ Classes and endpoints, to shape and to steer, Devices and sensors, their purpose ## Properties for deployment -| name | required | info | -|----------------------------------------------|:--------:|----------------------------------------------| -| spring.profiles.active | ✓ | Spring Boot environment | -| server.port | ✓ | HTTP port | -| server.ssl.enabled | ✓ | HTTP Enable SSL | -| server.ssl.key-store | ✓ | HTTP Keystore | -| server.ssl.key-store-type | ✓ | HTTP Cert Type | -| server.ssl.key-store-password | ✗ | HTTP Cert Pass | -| spring.cache.type | | Cache type (redis) | -| spring.data.redis.host | ✓ | Redis host | -| spring.data.redis.port | | Redis port | -| spring.data.redis.database | ✓ | Redis database | -| spring.data.redis.password | ✗ | Redis password | -| cache.time-to-live | | Cache time to live (minutes) | -| jwt.public-key | ✓ | JWT public key | -| device-registry.url | ✓ | Device Register URL | -| device-data.url | ✓ | Device Data URL | -| device-configuration.url | ✓ | Device Configuration URL | -| management.influx.metrics.export.api-version | | InfluxDB API version | -| management.influx.metrics.export.enabled | | Enable/Disable exporting metrics to InfluxDB | -| management.influx.metrics.export.bucket | ✓ | InfluxDB bucket name | -| management.influx.metrics.export.org | ✓ | InfluxDB organization | -| management.influx.metrics.export.token | ✗ | InfluxDB token | -| management.influx.metrics.export.uri | ✓ | InfluxDB URL | -| management.metrics.tags.application | ✓ | Application instance tag for metrics | +| name | required | info | +|-------------------------------|:--------:|------------------------------| +| spring.profiles.active | ✓ | Spring Boot environment | +| server.port | ✓ | HTTP port | +| server.ssl.enabled | ✓ | HTTP Enable SSL | +| server.ssl.key-store | ✓ | HTTP Keystore | +| server.ssl.key-store-type | ✓ | HTTP Cert Type | +| server.ssl.key-store-password | ✗ | HTTP Cert Pass | +| spring.cache.type | | Cache type (redis) | +| spring.data.redis.host | ✓ | Redis host | +| spring.data.redis.port | | Redis port | +| spring.data.redis.database | ✓ | Redis database | +| spring.data.redis.password | ✗ | Redis password | +| cache.time-to-live | | Cache time to live (minutes) | +| jwt.public-key | ✓ | JWT public key | +| device-registry.url | ✓ | Device Register URL | +| device-data.url | ✓ | Device Data URL | +| device-configuration.url | ✓ | Device Configuration URL | *Required: ✓ can be stored as text, and ✗ need to be stored as secret.* diff --git a/build.gradle.kts b/build.gradle.kts index c938841..4f81d60 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,3 @@ -import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer - plugins { alias(hlaeja.plugins.kotlin.jvm) alias(hlaeja.plugins.kotlin.spring) @@ -15,7 +13,6 @@ dependencies { implementation(hlaeja.kotlin.logging) implementation(hlaeja.kotlin.reflect) implementation(hlaeja.kotlinx.coroutines) - implementation(hlaeja.micrometer.registry.influx) implementation(hlaeja.library.common.messages) implementation(hlaeja.library.jwt) implementation(hlaeja.springboot.starter.actuator) @@ -34,17 +31,6 @@ dependencies { group = "ltd.hlaeja" -fun influxDbToken(): String = config.findOrDefault("influxdb.token", "INFLUXDB_TOKEN", "") - -tasks { - named("containerCreate", DockerCreateContainer::class) { - withEnvVar("MANAGEMENT_INFLUX_METRICS_EXPORT_TOKEN", influxDbToken()) - } - withType { - filesMatching("**/application.yml") { filter { it.replace("%INFLUXDB_TOKEN%", influxDbToken()) } } - onlyIf { file("src/main/resources/application.yml").exists() } - } - named("processResources") { - dependsOn("copyCertificates") - } +tasks.named("processResources") { + dependsOn("copyCertificates") } diff --git a/src/main/kotlin/ltd/hlaeja/service/DeviceConfigurationService.kt b/src/main/kotlin/ltd/hlaeja/service/DeviceConfigurationService.kt index 8462837..b168da9 100644 --- a/src/main/kotlin/ltd/hlaeja/service/DeviceConfigurationService.kt +++ b/src/main/kotlin/ltd/hlaeja/service/DeviceConfigurationService.kt @@ -1,8 +1,6 @@ package ltd.hlaeja.service import io.github.oshai.kotlinlogging.KotlinLogging -import io.micrometer.core.instrument.Counter -import io.micrometer.core.instrument.MeterRegistry import java.util.UUID import ltd.hlaeja.library.deviceConfiguration.Node import ltd.hlaeja.property.DeviceConfigurationProperty @@ -18,29 +16,17 @@ private val log = KotlinLogging.logger {} @Service class DeviceConfigurationService( - meterRegistry: MeterRegistry, private val webClient: WebClient, private val deviceConfigurationProperty: DeviceConfigurationProperty, ) { - private val deviceConfigurationSuccess = Counter.builder("device.configuration.success") - .description("Number of successful device configuration calls") - .register(meterRegistry) - - private val deviceConfigurationFailure = Counter.builder("device.configuration.failure") - .description("Number of failed device configuration calls") - .register(meterRegistry) - suspend fun getConfiguration( node: UUID, ): Node.Response = try { webClient.deviceConfigurationGetConfiguration(node, deviceConfigurationProperty) - .also { deviceConfigurationSuccess.increment() } } catch (e: ErrorResponseException) { - deviceConfigurationFailure.increment() throw e } catch (e: WebClientRequestException) { - deviceConfigurationFailure.increment() log.error(e) { "Error device registry" } throw ResponseStatusException(SERVICE_UNAVAILABLE) } diff --git a/src/main/kotlin/ltd/hlaeja/service/DeviceDataService.kt b/src/main/kotlin/ltd/hlaeja/service/DeviceDataService.kt index aee3ff9..74e96f2 100644 --- a/src/main/kotlin/ltd/hlaeja/service/DeviceDataService.kt +++ b/src/main/kotlin/ltd/hlaeja/service/DeviceDataService.kt @@ -1,8 +1,6 @@ package ltd.hlaeja.service import io.github.oshai.kotlinlogging.KotlinLogging -import io.micrometer.core.instrument.Counter -import io.micrometer.core.instrument.MeterRegistry import java.util.UUID import ltd.hlaeja.library.deviceData.MeasurementData import ltd.hlaeja.property.DeviceDataProperty @@ -20,30 +18,18 @@ private val log = KotlinLogging.logger {} @Service class DeviceDataService( - meterRegistry: MeterRegistry, private val webClient: WebClient, private val deviceDataProperty: DeviceDataProperty, ) { - private val deviceDataSuccess = Counter.builder("device.data.success") - .description("Number of successful device data calls") - .register(meterRegistry) - - private val deviceDataFailure = Counter.builder("device.data.failure") - .description("Number of failed device data calls") - .register(meterRegistry) - suspend fun getMeasurement( client: UUID, node: UUID, ): MeasurementData.Response = try { webClient.deviceDataGetMeasurement(client, node, deviceDataProperty) - .also { deviceDataSuccess.increment() } } catch (e: ErrorResponseException) { - deviceDataFailure.increment() throw e } catch (e: WebClientRequestException) { - deviceDataFailure.increment() log.error(e) { "Error device registry" } throw ResponseStatusException(SERVICE_UNAVAILABLE) } @@ -53,12 +39,9 @@ class DeviceDataService( request: MeasurementData.Request, ): ResponseEntity = try { webClient.deviceDataAddMeasurement(client, request, deviceDataProperty) - .also { deviceDataSuccess.increment() } } catch (e: ErrorResponseException) { - deviceDataFailure.increment() throw e } catch (e: WebClientRequestException) { - deviceDataFailure.increment() log.error(e) { "Error device registry" } throw ResponseStatusException(SERVICE_UNAVAILABLE) } diff --git a/src/main/kotlin/ltd/hlaeja/service/DeviceRegistryService.kt b/src/main/kotlin/ltd/hlaeja/service/DeviceRegistryService.kt index ef4d035..99a859e 100644 --- a/src/main/kotlin/ltd/hlaeja/service/DeviceRegistryService.kt +++ b/src/main/kotlin/ltd/hlaeja/service/DeviceRegistryService.kt @@ -1,8 +1,6 @@ package ltd.hlaeja.service import io.github.oshai.kotlinlogging.KotlinLogging -import io.micrometer.core.instrument.Counter -import io.micrometer.core.instrument.MeterRegistry import java.util.UUID import ltd.hlaeja.library.deviceRegistry.Identity import ltd.hlaeja.property.DeviceRegistryProperty @@ -19,30 +17,18 @@ private val log = KotlinLogging.logger {} @Service class DeviceRegistryService( - meterRegistry: MeterRegistry, private val webClient: WebClient, private val deviceRegistryProperty: DeviceRegistryProperty, ) { - private val identityDeviceSuccess = Counter.builder("device.identity.success") - .description("Number of successful device identity calls") - .register(meterRegistry) - - private val identityDeviceFailure = Counter.builder("device.identity.failure") - .description("Number of failed device identity calls") - .register(meterRegistry) - @Cacheable(value = ["identity"], key = "#device") suspend fun getIdentityFromDevice( device: UUID, ): Identity.Response = try { webClient.deviceRegistryIdentityDevice(device, deviceRegistryProperty) - .also { identityDeviceSuccess.increment() } } catch (e: ErrorResponseException) { - identityDeviceFailure.increment() throw e } catch (e: WebClientRequestException) { - identityDeviceFailure.increment() log.error(e) { "Error device identity" } throw ResponseStatusException(SERVICE_UNAVAILABLE) } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cbbc4ea..8355c54 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -29,12 +29,6 @@ management: access: read_only info: access: read_only - influx: - metrics: - export: - api-version: v2 - bucket: hlaeja - org: hlaeja_ltd cache: time-to-live: 10 @@ -54,16 +48,6 @@ spring: redis: host: localhost -management: - metrics: - tags: - application: device-api - influx: - metrics: - export: - enabled: false - token: %INFLUXDB_TOKEN% - server: port: 8443 ssl: @@ -93,15 +77,6 @@ spring: redis: host: Redis -management: - metrics: - tags: - application: device-api - influx: - metrics: - export: - uri: http://InfluxDB:8086 - server: port: 8443 ssl: