Azure ApplicationInsights using logback in Spring Boot - application name not propagated - spring-boot

Currently Im trying to integrate our Spring Boot Java services with Azure Application Insights.
First of all I shall write that below issue from 2018 seems to be still active/alive as I encountered this behavior when using 2.6.0 version.
https://github.com/Microsoft/ApplicationInsights-Java/issues/710
https://github.com/microsoft/ApplicationInsights-Java/issues/1014
It seems the application.yml (not properties in my case) are not used and I was able to get it working only with ApplicationInsgights.xml file.
Anyway there are some workarounds for setting the instrumentation key so OK.
However my question is following:
Why the Logback logs dont have application name in "traces" table/data set in Azure portal?
Under which column should the application name be populated? It was populated in column "cloud_RoleName", but now it is not populated despite no changes were made. Column "appId" is some UUID and column "appName" has name of the application insights resource, not the value from spring.application.name.
This doc does not seem up to date:
https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/traces
Also the app. Im connecting to AI is run outside Azure, which can possibly play some role.
Thanks.

Related

Open API (Swagger) non working in Spring Boot when adding context path

I have a Spring Boot application exposing REST services that are easily called on addresses like
http://localhost:8080/<controller_mapping>/<service_mapping>.
I've been asked to modify my settings in order to add a context path and have my services to respond on
http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.
Thus I edited my application.properties adding
server.servlet.context-path=/gesev-mensa
Everything works but I can't call Swagger on old address
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
I get the error Failed to load remote configuration
As suggested, I tried to add property
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
but problem persists.
I guess Swagger should be reachable at
http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
but that doesn't work.
Any hint?
Thanks for support.
Try removing
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
from your properties,
And your swagger will be available in
http://localhost:8080/gesev-mensa/swagger-ui/index.html
As per your current configuration with,
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
Swagger will be available in
http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html

Disable specific bean types from cloud foundry java-buildpack-auto-reconfiguration

I have the problem that im my company there is a workaround for using the db2 broker in cloud foundry. To get this work you have to disable the java-buildpack-auto-reconfiguration in your application with this property:
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'
Otherwise you get this error:
DB2 SQL Error: SQLCODE=-142, SQLSTATE=42612, SQLERRMC=null
In the git project (https://github.com/cloudfoundry/java-buildpack-auto-reconfiguration) I read that this property disables re-writes of bean definitions of various types (javax.sql.DataSource, org.springframework.data.mongodb.MongoDbFactory, org.springframework.amqp.rabbit.connection.ConnectionFactory, ...) to connect automatically with services bound to the application. In our application we use MongoDB as well as DB2. Therefore I am worried about that with this configuration I disable something that I do not want to disable for MongoDB.
I hope this will get fixed soon that I do not need this configuration. But for now is it possible to only disable the reconfiguration for specific bean types (in my case "javax.sql.DataSource")?

Unable to link Spring boot application with Azure Application insight using application.properties, when logback.xml is used

I have created a spring-boot starter project and linked Azure Application insight to it. The properties like instrumentation- key is defined in "application.properties". On launching the application it is correctly linked to App Insight as can be verified by Live Metrics Stream.
However same application fails to connect to Azure App Insight if logback.xml is included in project (in resources), in this case to connect to App insight I have to include ApplicationInsights.xml as well.
But I do not want to use "ApplicationInsights.xml" in my application for 2 reasons. 1. I do not want multiple configuration files. 2. I am not able to inject key , i.e. not able to externalize key which might come as vm arguments or environment variable.
Defining InstrumentationKey and other configuration in application.properties works only when logback.xml is not present.
sample project (asset-register.zip) can be found at https://github.com/Microsoft/ApplicationInsights-Java/issues/710

How to automatically create DynamoDB table on application startup using Spring Data DynamoDB?

I am using spring-data-dynamodb Spring Data extension to integrate AWS DynamDB with Spring Boot 2.0. I was able to make it work.
My question is, is there a way that the table is automatically created on application startup if it doesn't already exists, similar to what Hiberate offers via hibernate.hbm2ddl.auto ?. Right now, I have to create the table manually or in the application using the AWS DynamoDB sdk. Many Thanks.
Right now there is no such feature but there is an open feature request: https://github.com/derjust/spring-data-dynamodb/issues/17 (which I'm actually working on these days)
Note: I'm the maintainer of this GitHub project.

springboot admin: How to display custom metrics in springboot admin GUI ("Metrics" tab)

We are using serveral microservices with springboot (Vers. 1.4.3) and for monitoring them springboot-admin (Vers. 1.5.0).
Inside our microservices we generate several custom metrics (using the
'#com.codahale.metrics.annotation.Timed' annotation).
While all these custom metrics are displayed through the ordinary actuator-endpoint "/metrics" they are sorrowly not shown in the springboot admin GUI -"Metrics" tab.
Obviously only "counter." and "gauge." metrics are displayed in the latter.
Is there any possibility to configure / modify springboot admin, so that these custom metrics also are shown - either in the existing 'metrics' tab or in another new tab ?
Ok, meanwhile I found out, that the new springboot-admin version 1.5.2 will solve our problem:
As I could see at a project from a colleague, this springboot-admin version will display ALL metrics without any restrictions regarding the metrics-key.
[ At the moment we can't upgrade to this version since our springboot-version dependency prevents it but in the future we'll be able to do so.]
So the problem is more or less solved.

Resources