From 0960d01721345589c6d52254f3889f59313ff614 Mon Sep 17 00:00:00 2001 From: Dimple Soni Date: Thu, 12 Aug 2021 18:49:18 -0400 Subject: [AAI] Integrate Micrometer to identify slow APIs (Making aai_uri tag configurable) Issue-ID: AAI-3367 Signed-off-by: Dimple Soni " Change-Id: I7879c7e6a5ae9b3a3943f4accceede0c7ba2ade0 --- .../main/java/org/onap/aai/web/MicrometerConfiguration.java | 4 ++++ aai-resources/src/main/resources/application.properties | 10 +++++++--- .../src/test/java/org/onap/aai/rest/ConfigurationTest.java | 4 ++-- aai-resources/src/test/resources/application-test.properties | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/aai-resources/src/main/java/org/onap/aai/web/MicrometerConfiguration.java b/aai-resources/src/main/java/org/onap/aai/web/MicrometerConfiguration.java index 0be4e0b..bbe94fc 100644 --- a/aai-resources/src/main/java/org/onap/aai/web/MicrometerConfiguration.java +++ b/aai-resources/src/main/java/org/onap/aai/web/MicrometerConfiguration.java @@ -21,6 +21,7 @@ package org.onap.aai.web; import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tags; import io.micrometer.jersey2.server.JerseyTags; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import io.micrometer.jersey2.server.JerseyTagsProvider; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.monitoring.RequestEvent; @@ -31,6 +32,9 @@ import org.springframework.context.annotation.Configuration; * Configuration Class to add customized tags to http metrics scraped in /actuator/prometheus endpoint */ @Configuration +@ConditionalOnProperty( + value="scrape.uri.metrics", + havingValue = "true") public class MicrometerConfiguration { private static final String TAG_AAI_URI = "aai_uri"; private static final String NOT_AVAILABLE = "NOT AVAILABLE"; diff --git a/aai-resources/src/main/resources/application.properties b/aai-resources/src/main/resources/application.properties index cd19be9..d80079d 100644 --- a/aai-resources/src/main/resources/application.properties +++ b/aai-resources/src/main/resources/application.properties @@ -95,12 +95,16 @@ schema.service.versions.override=false #To Expose the Prometheus scraping endpoint management.server.port=8448 #To Enable Actuator Endpoint, you can override this to True in OOM charts -management.endpoints.enabled-by-default=false +management.endpoints.enabled-by-default=true #To Enable Actuator Endpoint, you can override this in OOM Charts -#management.endpoints.web.exposure.include=info, health, prometheus +management.endpoints.web.exposure.include=info, health, prometheus management.metrics.web.server.auto-time-requests=false management.metrics.tags.group_id=aai -management.metrics.tags.app_id=${info.build.artifact} +# management.metrics.tags.app_id=${info.build.artifact} +# management.metrics.tags.aai_uri=${schema.uri.base.path} +#It is not advisable to use labels to store dimensions with high cardinality. +#Enable this option only for debug purposes. For more information: https://github.com/micrometer-metrics/micrometer/issues/1584 +scrape.uri.metrics=false # Location of the cadi properties file should be specified here aaf.cadi.file=${server.local.startpath}/cadi.properties diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java index 39f71fd..caaf91a 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java @@ -176,9 +176,9 @@ public class ConfigurationTest extends AbstractSpringRestTest { responseEntity = restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntity, String.class); responseBody = (String) responseEntity.getBody(); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); - assertTrue(responseBody.contains("app_id")); assertTrue(responseBody.contains("group_id")); - + assertTrue(responseBody.contains("aai_uri")); + //Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint "/actuator/info" and "/actuator/health" headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); httpEntity = new HttpEntity(headers); diff --git a/aai-resources/src/test/resources/application-test.properties b/aai-resources/src/test/resources/application-test.properties index 8aee5e1..e228229 100644 --- a/aai-resources/src/test/resources/application-test.properties +++ b/aai-resources/src/test/resources/application-test.properties @@ -78,3 +78,4 @@ management.server.port=0 management.endpoints.enabled-by-default=true management.endpoints.web.exposure.include=info, health, prometheus management.metrics.web.server.auto-time-requests=false +scrape.uri.metrics=true -- cgit 1.2.3-korg