Chapter 2. Monitoring and managing Red Hat Fuse applications on Spring Boot standalone
2.1. About the Fuse Console
The Red Hat Fuse Console is a web console based on HawtIO open source software. For a list of supported browsers, go to Supported Configurations.
The Fuse Console provides a central interface to examine and manage the details of one or more deployed Fuse containers. You can also monitor Red Hat Fuse and system resources, perform updates, and start or stop services.
The Fuse Console is available when you install Red Hat Fuse standalone or use Fuse on OpenShift. The integrations that you can view and manage in the Fuse Console depend on the plugins that are running. Possible plugins include:
- Camel
- JMX
- OSGI
- Runtime
- Logs
2.2. Accessing the Fuse Console for Spring Boot 2.x
You can access the Fuse Console for a standalone Fuse Spring Boot 2.x distribution.
Procedure
Add the following dependency to your Fuse application’s
pom.xml
file:<dependency> <groupId>io.hawt</groupId> <artifactId>hawtio-springboot</artifactId> </dependency>
Note that you do not need to specify the exact version because it is provided by the Maven BOM.
Edit the
src/main/resources/application.properties
file:Set the following properties:
-
management.endpoints.web.exposure.include=hawtio,jolokia
-
hawtio.authenticationEnabled=false
-
management.endpoint.hawtio.enabled=true
-
management.endpoint.jolokia.enabled=true
-
Optionally, set the
management.endpoints.web.base-path
property.By default for Spring Boot 2.x, the Fuse Console’s URL includes the context path (
/actuator
) of the management endpoints. For example:http://localhost:10001/actuator/hawtio/index.html
To change this default URL, for example to specify
http://localhost:10001/hawtio
, set themanagement.endpoints.web.base-path
property as shown here:management.endpoints.web.base-path=/
Your
application.properties
settings should look similar to the following example:# ports server.port=8080 management.server.port=10001 # enable management endpoints for healthchecks and hawtio management.endpoints.enabled-by-default = false management.endpoint.hawtio.enabled = true management.endpoint.jolokia.enabled = true management.endpoints.health.enabled = true management.health.defaults.enabled=false camel.health.enabled=false camel.health.indicator.enabled=true management.endpoints.web.exposure.include=hawtio,jolokia hawtio.authenticationEnabled=false # change the URL so that it does not include the actuator folder management.endpoints.web.base-path=/
NoteBy default, authentication for the Fuse Console on Spring Boot is disabled. Optionally, you can enable authentication by writing code specific to your Fuse Console distribution. Here is an example that you can use for guidance:
https://github.com/hawtio/hawtio/tree/master/examples/springboot-authentication
Run the Fuse application:
mvn spring-boot:run
To determine the port number for the Fuse Console URL, obtain the management.server.port value by looking at the value set in the
src/main/resources/application.properties
file. For example:management.server.port = 10001
To open the Fuse Console in a browser, use the following URL syntax where nnnnn is the value of the management.server.port property:
http://localhost:nnnnn/actuator/hawtio
For example, if the management.server.port property value is
10001
and you have not set themanagement.endpoints.web.base-path
property then the URL is:
2.3. Customizing the Fuse Console branding
You can customize the Fuse Console branding information, such as title, logo, and login page information, by adding a hawtconfig.json
file into your Fuse on Spring Boot standalone application.
Procedure
-
Create a JSON file named
hawtconfig.json
in your local Fuse on Spring Boot standalone application’ssrc/main/webapp
directory. Open the
src/main/webapp/hawtconfig.json
in an editor of your choice, and then add the following content:{ "branding": { "appName": "Red Hat Fuse Console", "appLogoUrl": "img/Logo-Red_Hat-Fuse-A-Reverse-RGB.png", "companyLogoUrl": "img/Logo-RedHat-A-Reverse-RGB.png" }, "login": { "description": "", "links": [] }, "about": { "title": "Red Hat Fuse Console", "productInfo": [], "additionalInfo": "", "copyright": "", "imgSrc": "img/Logo-RedHat-A-Reverse-RGB.png" }, "disabledRoutes": [ "/camel/source", "/diagnostics", "/jvm/discover", "/jvm/local" ] }
- Change the values of the configuration properties listed in Table A.1, “Fuse Console Configuration Properties”.
- Save your changes.
Run Fuse on Spring Boot by using the following command:
mvn spring-boot:run
-
In a web browser, open the Fuse Console by using this URL:
http://localhost:10001/actuator/hawtio/index.html
If you have already run the Fuse Console in a web browser, the branding is stored in the browser’s local storage. To use new branding settings, you must clear the browser’s local storage.
2.4. Securing the Fuse Console
To secure the Fuse Console on Spring Boot:
Disable the Fuse Console’s proxy servlet when deploying to AWS
If you want to deploy a standalone Fuse application to Amazon Web Services (AWS), you should disable the Fuse Console’s proxy servlet by setting the
hawtio.disableProxy
system property totrue
.NoteWhen you disable the Fuse Console proxy servlet, the Fuse Console’s Connect tab is disabled and you cannot connect to other JVMs from the Fuse Console. If you want to deploy more than one Fuse application on AWS, you must deploy the Fuse Console for each application.
Set HTTPS as the required protocol
You can use the
hawtio.http.strictTransportSecurity
property to require web browsers to use the secure HTTPS protocol to access the Fuse Console. This property specifies that web browsers that try to use HTTP to access the Fuse Console must automatically convert the request to use HTTPS.Use public keys to secure responses
You can use the
hawtio.http.publicKeyPins
property to secure the HTTPS protocol by telling the web browser to associate a specific cryptographic public key with the Fuse Console to decrease the risk of “man-in-the-middle” attacks with forged certificates.
Procedure
Set the
hawtio.http.strictTransportSecurity
andhawtio.http.publicKeyPins
properties as shown in the following example:public static void main(String[] args) { System.setProperty("hawtio.http.strictTransportSecurity", "max-age=31536000; includeSubDomains; preload"); System.setProperty("hawtio.http.publicKeyPins", "pin-sha256=cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs"; max-age=5184000; includeSubDomains"); SpringApplication.run(YourSpringBootApplication.class, args); }
(For deploying on AWS only) To disable the Fuse Console’s proxy servlet, set the
hawtio.disableProxy
property as shown in the following example:public static void main(String[] args) { System.setProperty("hawtio.disableProxy", "true"); }
Additional resources
-
For a description of the
hawtio.http.strictTransportSecurity
property’s syntax, see the description page for the HTTP Strict Transport Security (HSTS) response header. -
For a description of the
hawtio.http.publicKeyPins
property’s syntax, including instructions on how to extract the Base64 encoded public key, see the description page for the HTTP Public Key Pinning response header.
2.5. Ensuring that data displays correctly in the Fuse Console
If the display of the queues and connections in the Fuse Console is missing queues, missing connections, or displaying inconsistent icons, adjust the Jolokia collection size parameter that specifies the maximum number of elements in an array that Jolokia marshals in a response.
Procedure
In the upper right corner of the Fuse Console, click the user icon and then click Preferences.
- Increase the value of the Maximum collection size option (the default is 50,000).
- Click Close.
2.6. Connecting to remote Fuse applications
The Fuse Console uses Jolokia, an agent-based approach to Java Management Extensions (JMX) that requires extra software (an agent) installed on the client. By default, Red Hat Fuse includes a jolokia agent.
With standalone Fuse Console distributions, you can connect to remote integrations that already have a jolokia agent (https://jolokia.org/) running inside them. If the process that you want to connect to does not have a jolokia agent inside, refer to the jolokia documentation (http://jolokia.org/agent.html).
Procedure
The Fuse Console’s proxy servlet uses whitelist host protection, with which by default the Fuse Console can only connect to localhost. If you want to connect the Fuse Console to other remote Fuse instances, you need to configure the hawtio.proxyWhitelist system property in the main()
method of your Spring Boot application:
System.setProperty("hawtio.proxyWhitelist", "localhost, 127.0.0.1, myhost1, myhost2, myhost3");
2.6.1. Connecting to a remote Jolokia agent
Before you begin, you need to know the connection details (host name, port, and path) of the remote Jolokia agent.
The default connection URLs for the Jolokia agent on Spring Boot is http://<host>:8080/jolokia
As a system administrator, you can change this default.
Typically, the URL to remotely connect to a Jolokia agent is the URL to open the Fuse Console plus /jolokia
. For example, if the URL to open the Fuse Console is http://<host>:1234/hawtio
, then the URL to remotely connect to it would probably be http://<host>:1234/hawtio/jolokia
.
To connect to a remote Jolokia instance so that you can examine its JVM:
- Click the Connect tab.
- Click the Remote tab, and then Add connection.
- Type the Name, Scheme (HTTP or HTTPS), and the hostname.
- Click Test Connection.
- Click Add.
The Fuse Console automatically probes the local network interfaces other than localhost and 127.0.0.1 and adds them to the whitelist. Hence, you do not need to manually register the local machine’s addresses to the whitelist.
2.6.2. Setting data moving preferences
You can change the following Jolokia preferences, for example, if you want to more frequently refresh data that displays in the Fuse Console. Note that increasing the frequency of data updates impacts networking traffic and increases the number of requests made to the server.
- Update rate - The period between polls to Jolokia to fetch JMX data (the default is 5 seconds).
- Maximum depth - The number of levels that Jolokia will marshal an object to JSON on the server side before returning (the default is 7).
- Maximum collection size - The maximum number of elements in an array that Jolokia marshals in a response (the default is 50,000).
To change the values of these settings:
In the upper right of the Fuse Console, click the user icon and then click Preferences.
- Edit the options and then click Close.
2.6.3. Viewing JVM runtime information
To view JVM runtime information, such as system properties, metrics, and threads, click the Runtime tab.
2.7. Viewing and managing Apache Camel applications
In the Fuse Console’s Camel tab, you view and manage Apache Camel contexts, routes, and dependencies.
You can view the following details:
- A list of all running Camel contexts
- Detailed information of each Camel context such as Camel version number and runtime statics
- Lists of all routes in each Camel application and their runtime statistics
- Graphical representation of the running routes along with real time metrics
You can also interact with a Camel application by:
- Starting and suspending contexts
- Managing the lifecycle of all Camel applications and their routes, so you can restart, stop, pause, resume, etc.
- Live tracing and debugging of running routes
- Browsing and sending messages to Camel endpoints
Prerequisite
The Camel tab is only available when you connect to a container that uses one or more Camel routes.
2.7.1. Starting, suspending, or deleting a context
- In the Camel tab’s tree view, click Camel Contexts.
- Check the box next to one or more contexts in the list.
- Click Start or Suspend.
To delete a context:
- Stop the context.
- Click the ellipse icon and then select Delete from the dropdown menu.
When you delete a context, you remove it from the deployed application.
2.7.2. Viewing Camel application details
- In the Camel tab’s tree view, click a Camel application.
- To view a list of application attributes and values, click Attributes.
- To view a graphical representation of the application attributes, click Chart and then click Edit to select the attributes that you want to see in the chart.
- To view inflight and blocked exchanges, click Exchanges.
- To view application endpoints, click Endpoints. You can filter the list by URL, Route ID, and direction.
- To view, enable, and disable statistics related to the Camel built-in type conversion mechanism that is used to convert message bodies and message headers to different types, click Type Converters.
- To view and execute JMX operations, such as adding or updating routes from XML or finding all Camel components available in the classpath, click Operations.
2.7.3. Viewing a list of the Camel routes and interacting with them
To view a list of routes:
- Click the Camel tab.
In the tree view, click the application’s routes folder:
To start, stop, or delete one or more routes:
- Check the box next to one or more routes in the list.
- Click Start or Stop.
To delete a route, you must first stop it. Then click the ellipse icon and select Delete from the dropdown menu.
Note- When you delete a route, you remove it from the deployed application.
- You can also select a specific route in the tree view and then click the upper-right menu to start, stop, or delete it.
- To view a graphical diagram of the routes, click Route Diagram.
- To view inflight and blocked exchanges, click Exchanges.
- To view endpoints, click Endpoints. You can filter the list by URL, Route ID, and direction.
- Click Type Converters to view, enable, and disable statistics related to the Camel built-in type conversion mechanism, which is used to convert message bodies and message headers to different types.
To interact with a specific route:
- In the Camel tab’s tree view, select a route.
- To view a list of route attributes and values, click Attributes.
- To view a graphical representation of the route attributes, click Chart. You can click Edit to select the attributes that you want to see in the chart.
- To view inflight and blocked exchanges, click Exchanges.
- Click Operations to view and execute JMX operations on the route, such as dumping the route as XML or getting the route’s Camel ID value.
To trace messages through a route:
- In the Camel tab’s tree view, select a route.
- Select Trace, and then click Start tracing.
To send messages to a route:
- In the Camel tab’s tree view, open the context’s endpoints folder and then select an endpoint.
- Click the Send subtab.
- Configure the message in JSON or XML format.
- Click Send.
- Return to the route’s Trace tab to view the flow of messages through the route.
2.7.4. Debugging a route
- In the Camel tab’s tree view, select a route.
- Select Debug, and then click Start debugging.
To add a breakpoint, select a node in the diagram and then click Add breakpoint. A red dot appears in the node:
The node is added to the list of breakpoints:
- Click the down arrow to step to the next node or the Play button to resume running the route.
- Click the Pause button to suspend all threads for the route.
- Click Stop debugging when you are done. All breakpoints are cleared.
2.8. Viewing and managing JMX domains and MBeans
Java Management Extensions (JMX) is a Java technology that allows you to manage resources (services, devices, and applications) dynamically at runtime. The resources are represented by objects called MBeans (for Managed Bean). You can manage and monitor resources as soon as they are created, implemented, or installed.
With the JMX plugin on the Fuse Console, you can view and manage JMX domains and MBeans. You can view MBean attributes, run commands, and create charts that show statistics for the MBeans.
The JMX tab provides a tree view of the active JMX domains and MBeans organized in folders. You can view details and execute commands on the MBeans.
Procedure
To view and edit MBean attributes:
- In the tree view, select an MBean.
- Click the Attributes tab.
- Click an attribute to see its details.
To perform operations:
- In the tree view, select an MBean.
- Click the Operations tab, expand one of the listed operations.
- Click Execute to run the operation.
To view charts:
- In the tree view, select an item.
- Click the Chart tab.
2.9. Viewing diagnostics
Use the Diagnostics tab to view diagnostic information about the JVM via the JVM DiagnosticCommand and HotspotDiangostic interfaces.
The functionality is similar to the Diagnostic Commands view in Java Mission Control (jmc) or the command line tool jcmd. The plugin will provide corresponding jcmd commands in some scenarios.
Procedure
- To retrieve the number of instances of loaded classes and the amount of bytes they take up, click Class Histogram. If the operation is repeated, the tab shows the difference since last run.
- To view the JVM diagnostic flag setting, click the JVM flags.
- For a running JVM, you can also modify the flag settings.
Additional resources
The supported JVM depends on the platform, for more information go to one of the following sources:
2.10. Viewing threads
You can view and monitor the state of threads.
Procedure
- Click the Runtime tab and then the Threads subtab. The Threads page lists active threads and stack trace details for each thread. By default, the thread list shows all threads in descending ID order.
- To sort the list by increasing ID, click the ID column label.
- Optionally, filter the list by thread state (for example, Blocked) or by thread name.
- To drill down to detailed information for a specific thread, such as the lock class name and full stack trace for that thread, in the Actions column, click More.