Spring Boot Actuator Micrometer New Relic Integration - spring-boot

I want to use New Relic, using the micrometer support of the spring boot actuator.
I am not using agents.
I have a configuration as below.
I can see data in data explorer (event or metric etc.) However, I can't see anything in the APM section of the explorer page.
Is there a root cause of this due to the configuration, maybe something I missed?
I think I don't have to use agents because I use Micrometer, am I right?
Is it really a problem that I can't see anything in the APM section of the explorer page, would it come up automatically in a proper integration?
Thanks.
application.yaml
management:
metrics:
export:
newrelic:
api-key: ${MY_API_KEY}
account-id: ${MY_ACCOUNT_ID}
step: 3s
uri: ${URI}
meter-name-event-type-enabled: true
enabled: true
logging:
level:
io:
micrometer:
newrelic: TRACE
console
i.m.n.NewRelicInsightsApiClientProvider : successfully sent 75 metrics to New Relic
dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-new-relic</artifactId>
<scope>runtime</scope>
</dependency>
References:
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.metrics.export.newrelic
https://micrometer.io/docs/registry/new-relic

New Relic uses a Synthesis engine to create "Entities"; and in the opensource entityDefinition repository it looks like you need to make sure you have an attribute/tag value specified for service.name.

Related

Setting up Flapdoodle so that it stores documents on the disk (+ caching)

I have a Spring Boot project for which I use Flapdoodle. Flapdoodle is used normally for testing, but I use it for development as it starts with the application itself and is comfortable to use. I just added it as dependency but without scope "test".
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>3.4.11</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
I've also set the spring.mongodb.embedded = 4.4.2 as the application doesn't start if this isn't set apperently.
Everything works fine. I can create collections and read and write documents using MongoTemplate.
However I'd be interested to know how I can switch the storaging behavior of the database: not in-memory anymore but on the disk ( + caching the most recent documents if possible). In this way the data isn't lost between restarts.
How can I set up the YAML configuration to enable this behavior?

Problem with Google cloud SQL and Google pubsub together :Error A database name must be provided

I have a rest application which which talks to google cloud sql and based on some data and I will sent data to pubsub topic. I have developing this two phase. Phase 1 getting data from cloudsql. I have successfully completed this and unit & integration test cases are working fine.
In second step i have included google pubsub dependency.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
</dependency>
when added this I am getting following error
Caused by: java.lang.IllegalArgumentException: A database name must be provided.
As i understand after debugging once include the above dependency the code / testing code doesnt refer application.yml file
Note: In application YML file i use spring datasource uRL to connect to Cloud SQL database (which has db name, cloud sql socket factory, cloud instance and username / password) I dont use GCP specific properties for database. For refering google project id use google:cloud:gcp: project-id:
I have solved the problem by removing spring-cloud-gcp-starter-pubsub dependency and added the google pubsub dependency.
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
</dependency>
However still could not find out the root cause of error

spring boot 2: actuator/health endpoint is taking more time

In one of my service /actuator/health endpoint is taking more time (approximately 9 seconds). I am using following dependencies, how to debug this?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Spring boot version used: 2.0.3.RELEASE
Thanks,
Hari
Basically health endpoint is implemented in a way that it contains a list of all Spring beans that implement the interface HealthIndicator.
Each health indicator is responsible for supplying a health information about one subsystem (examples of such subsystem are:disk, postgres, mongo, etc.), spring boot comes with some predefined HealthIndicators.
So that when the health endpoint is invoked, it iterates through this list and gets the information about each subsystem and then constructs the answer.
Hence you can place a break point in relevant health indicators (assuming you know which subsystems are checked) and see what happens.
If you're looking for the HTTP entry point - the code that gets called when you call http://<host-port>/health (can vary depending on your settings but you get the idea)`, it can be found here
Yet another approach that comes to mind is disabling "suspicious" health check and finding the slow one by elimination.
For example, if you have an elastricsearch and would like to disable it, use in the application.properties:
management.health.elasticsearch.enabled = false
On top of Mark's answer, setting this property in your application.properties / application.yml
management.endpoint.health.show-details=always
Will help in identifying which components comprise the health check,
as the GET /actuator/health will yield more details
On top of Mark's great answer:
As an alternative to synchronously running all your health checks when the /health endpoint is called (which can only lead to longer and longer execution time as you add more health checks), you can make your HealthIndicators run asynchronously using the library spring-boot-async-health-indicator (for Spring Boot >= 2.2) by annotating them with #AsyncHealth.
On top of making the /health endpoint return immediately (as returning healths calculated on separate threads), it also includes the execution time of each asynchronous health() method execution as an additional detail which dramatically helps in figuring out which underlying service responds slowly on production systems.
disclaimer: I wrote this library to help solve multiple limitations of the existing HealthIndicator system, including this one

Quarkus GraphQL: How to change the default endpoint?

I am using the dependency as shown below in a Quarkus application. Default the endpoint is /graphql. But since I am running this application in a k8s environment behind a ingress, this is not ideal. Anyone has an idea how to change this default endpoint to something like: /<service-name>/graphql?
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-servlet</artifactId>
<version>1.0.1</version>
</dependency>
If you're using the SmallRye GraphQL extension, you can control the endpoint path using application.properties:
quarkus.smallrye-graphql.root-path=/my-path-to-graphql
You can also use variables (with ${variableName} syntax) in the value, so you can inject your service name there.
But to be using that extension you need to adjust the dependency to
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-graphql</artifactId>
</dependency>
Note that it's only available since Quarkus 1.5.0.

How to supress windowed aggregation result in Spring Cloud Kafka Streams?

I am using Kafka-streams-binder in my Spring Cloud project. The Kafka stream application uses sliding window of 6 minutes to aggregate the results and analyze patter. But the problem is that the aggregation operation is generating duplicate results.
I want to suppress the intermediate results and publish only after the window ends in the application. This can be achieved by Kafka .supress() operation in Kafka 2.1.1. But the Spring Cloud version does not have the latest kafka to use the capability.
Dependencies used by Project
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
Any alternatives for suppressing the intermediate results would be helpful.
Any alternatives for suppressing the intermediate results would be helpful.
There is no equivalent functionality available in prior versions of Kafka Streams that give you the same behavior as the recently introduced Suppress feature.
The closest you can get is to configure your Kafka Streams application's record caches (settings like cache.max.bytes.buffering) and the commit.interval.ms to reduce the number of "intermediate" updates you will be seeing. But this will not fully remove any such updates unlike the new Suppress feature.
You can override the kafka-clients and kafka-streams versions, as described in the appendix to the Spring for Apache Kafka reference manual.
If you are not using the embedded kafka broker in tests, you just need to override the kafka clients and streams.
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>2.1.1</version>
</dependency>

Resources