Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jolokia JVM only extension #6988

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ updates:
- dependency-name: "com.squareup.okhttp3:okhttp"
- dependency-name: "io.swagger.codegen.v3:swagger-codegen-generators"
- dependency-name: "org.amqphub.quarkus:quarkus-qpid-jms-bom"
- dependency-name: "org.jolokia:jolokia-agent-jvm"
# Test dependencies
- dependency-name: "org.wiremock:wiremock-standalone"
- dependency-name: "com.unboundid:unboundid-ldapsdk"
Expand Down
13 changes: 13 additions & 0 deletions catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jolokia</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jolt</artifactId>
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
*** xref:reference/extensions/javascript.adoc[JavaScript]
*** xref:reference/extensions/jfr.adoc[Jfr]
*** xref:reference/extensions/jira.adoc[Jira]
*** xref:reference/extensions/jolokia.adoc[Jolokia]
*** xref:reference/extensions/json-patch.adoc[JsonPatch]
*** xref:reference/extensions/kafka.adoc[Kafka]
*** xref:reference/extensions/kamelet.adoc[Kamelet]
Expand Down
266 changes: 266 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/jolokia.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-jolokia"]
= Jolokia
:linkattrs:
:cq-artifact-id: camel-quarkus-jolokia
:cq-native-supported: false
:cq-status: Preview
:cq-status-deprecation: Preview
:cq-description: Expose runtime metrics and management operations via JMX with Jolokia
:cq-deprecated: false
:cq-jvm-since: 3.19.0
:cq-native-since: n/a

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##3.19.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
endif::[]

Expose runtime metrics and management operations via JMX with Jolokia

[id="extensions-jolokia-maven-coordinates"]
== Maven coordinates

[source,xml]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jolokia</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-jolokia-usage"]
== Usage
This extension adds https://jolokia.org/[Jolokia] support to your application.

[id="extensions-jolokia-usage-jolokia-http-endpoints"]
=== Jolokia HTTP endpoints

In prod mode, Jolokia is accessible at the following URLs.

* http://0.0.0.0:8778/jolokia/
* http://0.0.0.0:8080/q/jolokia

In dev and test modes Jolokia is bound only to `localhost`.

To disable exposing Jolokia via the Quarkus management interface at `/q/jolokia`, add the following configuration to `application.properties`.

[source]
----
quarkus.camel.jolokia.register-management-endpoint=false
----

If you want to disable Jolokia entirely, then add the following configuration to `application.properties`.

[source]
----
quarkus.camel.jolokia.enabled=false
----

[id="extensions-jolokia-usage-jolokia-configuration"]
=== Jolokia configuration

Any of the https://jolokia.org/reference/html/manual/agents.html[Jolokia configuration options] can be configured via the `quarkus.camel.jolokia.additional-properties.<jolokia-property-name>` option.
Where `<jolokia-property-name>` is the name of the Jolokia configuration option you want to set.

For example, the following configuration added to `application.properties` enables Jolokia debugging and sets the max depth for traversing bean properties.

[source]
----
quarkus.camel.jolokia.additional-properties.debug=true
quarkus.camel.jolokia.additional-properties.maxDepth=10
----

[id="extensions-jolokia-usage-jolokia-restrictor"]
=== Jolokia restrictor

By default, a Jolokia restrictor is automatically registered that exposes access to only a specific set of MBean domains.

* `org.apache.camel`
* `java.lang`
* `java.nio`

If this is too restrictive, then you can either disable the default restrictor, or create your own custom restrictor.

[id="extensions-jolokia-usage-disable-the-default-restrictor"]
==== Disable the default restrictor

The following configuration added to `application.properties` disables the default restrictor.

[source]
----
quarkus.camel.jolokia.register-camel-restrictor=false
----

[id="extensions-jolokia-usage-create-a-custom-restrictor"]
==== Create a custom restrictor

You can create your own restrictor class and register it with Jolokia.

[source,java]
----
public class CustomRestrictor extends AllowAllRestrictor {
// Override methods to apply custom restrictions
}
----

Register the restrictor with Jolokia by adding the following configuration to `application.properties`.

[source]
----
quarkus.camel.jolokia.additional-properties.restrictorClass=org.acme.CustomRestrictor
----

[id="extensions-jolokia-usage-kubernetes-openshift-support"]
=== Kubernetes & OpenShift support

[id="extensions-jolokia-usage-generated-kubernetes-manifests"]
==== Generated Kubernetes manifests

If the `quarkus-kubernetes` or `quarkus-openshift` extensions are present, a container port named `jolokia` will be added automatically to the pod configuration within the generated Kubernetes manifest resources.

This can be disabled by adding the following configuration to `application.properties`.

[source]
----
quarkus.camel.jolokia.kubernetes.expose-container-port=false
----

[id="extensions-jolokia-usage-automatic-enablement-of-ssl-client-authentication"]
==== Automatic enablement of SSL client authentication

If the application detects that it is running on Kubernetes or OpenShift, then Jolokia is automatically configured for SSL client authentication.
This is useful if you use tools like https://hawt.io/[Hawtio] to discover and connect to your running application pod.

This functionality can be disabled by adding the following configuration to `application.properties`.

[source]
----
quarkus.camel.jolokia.kubernetes.client-authentication-enabled=false
----

Note that if you choose to use https://github.com/hawtio/hawtio-online[hawtio-online] to connect to your running application, then you must configure the Jolokia client principal.

[source]
----
quarkus.camel.jolokia.kubernetes.client-principal="cn=hawtio-online.hawtio.svc"
----


[id="extensions-jolokia-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[width="100%",cols="80,5,15",options="header"]
|===
| Configuration property | Type | Default


|icon:lock[title=Fixed at build time] [[quarkus.camel.jolokia.enabled]]`link:#quarkus.camel.jolokia.enabled[quarkus.camel.jolokia.enabled]`

Enables Jolokia support.
| `boolean`
| `true`

|icon:lock[title=Fixed at build time] [[quarkus.camel.jolokia.path]]`link:#quarkus.camel.jolokia.path[quarkus.camel.jolokia.path]`

The context path that the Jolokia agent is deployed under.
| `string`
| `jolokia`

|icon:lock[title=Fixed at build time] [[quarkus.camel.jolokia.register-management-endpoint]]`link:#quarkus.camel.jolokia.register-management-endpoint[quarkus.camel.jolokia.register-management-endpoint]`

Whether to register a Quarkus management endpoint for Jolokia (default /q/jolokia).
When enabled this activates a management endpoint which will be accessible on a path relative to
${quarkus.http.non-application-root-path}/${quarkus.camel.jolokia.server.path}.
If the management interface is enabled, the value will be resolved as a path relative to
${quarkus.management.root-path}/${quarkus.camel.jolokia.server.path}. Note that for this feature to work you must
have quarkus-vertx-http on the application classpath.
| `boolean`
| `true`

|icon:lock[title=Fixed at build time] [[quarkus.camel.jolokia.kubernetes.expose-container-port]]`link:#quarkus.camel.jolokia.kubernetes.expose-container-port[quarkus.camel.jolokia.kubernetes.expose-container-port]`

When {@code true} and the quarkus-kubernetes extension is present, a container port named jolokia will
be added to the generated Kubernetes manifests within the container spec ports definition.
| `boolean`
| `true`

| [[quarkus.camel.jolokia.server.auto-start]]`link:#quarkus.camel.jolokia.server.auto-start[quarkus.camel.jolokia.server.auto-start]`

Whether the Jolokia agent HTTP server should be started automatically.
When set to {@code false}, it is the user responsibility to start the server.
This can be done via {@code @Inject CamelQuarkusJolokiaServer} and then invoking the start() method.
| `boolean`
| `true`

| [[quarkus.camel.jolokia.server.host]]`link:#quarkus.camel.jolokia.server.host[quarkus.camel.jolokia.server.host]`

The host address to which the Jolokia agent HTTP server should bind to.
When unspecified, the default is localhost for dev and test mode.
In prod mode the default is to bind to all interfaces at 0.0.0.0.
| `string`
|

| [[quarkus.camel.jolokia.server.port]]`link:#quarkus.camel.jolokia.server.port[quarkus.camel.jolokia.server.port]`

The port on which the Jolokia agent HTTP server should listen on.
| `int`
| `8778`

| [[quarkus.camel.jolokia.server.discovery-enabled-mode]]`link:#quarkus.camel.jolokia.server.discovery-enabled-mode[quarkus.camel.jolokia.server.discovery-enabled-mode]`

The mode in which Jolokia agent discovery is enabled. The default {@code dev-test}, enables discovery only in dev and
test modes.
A value of {@code all} enables agent discovery in dev, test and prod modes. Setting the value to {@code none} will
disable agent discovery in all modes.
| `all`, `dev-test`, `none`
| `dev-test`

| [[quarkus.camel.jolokia.kubernetes.client-authentication-enabled]]`link:#quarkus.camel.jolokia.kubernetes.client-authentication-enabled[quarkus.camel.jolokia.kubernetes.client-authentication-enabled]`

Whether to enable Jolokia SSL client authentication in Kubernetes environments.
Useful for tools such as hawtio to be able to connect with your application.
| `boolean`
| `true`

| [[quarkus.camel.jolokia.kubernetes.service-ca-cert]]`link:#quarkus.camel.jolokia.kubernetes.service-ca-cert[quarkus.camel.jolokia.kubernetes.service-ca-cert]`

Absolute path of the CA certificate Jolokia should use for SSL client authentication.
| link:https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/File.html[`File`]
| `/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt`

| [[quarkus.camel.jolokia.kubernetes.client-principal]]`link:#quarkus.camel.jolokia.kubernetes.client-principal[quarkus.camel.jolokia.kubernetes.client-principal]`

The principal which must be given in a client certificate to allow access to Jolokia.
| `string`
|

| [[quarkus.camel.jolokia.additional-properties.-additional-properties]]`link:#quarkus.camel.jolokia.additional-properties.-additional-properties[quarkus.camel.jolokia.additional-properties."additional-properties"]`

Arbitrary Jolokia configuration options. These are described at the
<a href="https://jolokia.org/reference/html/manual/agents.html">Jolokia documentation</a>.
Options can be configured like {@code quarkus.camel.jolokia.additional-properties."debug"=true}.
| `Map<String,String>`
|

| [[quarkus.camel.jolokia.register-camel-restrictor]]`link:#quarkus.camel.jolokia.register-camel-restrictor[quarkus.camel.jolokia.register-camel-restrictor]`

When {@code true}, a Jolokia restrictor is registered that limits MBean read, write and operation execution to the
following MBean domains.
<ul>
<li>org.apache.camel</li>
<li>java.lang</li>
<li>java.nio</li>
</ul>
Note that this option has no effect if quarkus.camel.jolokia.additional-properties."restrictorClass" is set.
| `boolean`
| `true`
|===

[.configuration-legend]
{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.

90 changes: 90 additions & 0 deletions extensions-jvm/jolokia/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jolokia-parent</artifactId>
<version>3.19.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-jolokia-deployment</artifactId>
<name>Camel Quarkus :: Jolokia :: Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-spi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-management-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jolokia</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-direct</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-seda</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading