remove metrics collection
This commit is contained in:
@@ -5,7 +5,7 @@ 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 |
|
||||
@@ -22,13 +22,6 @@ Classes and endpoints, to shape and to steer, Devices and sensors, their purpose
|
||||
| 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 |
|
||||
|
||||
*Required: ✓ can be stored as text, and ✗ need to be stored as secret.*
|
||||
|
||||
|
||||
@@ -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<ProcessResources> {
|
||||
filesMatching("**/application.yml") { filter { it.replace("%INFLUXDB_TOKEN%", influxDbToken()) } }
|
||||
onlyIf { file("src/main/resources/application.yml").exists() }
|
||||
}
|
||||
named("processResources") {
|
||||
tasks.named("processResources") {
|
||||
dependsOn("copyCertificates")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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<Void> = 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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user