diff --git a/.env.ping-test b/.env.ping-test index dc8a8c94..92874efd 100644 --- a/.env.ping-test +++ b/.env.ping-test @@ -7,4 +7,4 @@ POSTGRES_DB=mypingtest DEBUG=true # JVM Configuration -JAVA_OPTS=-Xmx1g -XX:+UseG1GC -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 +JAVA_OPTS='-Xmx1g -XX:+UseG1GC -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' diff --git a/docker-compose.services.yml b/docker-compose.services.yml index fb548150..bf3ef58f 100644 --- a/docker-compose.services.yml +++ b/docker-compose.services.yml @@ -20,7 +20,7 @@ services: SERVER_PORT: ${PING_SERVICE_PORT:-8082} CONSUL_HOST: consul CONSUL_PORT: ${CONSUL_PORT:-8500} - CONSUL_ENABLED: ${CONSUL_ENABLED:-true} + CONSUL_ENABLED: true DB_HOST: postgres DB_PORT: 5432 DB_NAME: ${POSTGRES_DB:-meldestelle} diff --git a/docker-compose.yml b/docker-compose.yml index 53e6ec43..d73fe8b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,7 +67,7 @@ services: KC_DB_USERNAME: ${POSTGRES_USER:-meldestelle} KC_DB_PASSWORD: ${POSTGRES_PASSWORD:-meldestelle} ports: - - "8180:8080" + - "8180:8081" depends_on: postgres: condition: service_healthy @@ -77,7 +77,7 @@ services: networks: - meldestelle-network healthcheck: - test: [ "CMD", "curl", "--fail", "http://localhost:8080/health/ready" ] + test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8081/" ] interval: 10s timeout: 5s retries: 3 diff --git a/docker/monitoring/prometheus/prometheus.yml b/docker/monitoring/prometheus/prometheus.yml new file mode 100644 index 00000000..34db49bd --- /dev/null +++ b/docker/monitoring/prometheus/prometheus.yml @@ -0,0 +1,38 @@ +# Prometheus configuration for Meldestelle project +# Basic configuration to enable service monitoring + +global: + scrape_interval: 15s + evaluation_interval: 15s + +rule_files: + # - "first_rules.yml" + # - "second_rules.yml" + +scrape_configs: + # The job name is added as a label `job=` to any timeseries scraped from this config. + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + # Monitor API Gateway + - job_name: 'api-gateway' + metrics_path: '/actuator/prometheus' + static_configs: + - targets: ['api-gateway:8081'] + scrape_interval: 30s + + # Monitor other services if they expose metrics + - job_name: 'postgres-exporter' + static_configs: + - targets: ['postgres:5432'] + scrape_interval: 30s + metrics_path: '/metrics' + + # Add consul for service discovery monitoring + - job_name: 'consul' + static_configs: + - targets: ['consul:8500'] + metrics_path: '/v1/agent/metrics' + params: + format: ['prometheus'] diff --git a/dockerfiles/services/ping-service/Dockerfile b/dockerfiles/services/ping-service/Dockerfile index 027579ae..42bd0ec6 100644 --- a/dockerfiles/services/ping-service/Dockerfile +++ b/dockerfiles/services/ping-service/Dockerfile @@ -86,6 +86,11 @@ ARG VERSION=1.0.0 ARG JAVA_VERSION=21 ARG SPRING_PROFILES_ACTIVE=default +# Convert build arguments to environment variables +ENV JAVA_VERSION=${JAVA_VERSION} \ + VERSION=${VERSION} \ + BUILD_DATE=${BUILD_DATE} + # Add comprehensive metadata LABEL service="ping-service" \ version="${VERSION}" \ diff --git a/temp/ping-service/src/main/resources/application.yml b/temp/ping-service/src/main/resources/application.yml index e2396eea..8a7d603f 100644 --- a/temp/ping-service/src/main/resources/application.yml +++ b/temp/ping-service/src/main/resources/application.yml @@ -3,9 +3,10 @@ spring: name: ping-service cloud: consul: - host: localhost - port: 8500 + host: ${CONSUL_HOST:localhost} + port: ${CONSUL_PORT:8500} discovery: + enabled: true register: true health-check-path: /actuator/health health-check-interval: 10s