remove influx monitoring

This commit is contained in:
2025-04-06 18:21:51 +02:00
parent 7cc40e7fc6
commit 503e307c69
5 changed files with 0 additions and 74 deletions

View File

@@ -15,13 +15,6 @@ Classes and endpoints, to shape and to steer, Devices and sensors, their purpose
| jwt.public-key | ✓ | JWT public key file | | jwt.public-key | ✓ | JWT public key file |
| account-registry.url | ✓ | Account Register URL | | account-registry.url | ✓ | Account Register URL |
| device-registry.url | ✓ | Device Register URL | | device-registry.url | ✓ | Device Register 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.* *Required: ✓ can be stored as text, and ✗ need to be stored as secret.*

View File

@@ -1,5 +1,3 @@
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
plugins { plugins {
alias(hlaeja.plugins.kotlin.jvm) alias(hlaeja.plugins.kotlin.jvm)
alias(hlaeja.plugins.kotlin.spring) alias(hlaeja.plugins.kotlin.spring)
@@ -17,7 +15,6 @@ dependencies {
implementation(hlaeja.kotlinx.coroutines) implementation(hlaeja.kotlinx.coroutines)
implementation(hlaeja.library.hlaeja.common.messages) implementation(hlaeja.library.hlaeja.common.messages)
implementation(hlaeja.library.hlaeja.jwt) implementation(hlaeja.library.hlaeja.jwt)
implementation(hlaeja.micrometer.registry.influx)
implementation(hlaeja.springboot.starter.actuator) implementation(hlaeja.springboot.starter.actuator)
implementation(hlaeja.springboot.starter.security) implementation(hlaeja.springboot.starter.security)
implementation(hlaeja.springboot.starter.webflux) implementation(hlaeja.springboot.starter.webflux)
@@ -33,16 +30,7 @@ dependencies {
group = "ltd.hlaeja" group = "ltd.hlaeja"
fun influxDbToken(): String = config.findOrDefault("influxdb.token", "INFLUXDB_TOKEN", "")
tasks { 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") { named("processResources") {
dependsOn("copyCertificates") dependsOn("copyCertificates")
} }

View File

@@ -1,8 +1,6 @@
package ltd.hlaeja.service package ltd.hlaeja.service
import io.github.oshai.kotlinlogging.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.MeterRegistry
import ltd.hlaeja.library.accountRegistry.Authentication import ltd.hlaeja.library.accountRegistry.Authentication
import ltd.hlaeja.property.AccountRegistryProperty import ltd.hlaeja.property.AccountRegistryProperty
import ltd.hlaeja.util.accountRegistryAuthenticate import ltd.hlaeja.util.accountRegistryAuthenticate
@@ -19,33 +17,20 @@ private val log = KotlinLogging.logger {}
@Service @Service
class AuthenticationService( class AuthenticationService(
meterRegistry: MeterRegistry,
private val webClient: WebClient, private val webClient: WebClient,
private val property: AccountRegistryProperty, private val property: AccountRegistryProperty,
) { ) {
private val accountRegistrySuccess = Counter.builder("account.registry.success")
.description("Number of successful account registry calls")
.register(meterRegistry)
private val accountRegistryFailure = Counter.builder("account.registry.failure")
.description("Number of failed account registry calls")
.register(meterRegistry)
suspend fun authenticate( suspend fun authenticate(
request: Authentication.Request, request: Authentication.Request,
): Authentication.Response = try { ): Authentication.Response = try {
webClient.accountRegistryAuthenticate(request, property) webClient.accountRegistryAuthenticate(request, property)
.also { accountRegistrySuccess.increment() }
} catch (e: ErrorResponseException) { } catch (e: ErrorResponseException) {
accountRegistryFailure.increment()
throw e throw e
} catch (e: WebClientRequestException) { } catch (e: WebClientRequestException) {
accountRegistryFailure.increment()
log.error(e) { "Error device registry" } log.error(e) { "Error device registry" }
throw ResponseStatusException(SERVICE_UNAVAILABLE) throw ResponseStatusException(SERVICE_UNAVAILABLE)
} catch (e: WebClientResponseException) { } catch (e: WebClientResponseException) {
accountRegistryFailure.increment()
log.error(e) { "Error device registry" } log.error(e) { "Error device registry" }
throw ResponseStatusException(INTERNAL_SERVER_ERROR) throw ResponseStatusException(INTERNAL_SERVER_ERROR)
} }

View File

@@ -1,8 +1,6 @@
package ltd.hlaeja.service package ltd.hlaeja.service
import io.github.oshai.kotlinlogging.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.MeterRegistry
import ltd.hlaeja.library.deviceRegistry.Device import ltd.hlaeja.library.deviceRegistry.Device
import ltd.hlaeja.property.DeviceRegistryProperty import ltd.hlaeja.property.DeviceRegistryProperty
import ltd.hlaeja.util.deviceRegistryCreateDevice import ltd.hlaeja.util.deviceRegistryCreateDevice
@@ -19,33 +17,20 @@ private val log = KotlinLogging.logger {}
@Service @Service
class DeviceRegistryService( class DeviceRegistryService(
meterRegistry: MeterRegistry,
private val webClient: WebClient, private val webClient: WebClient,
private val deviceRegistryProperty: DeviceRegistryProperty, private val deviceRegistryProperty: DeviceRegistryProperty,
) { ) {
private val registerDeviceSuccess = Counter.builder("device.registry.success")
.description("Number of successful device registrations")
.register(meterRegistry)
private val registerDeviceFailure = Counter.builder("device.registry.failure")
.description("Number of failed device registrations")
.register(meterRegistry)
suspend fun registerDevice( suspend fun registerDevice(
request: Device.Request, request: Device.Request,
): Device.Response = try { ): Device.Response = try {
webClient.deviceRegistryCreateDevice(request, deviceRegistryProperty) webClient.deviceRegistryCreateDevice(request, deviceRegistryProperty)
.also { registerDeviceSuccess.increment() }
} catch (e: ErrorResponseException) { } catch (e: ErrorResponseException) {
registerDeviceFailure.increment()
throw e throw e
} catch (e: WebClientRequestException) { } catch (e: WebClientRequestException) {
registerDeviceFailure.increment()
log.error(e) { "Error device registry" } log.error(e) { "Error device registry" }
throw ResponseStatusException(SERVICE_UNAVAILABLE) throw ResponseStatusException(SERVICE_UNAVAILABLE)
} catch (e: WebClientResponseException) { } catch (e: WebClientResponseException) {
registerDeviceFailure.increment()
log.error(e) { "Error device registry" } log.error(e) { "Error device registry" }
throw ResponseStatusException(INTERNAL_SERVER_ERROR) throw ResponseStatusException(INTERNAL_SERVER_ERROR)
} }

View File

@@ -22,12 +22,6 @@ management:
show-details: always show-details: always
info: info:
enabled: true enabled: true
influx:
metrics:
export:
api-version: v2
bucket: hlaeja
org: hlaeja_ltd
jwt: jwt:
public-key: cert/public_key.pem public-key: cert/public_key.pem
@@ -55,16 +49,6 @@ account-registry:
device-registry: device-registry:
url: http://localhost:9010 url: http://localhost:9010
management:
metrics:
tags:
application: register-api
influx:
metrics:
export:
enabled: false
token: %INFLUXDB_TOKEN%
--- ---
########################## ##########################
### Docker environment ### ### Docker environment ###
@@ -74,15 +58,6 @@ spring:
activate: activate:
on-profile: docker on-profile: docker
management:
metrics:
tags:
application: register-api
influx:
metrics:
export:
uri: http://InfluxDB:8086
server: server:
port: 8443 port: 8443
ssl: ssl: