I have a prometheus metrics registry and captor beans registered as seen below:
"prometheusMeterRegistry": {
"aliases": [],
"scope": "singleton",
"type": "io.micrometer.prometheus.PrometheusMeterRegistry",
"resource": "class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]",
"dependencies": [
"prometheusConfig",
"collectorRegistry",
"micrometerClock"
]
},
"integrationMicrometerMetricsCaptor": {
"aliases": [],
"scope": "singleton",
"type": "org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor",
"resource": null,
"dependencies": []
},
However, when I check the actuator/prometheus endpoint, I don't see any metrics for MessageHandler, MessageChannel and MessageSource which are mentioned here. The only spring-integeration metrics available are:
spring_integration_sources 1.0
spring_integration_handlers 17.0
spring_integration_channels 15.0
I also ran data through my flows, still can't see the metrics. What am I missing?
Thank you for such a great sample!
So, your problem is here:
<!-- Enable Spring Integration Metrics -->
<int:management/>
First of all you must not do this since Spring Boot auto-configures this for us. (We probably need to improve Spring Boot docs to mention that feature).
Secondly you still can do this but you need to use this option:
<xsd:attribute name="default-counts-enabled" use="optional">
<xsd:annotation>
<xsd:documentation>
The default value for components that don't match 'counts-enabled-patterns'.
Defaults to false, or true when an Integration MBean Exporter is provided.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
and set it to true.
In the current Spring Integration 5.4 version it is deprecated already. We definitely are going to remove it altogether in the next 6.0.
Related
I am trying to run ChaosMonkey for my resilience tests. I'm using Spring Boot and the WebTestClient Class to make api requests in cucumber functional resilience tests. The responses show that Chaos Monkey latency is configured correctly, but I don't see any latency. Does anyone know why it's not working for my tests?
My watcher configuration (request from within the test):
{
"controller": false,
"restController": false,
"service": false,
"repository": false,
"component": false,
"restTemplate": false,
"webClient": false,
"actuatorHealth": false,
"beans": []
}
My assault configuration (request from within the test):
{
"level":1,
"latencyRangeStart":5000,
"latencyRangeEnd":5000,
"latencyActive":true,
"watchedCustomServices":["com.my.correct.repository.ClassName"]
}
My application-test.properties file matches my application-dev.properties file, which DOES WORK.
spring.profiles.include=resilience4J-test,chaos-monkey
server.error.include-message=always
chaos.monkey.enabled=true
management.endpoint.chaosmonkey.enabled=true
management.endpoint.chaosmonkeyjmx.enabled=true
management.endpoints.web.exposure.include=health,info,chaosmonkey
management.endpoint.health.show-details=always
management.health.circuitbreakers.enabled=true
management.endpoint.circuitbreakers.enabled=true
I'm using Chaos Monkey 2.5.4 and Spring Boot 2.3.12
I actually just figured out that you need to add #ComponentScan to the test app so that Chaos monkey can discover the components and annotations. It works fine for me now.
I am trying to override RedisCustomConversions [initial post] (RedisCustomConversions using Redis Repository noticed some inconsistent behaviour.
When I run the spring boot app from IDE I get the error mentioned in the above post, but it works fine if the app is executed using java -jar myapp.jar. Which sounds okay but that makes me question if this behaviour is consistent? i.e will my overloaded bean will always be wired? or is it random?
I also noticed from /actuator/beans endpoint that when executed in IDE I get this
redisCustomConversions: {
aliases: [ ],
scope: "singleton",
type: "org.springframework.data.redis.core.convert.RedisCustomConversions",
dependencies: []
But running from the command line I see this.
redisCustomConversions: {
aliases: [ ],
scope: "singleton",
type: "org.springframework.data.redis.core.convert.RedisCustomConversions",
resource: "class path resource [com/my/project/cache/config/RedisConfig.class]",
dependencies: [
"MyWriterConverter",
"MyReaderConverter"
]
So the question is, can we rely on this behaviour? or it's random and for some deployments, the default RedisCustomConversions will be loaded and for other my custom RedisCustomConversions will be loaded (this will crash the application as data format in REDIS will be different)?
I was having the same issue as you and after banging my head against wall for longer than I wish to admit I asked in the spring-data gitter. They responded as so:
When using Spring Boot, you need to declare #EnableRedisRepositories and the #Bean definition for RedisCustomConversions on the same configuration class. That's currently a limitation of how #EnableRedisRepositories is built.
I am in new to spring boot. I have created a web app using spring boot. My application require some properties file to do the processing. In eclipse What I do i set the path on Run configuration like bellow.
Now When I run the application I gets the require file on path and run smoothly.
Now I want to deploy the war file on some server. How do i provide this path to my application.
Bellow is the project structure of my project. and files are here
highlighted
How do I set this file path using application.properties or any other way so that, I don't have to provide the path from run configuration, and the .war can be deploy on any server.
Update 1 : This what I tried.
Created a customStart.bat
content of the file is
set CATALINA_OPTS="-engine.home="/src/main/resources/" -Dlog4j.configuration=config/log4j.xml -Dlog4j.debug=true"
call startup.bat %CATALINA_OPTS%
But still that argument is not set. How do I do that?
As an option you can add your properties to %tomcat_home%\conf\catalina.properties
Just put them at the end of the file as follows:
log4j.configuration=config/log4j.xml
.....
From spring boot official documentation (This is a highlight of the concept of creating custom spring boot variable) bellow you'll find a link to a Q/A that describes the solution.
Spring Boot jars are shipped with meta-data files that provide details
of all supported configuration properties. The files are designed to
allow IDE developers to offer contextual help and “code completion” as
users are working with application.properties or application.yml
files.
The majority of the meta-data file is generated automatically at
compile time by processing all items annotated with
#ConfigurationProperties. However, it is possible to write part of the
meta-data manually for corner cases or more advanced use cases.
Configuration meta-data files are located inside jars under
META-INF/spring-configuration-metadata.json They use a simple JSON
format with items categorized under either “groups” or “properties”
and additional values hint categorized under "hints":
Here is an example of a meta data config file :
{"groups": [
{
"name": "server",
"type": "org.springframework.boot.autoconfigure.web.ServerProperties",
"sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
},
{
"name": "spring.jpa.hibernate",
"type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate",
"sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties",
"sourceMethod": "getHibernate()"
}
...
],"properties": [
{
"name": "server.port",
"type": "java.lang.Integer",
"sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
},
{
"name": "spring.jpa.hibernate.ddl-auto",
"type": "java.lang.String",
"description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.",
"sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate"
}
...
],"hints": [
{
"name": "spring.jpa.hibernate.ddl-auto",
"values": [
{
"value": "none",
"description": "Disable DDL handling."
},
{
"value": "validate",
"description": "Validate the schema, make no changes to the database."
},
{
"value": "update",
"description": "Update the schema if necessary."
},
{
"value": "create",
"description": "Create the schema and destroy previous data."
},
{
"value": "create-drop",
"description": "Create and then destroy the schema at the end of the session."
}
]
}
]}
Each “property” is a configuration item that the user specifies with a
given value. For example server.port and server.servlet-path might be
specified in application.properties as follows:
server.port=9090 server.servlet-path=/home The “groups” are higher
level items that don’t themselves specify a value, but instead provide
a contextual grouping for properties. For example the server.port and
server.servlet-path properties are part of the server group.
Notes:
The groups section is note required
“hints” are additional information used to assist the user in configuring a given property. When configuring the spring.jpa.hibernate.ddl-auto property, a tool can use it to offer some auto-completion help for the none, validate, update, create and create-drop values.
You can easily generate your own configuration meta-data file from
items annotated with #ConfigurationProperties by using the
spring-boot-configuration-processor jar
You can check this Q/A
** for more details check the spring boot apendix section **
I have two Spring Boot application. I've added Spring Boot Actuator both of them. When I run one of them I can see diskSpace:
{
"status": "UP",
"diskSpace": {
"status": "UP",
"total": 399055067136,
"free": 346446485504,
"threshold": 10485760
}
}
However at other service I can only see:
{
"status": "UP"
}
Even I add that property to second service:
management:
health:
diskspace:
enabled: true
I still cannot see diskSpace information. When I debug the system I see that such properties are collected but not returned to UI. What can be the problem?
Because only ADMINs are authorized to see any more info than this
{
"status": "UP"
}
To see all the metrics, authenticate with any user who has a spring security role ADMIN.
Or
(less preferable option)
Disable security for actuator endpoint like this
in application properties yaml file
management:
security:
enabled: false
In case if you are using spring security which is by default ON for actuator endpoints, you can disable it in your yml file -
management:
security:
enabled: false
management.security.enabled is deprecated now.
You can get full health details by adding a line in application.properties:
management.endpoint.health.show-details=always
Just add a line in application.properties:
management.endpoint.health.show-details = always
this made health show details to all users other than authorized people.
Spring boot actuator's HealthIndicator checks available disk space and reports a status of Status#DOWN when it drops below a configurable threshold.
so in your case for the second application the free space available is more than the threshold hence hou don't see any thing being reported.
you probably can debug and see in your code the values free disk space and the threshold.
let me know if this make sense...
In my configurations, service definitions are kept in /etc/consul.d/server.
Consul is started with following command:
consul agent -config-dir /etc/consul.d/server
When consul is started, none of the service is registered. However, same services can be registered using web API with same definition files.
What is the issue with multiple service definitions as they are not getting registered?
Do you have multiple files? If so -> make sure they all end in .json.
Also When loading configuration, Consul loads the configuration from files and directories in lexical order. For example, configuration file basic_config.json will be processed before extra_config.json. Configuration specified later will be merged into configuration specified earlier. In most cases, "merge" means that the later version will override the earlier. In some cases, such as event handlers, merging appends the handlers to the existing configuration. The exact merging behavior is specified for each option in the docs.
https://www.consul.io/docs/agent/options.html
Otherwise try to put all your service definitions into one json file.
using the services key in your configuration file. (not the plural S)
{
"services": [
{
"id": "red0",
"name": "redis",
"address": "127.0.0.1",
"port": 6000,
},
{
"id": "red1",
"name": "redis",
"address": "127.0.0.1",
"port": 7000,
},
]
}