diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index f6646a7751..a2b565eef7 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -5482,12 +5482,14 @@ by using the `integration` container name.
The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a `PodMonitor` resource,
so that the endpoint can be scraped automatically, when using the Prometheus operator.
-The metrics are exposed using MicroProfile Metrics.
+The metrics are exposed using Micrometer Metrics.
WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]
custom resource definition to be installed.
You can set `pod-monitor` to `false` for the Prometheus trait to work without the Prometheus Operator.
+WARNING: By default the metrics API is not available in JSON
+
The Prometheus trait is disabled by default.
diff --git a/docs/modules/traits/pages/prometheus.adoc b/docs/modules/traits/pages/prometheus.adoc
index b372e18fbb..a786aa6ce9 100755
--- a/docs/modules/traits/pages/prometheus.adoc
+++ b/docs/modules/traits/pages/prometheus.adoc
@@ -4,12 +4,14 @@
The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a `PodMonitor` resource,
so that the endpoint can be scraped automatically, when using the Prometheus operator.
-The metrics are exposed using MicroProfile Metrics.
+The metrics are exposed using Micrometer Metrics.
WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]
custom resource definition to be installed.
You can set `pod-monitor` to `false` for the Prometheus trait to work without the Prometheus Operator.
+WARNING: By default the metrics API is not available in JSON
+
The Prometheus trait is disabled by default.
@@ -45,3 +47,19 @@ The following configuration options are available:
|===
// End of autogenerated code - DO NOT EDIT! (configuration)
+== Examples
+
+* To activate the metrics and default scrapping through a new PodMonitor:
++
+[source,console]
+$ kamel run -t prometheus.enable=true ...
+
+* To activate the metrics when the Prometheus Operator is not available:
++
+[source,console]
+$ kamel run -t prometheus.enable=true -t pod-monitor=false ...
+
+* To activate the metrics with JSON format available :
++
+[source,console]
+$ kamel run -t prometheus.enable=true -t builder.properties="quarkus.micrometer.export.json.enabled=true"...
diff --git a/e2e/common/traits/prometheus_test.go b/e2e/common/traits/prometheus_test.go
index 26a80ba86a..d01e616297 100644
--- a/e2e/common/traits/prometheus_test.go
+++ b/e2e/common/traits/prometheus_test.go
@@ -62,7 +62,7 @@ func TestPrometheusTrait(t *testing.T) {
if err != nil {
assert.Fail(t, err.Error())
}
- assert.Contains(t, string(response), "camel.route.exchanges.total")
+ assert.Contains(t, string(response), "CamelExchangesTotal_total")
})
if ocp && createPodMonitor {
diff --git a/e2e/yaks/openshift/monitoring/Metrics.java b/e2e/yaks/openshift/monitoring/Metrics.java
index 38c423f526..ccd608730b 100644
--- a/e2e/yaks/openshift/monitoring/Metrics.java
+++ b/e2e/yaks/openshift/monitoring/Metrics.java
@@ -20,7 +20,7 @@
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.microprofile.metrics.MicroProfileMetricsConstants;
+import org.apache.camel.component.micrometer.MicrometerConstants;
import javax.enterprise.context.ApplicationScoped;
@@ -51,27 +51,27 @@ public void configure() {
.logStackTrace(false)
.logExhausted(false)
.log(LoggingLevel.ERROR, "Failed processing ${body}")
- .to("microprofile-metrics:meter:camel-k-example-metrics-redelivery?mark=2")
+ .to("micrometer:counter:camel-k-example-metrics-redelivery?increment=2")
// The 'error' meter
- .to("microprofile-metrics:meter:camel-k-example-metrics-error");
+ .to("micrometer:counter:camel-k-example-metrics-error");
from("timer:stream?period=1000")
.routeId("unreliable-service")
.setBody(header(Exchange.TIMER_COUNTER).prepend("event #"))
.log("Processing ${body}...")
// The 'generated' meter
- .to("microprofile-metrics:meter:camel-k-example-metrics-generated")
+ .to("micrometer:counter:camel-k-example-metrics-generated")
// TODO: replace with lookup by type as soon as CAMEL-15217 gets fixed
- // The 'attempt' meter via @Metered interceptor
+ // The 'attempt' meter via @Counted interceptor
.bean("service")
.filter(header(Exchange.REDELIVERED))
.log(LoggingLevel.WARN, "Processed ${body} after ${header.CamelRedeliveryCounter} retries")
- .setHeader(MicroProfileMetricsConstants.HEADER_METER_MARK, header(Exchange.REDELIVERY_COUNTER))
+ .setHeader(MicrometerConstants.HEADER_COUNTER_INCREMENT, header(Exchange.REDELIVERY_COUNTER))
// The 'redelivery' meter
- .to("microprofile-metrics:meter:camel-k-example-metrics-redelivery")
+ .to("micrometer:counter:camel-k-example-metrics-redelivery")
.end()
.log("Successfully processed ${body}")
// The 'success' meter
- .to("microprofile-metrics:meter:camel-k-example-metrics-success");
+ .to("micrometer:counter:camel-k-example-metrics-success");
}
}
diff --git a/e2e/yaks/openshift/monitoring/app/pom.xml b/e2e/yaks/openshift/monitoring/app/pom.xml
index c515105e2e..030c4d70fb 100644
--- a/e2e/yaks/openshift/monitoring/app/pom.xml
+++ b/e2e/yaks/openshift/monitoring/app/pom.xml
@@ -31,9 +31,13 @@
org.apache.camel.quarkus
- camel-quarkus-microprofile-metrics
+ camel-quarkus-micrometer
${version.camel.quarkus}
+
+ io.micrometer
+ micrometer-registry-prometheus
+
diff --git a/e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java b/e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
index ce7f798db8..655b2f7e1c 100644
--- a/e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
+++ b/e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
@@ -19,15 +19,11 @@
import java.util.Random;
+import io.micrometer.core.annotation.Counted;
+
import org.apache.camel.Exchange;
import org.apache.camel.RuntimeExchangeException;
-import org.eclipse.microprofile.metrics.Gauge;
-import org.eclipse.microprofile.metrics.Meter;
-
-import org.eclipse.microprofile.metrics.annotation.Metered;
-import org.eclipse.microprofile.metrics.annotation.Metric;
-
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
@@ -39,7 +35,7 @@
@io.quarkus.arc.Unremovable
public class Service {
- @Metered(name = "camel-k-example-metrics-attempt", absolute = true)
+ @Counted(value = "camel-k-example-metrics-attempt")
public void attempt(Exchange exchange) {
Random rand = new Random();
if (rand.nextDouble() < 0.5) {
diff --git a/pkg/apis/camel/v1/trait/prometheus.go b/pkg/apis/camel/v1/trait/prometheus.go
index 416cfa7f97..552375c4a6 100644
--- a/pkg/apis/camel/v1/trait/prometheus.go
+++ b/pkg/apis/camel/v1/trait/prometheus.go
@@ -20,12 +20,14 @@ package trait
// The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a `PodMonitor` resource,
// so that the endpoint can be scraped automatically, when using the Prometheus operator.
//
-// The metrics are exposed using MicroProfile Metrics.
+// The metrics are exposed using Micrometer Metrics.
//
// WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]
// custom resource definition to be installed.
// You can set `pod-monitor` to `false` for the Prometheus trait to work without the Prometheus Operator.
//
+// WARNING: By default the metrics API is not available in JSON
+//
// The Prometheus trait is disabled by default.
//
// +camel-k:trait=prometheus.
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 8694cb447e..70a0dba442 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -55,8 +55,9 @@ func (t *prometheusTrait) Configure(e *Environment) (bool, error) {
func (t *prometheusTrait) Apply(e *Environment) error {
if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
- // Add the Camel Quarkus MP Metrics extension
- util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-microprofile-metrics")
+ // Add the Camel Quarkus Micrometer extension and micrometer registry for prometheus
+ util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus:camel-quarkus-micrometer")
+ util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:io.micrometer:micrometer-registry-prometheus")
return nil
}
diff --git a/resources/traits.yaml b/resources/traits.yaml
index 77bac23afc..1f8c03900c 100755
--- a/resources/traits.yaml
+++ b/resources/traits.yaml
@@ -1179,11 +1179,12 @@ traits:
- OpenShift
description: 'The Prometheus trait configures a Prometheus-compatible endpoint.
It also creates a `PodMonitor` resource, so that the endpoint can be scraped automatically,
- when using the Prometheus operator. The metrics are exposed using MicroProfile
- Metrics. WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus
+ when using the Prometheus operator. The metrics are exposed using Micrometer Metrics.
+ WARNING: The creation of the `PodMonitor` resource requires the https://github.com/coreos/prometheus-operator[Prometheus
Operator] custom resource definition to be installed. You can set `pod-monitor`
- to `false` for the Prometheus trait to work without the Prometheus Operator. The
- Prometheus trait is disabled by default.'
+ to `false` for the Prometheus trait to work without the Prometheus Operator. WARNING:
+ By default the metrics API is not available in JSON The Prometheus trait is disabled
+ by default.'
properties:
- name: enabled
type: bool