From 8dc340c1c2bb8da99a63c9cd58e283266f7b7ee0 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Tue, 19 Aug 2025 15:36:52 +0200 Subject: [PATCH] Support prometheus metrics Issue-ID: SDC-4760 Change-Id: I2954601229e5ce02dd8a95b66439e3bc55f0016d Signed-off-by: Fiete Ostkamp --- sdc-workflow-designer-be/pom.xml | 4 ++ .../src/main/resources/application.properties | 1 + .../java/org/onap/sdc/workflow/MetricsTest.java | 48 ++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java diff --git a/sdc-workflow-designer-be/pom.xml b/sdc-workflow-designer-be/pom.xml index d6c8c0ed..e89a5174 100644 --- a/sdc-workflow-designer-be/pom.xml +++ b/sdc-workflow-designer-be/pom.xml @@ -221,6 +221,10 @@ spring-boot-starter-actuator provided + + io.micrometer + micrometer-registry-prometheus + org.apache.commons commons-text diff --git a/sdc-workflow-designer-be/src/main/resources/application.properties b/sdc-workflow-designer-be/src/main/resources/application.properties index 1afdc730..2011e7f3 100644 --- a/sdc-workflow-designer-be/src/main/resources/application.properties +++ b/sdc-workflow-designer-be/src/main/resources/application.properties @@ -48,6 +48,7 @@ zusammen.cassandra.trustStorePassword=${CS_TRUST_STORE_PASSWORD:} #Actuators management.endpoint.health.show-details=always +management.endpoints.web.exposure.include=* spring.output.ansi.enabled=always diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java new file mode 100644 index 00000000..128df2b1 --- /dev/null +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.sdc.workflow; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.hamcrest.Matchers.containsString; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +@SpringBootTest +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +public class MetricsTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void prometheusEndpointShouldReturnMetrics() throws Exception { + mockMvc.perform(get("/actuator/prometheus")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("# HELP"))); + } +} -- 2.16.6