fixing gateway prometheus

This commit is contained in:
stefan
2025-09-16 13:08:25 +02:00
parent f81e52388c
commit e40f3d9453
6 changed files with 17 additions and 21 deletions
@@ -29,7 +29,7 @@ class GatewayMetricsConfig {
companion object {
// Metric Namen als Konstanten für bessere Wartbarkeit
const val GATEWAY_REQUEST_TIMER = "gateway_request_duration"
const val GATEWAY_REQUEST_TIMER = "gateway_custom_request_duration"
const val GATEWAY_ERROR_COUNTER = "gateway_errors_total"
const val GATEWAY_REQUESTS_COUNTER = "gateway_requests_total"
const val GATEWAY_CIRCUIT_BREAKER_COUNTER = "gateway_circuit_breaker_events_total"
@@ -72,15 +72,11 @@ class GatewayMetricsConfig {
}
/**
* Bean für Request Duration Timer - ermöglicht manuelle Messungen.
* Bean für Request Duration Timer - entfernt um Konflikte mit dem WebFilter zu vermeiden.
* Die Request-Zeiten werden automatisch im GatewayMetricsWebFilter erfasst.
*/
@Bean
fun requestTimer(meterRegistry: MeterRegistry): Timer {
return Timer.builder(GATEWAY_REQUEST_TIMER)
.description("Gateway Request-Verarbeitungszeit")
.tag("type", "http")
.register(meterRegistry)
}
// @Bean - Entfernt um Prometheus Meter-Konflikte zu vermeiden
// fun requestTimer(meterRegistry: MeterRegistry): Timer { ... }
/**
* Bean für Error Counter - ermöglicht manuelles Error Tracking.
@@ -225,21 +225,19 @@ management:
metrics:
distribution:
percentiles-histogram:
spring.cloud.gateway.requests: true
http.server.requests: true
percentiles:
spring.cloud.gateway.requests: 0.5,0.90,0.95,0.99
http.server.requests: 0.5,0.90,0.95,0.99
minimum-expected-value:
spring.cloud.gateway.requests: 1ms
http.server.requests: 1ms
maximum-expected-value:
spring.cloud.gateway.requests: 30s
http.server.requests: 30s
tags:
application: ${spring.application.name}
environment: ${spring.profiles.active}
instance: ${spring.cloud.consul.discovery.instance-id}
service: gateway
component: infrastructure
gateway: api-gateway
info:
env:
@@ -252,12 +250,15 @@ management:
enabled: true
# Tracing-Konfiguration - Aktiviert (Micrometer Tracing + Zipkin)
tracing:
enabled: true
enabled: ${TRACING_ENABLED:false}
sampling:
probability: ${TRACING_SAMPLING_PROBABILITY:1.0}
zipkin:
tracing:
endpoint: ${ZIPKIN_TRACING_ENDPOINT:http://zipkin:9411/api/v2/spans}
endpoint: ${ZIPKIN_TRACING_ENDPOINT:http://localhost:9411/api/v2/spans}
# Reduziert Verbindungsfehler wenn Zipkin nicht verfügbar ist
connect-timeout: 1s
read-timeout: 10s
# Erweiterte Logging-Konfiguration
logging:
@@ -274,7 +275,7 @@ logging:
console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr([%X{correlationId:-}]){yellow} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{correlationId:-}] %logger{36} - %msg%n"
file:
name: logs/gateway.log
name: infrastructure/gateway/logs/gateway.log
logback:
rolling policy:
clean-history-on-start: true