Spring micrometer actuator StatsD tags definition - spring

I'm trying to configure spring actuator metrics along with micrometer to be sent to Datadog stastd agent.
Still, I'd like to get them all sent with a tag, so that I can filter in my Datadog dashboard just my service metrics, and not considering other services metrics.
I've added:
management:
metrics:
tags:
application: my_app
to my service metrics configuration, but I can't see this tag value in Datadog dashboard. I'm not seeing anything weird in app logs nor actuator logfile neither.
I have nothing else regarding metrics in my service, as I don't want to implement custom metrics, just want to use the one provided by actuator.
This is how the whole metrics configuration looks like:
management:
metrics:
export:
statsd:
host: ${STATSD_AGENT_HOST}
port: ${STATSD_AGENT_HOST_PORT}
flavor: datadog
tags:
application: my_app
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
Versions:
micrometer version: 1.6.4
actuator version: 2.4.3
spring version: 2.3.8
Any clue about what I could be missing to get the tag reaching Datadog?
Thanks!

We figured this out in the comments, I'm posting an answer that summarizes it all up: it seems the root cause was using different versions of different spring-boot modules.
It is a good rule of thumb to not define the versions yourself but use BOMs and let them define the versions for you, e.g. see: spring-boot-dependencies. This way you will use the compatible (and tested) versions.
management.metrics.tags.your-tag is the way to add tags to all of your metrics. A good way to check this is looking at /actuator/metrics.

Related

How do I scrape Prometheus metrics from two endpoints for the same Kubernetes pods?

I want to scrape metrics from two endpoints for the same pods - /demo/v1.0/metrics and /actuator/prometheus. This is how my annotations in values.yaml looks like right now.
metadata:
annotations:
iam.amazonaws.com/role: xxxx
prometheus.io/app: DEMO_SERVICE
prometheus.io/env: PRODUCTION
prometheus.io/path: /demo/v1.0/metrics
prometheus.io/port: "8197"
prometheus.io/product: DEMO_SERVICE
prometheus.io/scrape: "true"
prometheus.io/service: DEMO_SERVICE
prometheus.io/team: PROCESSING
How do I add the actuator endpoint to it and is it even required? I have added the Micrometer Prometheus registry dependency to pom.xml and I'm able to see the actuator metrics locally. Thank you.

How can I debug a failing spring boot actuator health indicator while spring security is on the classpath?

I am trying to see which health indicators get auto configured in spring boot actuator. i'm using spring boot 2.2.6, when I run my application locally and I navigate to /actuator/health I see "Status":"up". when I deploy my application on a openshift cluster however the status always shows down so i'm guessing one of the auto configured health indicators are failing. I use a custom JWT security implementation and it would be impossible to configure the Openshift readiness and liveness probes to use my security implementation. I tried all suggestions I could find on Stackoverflow to set the actuator health endpoint to show all details including setting management.endpoint.show-details to always, management.endpoints.sensitive to "*" or false, management.security.enabled to false etc etc. Nothing seems to work and i'm running out of ideas... i'm thinking that I manually need to start disabling all health checks and then re-enable them one by one to debug this? Any help/suggestions would be much appreciated, my latest management section of my application config file is below...
my config:
management:
security:
enabled: false
#defaults:
#enabled: false
#consul:
#enabled: false
endpoint:
health:
show-details: always
show-components: always
solr:
enabled: false
endpoints:
health:
sensitive: "*"
web:
exposure:
include: "*"
set
endpoints.health.sensitive : false
NOT "management.endpoints.health.sensitive".
It should help you to debug. Also
management.endpoint.health.show-details: always
in your setup there is a security level between management and endpoint.

Specifying route URI in Spring Cloud Gateway Configuration

Here is the yml for spring cloud gateway. I want to write URI without load balancing. But as I'm using Eureka, I don't think hardcoding something like "localhost:6678" is a good idea. I would like to specify the service name, without the lb prefix. Any way to write it ?
spring:
cloud:
gateway:
routes:
- id: before_route
uri: lb://hello-service
I'm seeing this on the console when I run the gateway:
You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
What is the official alternative of Ribbon? How can I enable it in my project instead of Ribbon?
Edit: I'm trying to avoid load balancing for now because of poor performance. Without lb I'm getting my request served within 150ms whereas lb makes it 500ms+
Thanks in advance!

Why am I missing Spring Actuator 2 endpoints in CloudFoundry, while the the same setup works locally?

I'm deploying an application on SAP Cloud Foundry, with Spring Actuator 2.0 embedded but the endpoints are not showing up as expected. Only the default ones (health, info) are enabled.
The very same setup works locally and all desired endpoints are available. I'm even trying to explicitly enable them, even though documentation says they are already enabled by default.
There's no information on CF logs about any issues with the Actuator.
Here's my Actuator dependency on pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
And here's my application.yml containing the Actuator setup, including explicit enablement of the endpoints.
management:
endpoint:
beans:
enabled: true
caches:
enabled: true
env:
enabled: true
health:
enabled: true
info:
enabled: true
loggers:
enabled: true
metrics:
enabled: true
endpoints:
web:
exposure:
include: beans, caches, env, health, info, loggers, metrics
Am I missing something? Couldn't find any hard restrictions about this on SAP CF as well.
I decided to re-create the application and now it seems to work.
I'm really not sure why a simple redeployment was not working and there was nothing about it in the logs.
The endpoints are there now and for reference, I'm using the same configuration above (I might try removing all the "enable" flags, though).

Enable eureka.client.healthcheck

I'm following http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html to build distributed system with Spring Cloud.
All works as expected apart from Eureka Client Healthcheck.
I have
eureka:
client:
healthcheck:
enabled: true
And pointing my service to nonexisten config_server, this results in
http://myservice:8080/health
{
status: "DOWN"
}
But Eureka server still showing this instance as UP and keep sending traffic to it.
What am I missing?
spring-boot: 1.2.8.RELEASE
spring-cloud-netflix : 1.0.4.RELEASE
You have to explicitly set eureka.client.healthcheck.enabled=true to link the Spring Boot health indicator to the Eureka registration. Source code reference: here.
Ok, I think I found it.
According to https://jmnarloch.wordpress.com/2015/09/02/spring-cloud-fixing-eureka-application-status/ this feature will only be available on Spring Cloud 1.1.
To make it work with 1.0.4 I need to implement my own HealthCheckHandler.
Thanks #xtreme-biker for bringing up Spring Cloud version issue.

Resources