I am trying scdf and its monitoring with prometheus and grafana. I followed the documentation available and able to deploy the sample stream and able to see the metrics in the grafana.
I have created a stream with some custom stream app (other than the supplied rabbit mq starter apps).
Stream:
htt | participant | log
But am not able see the "participant" application metrics in gafana. But able to see the metrics of http and log apps.
Added below properties in application.properties.
management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
spring.cloud.streamapp.security.enabled=false
Added below dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--<!– https://mvnrepository.com/artifact/org.springframework.cloud.stream.app/app-starters-common –>-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud.stream.app</groupId>-->
<!--<artifactId>app-starters-common</artifactId>-->
<!--<version>2.1.1.RELEASE</version>-->
<!--<type>pom</type>-->
<!--</dependency>-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
After adding app-starters-common:org.springframework.cloud.stream.app dependency localhost:< port >/ opens a login page.
I think you need app-starters-micrometer-common dependency which adds some of the micrometer tags to your app. This dependency is intended to be used by the Spring cloud stream app starters and I believe you can use it in your custom application as well.
I came across this question while looking answers for the same.
Here is my working code snippet:-
Pom.xml
<dependency>
<groupId>org.springframework.cloud.stream.app</groupId>
<artifactId>app-starters-micrometer-common</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-jmx</artifactId>
</dependency>
application property change to enable prometheus and disable security(login page)
management.endpoints.web.exposure.include=*
management.metrics.export.prometheus.enabled=true
-- this one to remove security (login page), which was automatically added by app-starter-micrometre-common dependency.
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
or
exclude the dependency, I excluded config-client and few other since I don't need them in my application.
<dependency>
<groupId>org.springframework.cloud.stream.app</groupId>
<artifactId>app-starters-micrometer-common</artifactId>
<version>2.1.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-security-config</artifactId>
<groupId>org.springframework.security</groupId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-services-starter-config-client</artifactId>
<groupId>io.pivotal.spring.cloud</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
With later Data Flow 2.3.x, you need to add the following dependencies to your processor:
<dependency>
<groupId>org.springframework.cloud.stream.app</groupId>
<artifactId>app-starters-micrometer-common</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer.prometheus</groupId>
<artifactId>prometheus-rsocket-spring</artifactId>
<version>0.9.0</version>
</dependency>
The app-starters-micrometer-common injects DataFlow specific tags, such as stream.name, application.name, application.type all used by the dashboard to aggregate the required metrics.
In addition you can follow instructions in the sample projects, showing how to build custom Source, Processor and Sink apps with enabled prometheus monitoring:
https://github.com/spring-cloud/spring-cloud-dataflow-samples/tree/master/monitoring-samples/stream-apps
Related
Could someone point me to a possible solution? We're migrating a really old Struts2.3/Spring4/Hibernate4 application to Struts 2.5.30 / Hibernate 5.2.1 / Spring 5.2.21. Also, the legacy app had Tiles 2.2.2 which we haven't changed. We're keeping Tiles 2.2.2 as is.
<properties>
<log4j.version>2.17.2</log4j.version>
<java.version>11</java.version>
<finalName>oar</finalName>
<spring.version>5.2.21.RELEASE</spring.version>
<hibernate.version>5.2.1.Final</hibernate.version>
<struts.version>2.5.30</struts.version>
<tiles.version>2.2.2</tiles.version>
</properties>
With these Maven dependencies, when the app launches, I get the following error:
java.lang.AbstractMethodError: Receiver class org.apache.struts2.tiles.StrutsTilesInitializer
does not define or inherit an implementation of the resolved method 'abstract
org.apache.tiles.factory.AbstractTilesContainerFactory
createContainerFactory(org.apache.tiles.TilesApplicationContext)'
of abstract class org.apache.tiles.startup.AbstractTilesInitializer.
Full stack trace:
java.lang.AbstractMethodError: Receiver class org.apache.struts2.tiles.StrutsTilesInitializer does not define or inherit an implementation of the resolved method 'abstract org.apache.tiles.factory.AbstractTilesContainerFactory createContainerFactory(org.apache.tiles.TilesApplicationContext)' of abstract class org.apache.tiles.startup.AbstractTilesInitializer.
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:123)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4753)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5215)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
Per the Version Properties above, the relevant Struts & Tiles dependencies are below. Note that struts2-tiles-plugin is included, with the version as per the property, 2.5.30. (My understanding is that there's also a newer struts2-tiles3-plugin but I'm not using that, since our Tiles is kept at 2.2.2.) Could the problem actually be that we're keeping Tiles 2.2.2 which is incompatible with Struts 2.5.30? We don't want to switch to Tiles 3, because there are a lot of differences (e.g., useAttribute has changed).
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.bootstrap</groupId>
<artifactId>struts2-bootstrap-plugin</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-el</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-freemarker</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-ognl</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>${tiles.version}</version>
</dependency>
The Struts 2 framework used a plugin for integration with Tiles framework. The plugin for Tiles 2 is struts2-tiles-plugin and for Tiles 3 is struts2-tiles3-plugin. You should not define the version of Tiles in your pom.xml because it is incurred from the transitive dependencies for each plugin. Look at this answer which has links to examples with the Tiles integration. Note how the version is defined
<struts2.version>6.0.0-RC3</struts2.version>
and
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
If you specify Tiles version separately in your configuration, it can be incompatible with one from the plugin dependencies and you have probably exlude it to resolve the error.
I am using spring stomp websocket on a Java client using StandardWebSocketClient, much like this example:
https://www.baeldung.com/websockets-api-java-spring-client
Using spring-boot-starter-websocket maven dep adds too many deps that are not needed on the client, so I came up with:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>${tomcat.embed.websocket.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>tomcat-annotations-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
</exclusions>
</dependency>
The tomcat-embed-websocket is to provide a javax.websocket implementation. But it's quite big as it adds tomcat-embed-core.
I tried to use Tyrus but don't know which deps to add.
Would Tyrus be smaller? How to add only client deps?
Tyrus standalone client bundle might be the best thing to start with
https://repo1.maven.org/maven2/org/glassfish/tyrus/bundles/tyrus-standalone-client/2.0.1/
I'm not sure how big is the tomcat embed core, but this isn't a small lib, it has ~2.2 MB.
I'm trying to use an unmanaged extension which uses 2.1.2 neo4j.version
on a neo4j server (version CE 3.5.11 Cypher version: CYPHER 3.5).
The neo4j server starts properly but when I invoke the Rest Service provided by that unmanaged extension via Postman I get the following error
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/neo4j/cypher/javacompat/ExecutionEngine
the extension is installed via the following pom :
<properties>
<neo4j.version>2.1.2</neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<type>test-jar</type>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>server-api</artifactId>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${neo4j.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-shell</artifactId>
<version>${neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-shell</artifactId>
<version>${neo4j.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
locally the extension works well all unit tests succeed.
Thank you for your help.
You need to set <neo4j.version> to 3.5.11, to be compatible with the neo4j server version.
If necessary, you may also need to fix the extension so that it will build and work correctly, since version 2.1.2 is extremely old.
I'm trying to use Jira Rest Client with an existing Jersey project. But it is causing dependency conflicts.
pom.xml:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.24.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>2.0.0-m30</version>
</dependency>
The above dependencies result in the exception:
root cause: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
If I exclude com.sun.jersey:jersey-client the former error does go away.
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client</artifactId>
<version>1.2-m01</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
</exclusions>
</dependency>
But then it cause in another exception.
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/atlassian/fugue/Effect
Is there any workaround for me to get Jira client work along with Jersey 2?
There are two dependencies to exclude from atlassian jira rest client:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.2-2bd0a62e</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
</exclusion>
</exclusions>
</dependency>
The other issue you gotten can be solved by adding this dependency:
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.2</version>
<scope>provided</scope>
</dependency>
I am trying to add OpenID support to broadleaf commerce application.
I was able to work out a working standalone web application using Spring OpenID.
In my site/pom.xml of my broadleaf commerce app, I added this :-
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
Doing Maven build after this resulted in compilation error at 'produces' attribute of #RequestMapping wherever it is used in application.
"The attribute produces is undefined for the annotation type RequestMapping"
#RequestMapping(value = "/add", produces = "text/html")
public String add(HttpServletRequest request, HttpServletResponse response, Model model,
The build path of project does shows spring-web.3.0.7.RELEASE jar.
Project refresh/clean also didn't help.
I am using Broadleaf 2.0.
Thanks for you help.
I'll start off by identifying myself as an employee of Broadleaf Commerce.
I don't believe the "produces" attribute was introduced until Spring-Web 3.1. I reviewed the pom.xml for Broadleaf core for version 2.0 and we specify a dependency on spring-web and spring-webmvc 3.1.3.RELEASE. I also confirmed that during a default build of the Broadleaf DemoSite for 2.0 that the 3.1.3.RELEASE versions are produced in WEB-INF/lib (and no other versions). This makes me think that one or more additional libraries you have declared a dependency on in your own project have a transitive dependency on an earlier version of spring-web. You may need to include an "exclusions" element in your dependency declaration to remove the offending dependency.
Simple adding exclusions didn't helped as it removed all the exluded dependencies irrespective of their version. (The exclusion tag does not allow you to specify version to be excluded.
I had to add the exluded dependencies with correct version as follow:-
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
<version>3.1.4.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>