This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 7ffcc24  Add prometheus example
7ffcc24 is described below

commit 7ffcc244dd59f86a62c787a9cab5e42c7afd5a3e
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 17 09:49:38 2023 +0100

    Add prometheus example
---
 jbang/prometheus/README.adoc            | 99 +++++++++++++++++++++++++++++++++
 jbang/prometheus/application.properties | 42 ++++++++++++++
 jbang/prometheus/demo.camel.yaml        | 40 +++++++++++++
 3 files changed, 181 insertions(+)

diff --git a/jbang/prometheus/README.adoc b/jbang/prometheus/README.adoc
new file mode 100644
index 0000000..f823b04
--- /dev/null
+++ b/jbang/prometheus/README.adoc
@@ -0,0 +1,99 @@
+== Micrometer Prometheus
+
+This example shows using Micrometer metrics with Camel JBang 
+and with HTTP endpoint for exposing statistics for scraping by Prometheus.
+
+The application is configured in the `application.properties` file.
+
+The route is in YAML DSL and was created with Apache Camel Karavan.
+You can try Karavan with the online editor at: https://karavan.space/
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== How to run
+
+Then you can run this example using:
+
+[source,sh]
+----
+$ camel run *
+----
+
+Or run with JBang using the longer command line (without installing camel as 
app in JBang):
+
+[source,sh]
+----
+$ jbang camel@apache/camel run *
+----
+
+=== Run directly from github
+
+The example can also be run directly by referring to the github URL as shown:
+
+[source,sh]
+----
+$ jbang camel@apache/camel run 
https://github.com/apache/camel-kamelets-examples/tree/main/jbang/prometheus
+----
+
+=== Micrometer
+
+The statistics from Micrometer can be observed from HTTP at:
+
+    http://localhost:8080/q/metrics
+
+You can also browse the developer console: http://localhost:8080/q/dev to 
introspect the running Camel application,
+such as browsing the micrometer, where you can see the captured statistics.
+
+The web console outputs data in text/html by default when using a web browser.
+However you can obtain the data in JSon format such as the micrometer with the 
following curl command:
+
+[source,bash]
+----
+curl -s -H "Accept: application/json" http://localhost:8080/q/dev/micrometer
+----
+
+And if you have `jq` installed to nicely format and output JSon in color then 
run:
+
+[source,bash]
+----
+curl -s -H "Accept: application/json" http://localhost:8080/q/dev/micrometer | 
jq
+----
+
+The metrics can also be displayed from the shell via:
+
+[source,sh]
+----
+$ camel get metric
+----
+
+
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/community/support/[let us know].
+
+We also love contributors, so
+https://camel.apache.org/community/contributing/[get involved] :-)
+
+The Camel riders!
diff --git a/jbang/prometheus/application.properties 
b/jbang/prometheus/application.properties
new file mode 100644
index 0000000..185741f
--- /dev/null
+++ b/jbang/prometheus/application.properties
@@ -0,0 +1,42 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
+camel.main.name = MyCoolCamel
+
+# allows source:line precise logging
+camel.main.sourceLocationEnabled=true
+
+# turn on dev console
+camel.context.dev-console=true
+
+# enable http server
+camel.server.enabled = true
+camel.server.dev-console-enabled = true
+camel.server.health-check-enabled = true
+# turn on micrometer prometheus on q/metrics
+camel.server.metrics-enabled = true
+
+# micrometer configurations
+camel.metrics.enabled=true
+camel.metrics.enable-message-history=true
+# additional binders to include cpu, jvm info etc
+camel.metrics.binders=processor,jvm-info,file-descriptor
+
+# application properties
+hi = Hello
diff --git a/jbang/prometheus/demo.camel.yaml b/jbang/prometheus/demo.camel.yaml
new file mode 100644
index 0000000..74101b1
--- /dev/null
+++ b/jbang/prometheus/demo.camel.yaml
@@ -0,0 +1,40 @@
+- route:
+    nodePrefixId: route-e2a
+    id: route-8847
+    from:
+      uri: timer
+      id: from-0922
+      parameters:
+        timerName: timer1
+        delay: '1000'
+        period: '5000'
+      steps:
+        - setBody:
+            expression:
+              simple:
+                expression: Hello World
+                id: simple-3fc3
+            id: setBody-b8e4
+        - to:
+            uri: direct
+            id: to-280f
+            parameters:
+              name: direct1
+- route:
+    nodePrefixId: route-6ce
+    id: route-a9b6
+    from:
+      uri: direct
+      id: from-a1fa
+      parameters:
+        name: direct1
+      steps:
+        - setBody:
+            constant: 'HELLO'
+            id: log-dcfc
+- rest:
+    id: rest-8cd4
+    post:
+      - path: /rest-api
+        to: direct:direct1
+        id: post-032f

Reply via email to