How to monitor JBoss EAP 7 in OpenShift monitoring
Environment
- Red hat OpenShift Container Platform (OCP)
- 4.x
- Red Hat JBoss EAP for OpenShift
- 7
- Template deployment
Issue
Customer wish to monitor JBoss EAP related metrics in openshift monitoring, How to do that?
Resolution
Metrics should come by default on template deployment in port 9990.
Follow the steps below to - Import Jboss templates for more information and customization:
oc new-project eapdemo
oc_project="$(oc project -q)"
for resource in \
eap74-basic-s2i.json
do
oc -n "$oc_project" create -f \
https://raw.githubusercontent.com/jboss-container-images/jboss-eap-openshift-templates/eap74/templates/${resource}
done
Install jboss for test with -e AB_PROMETHEUS_ENABLE=true
-e JAVA_OPTS_APPEND=-Dwildfly.statistics-enabled=true need to be added for jmx-exporter java agent that exposes Prometheus format metrics:
oc new-app --template=eap74-basic-s2i \
-p IMAGE_STREAM_NAMESPACE=openshift \
-p SOURCE_REPOSITORY_URL="https://github.com/jboss-developer/jboss-eap-quickstarts" \
-p SOURCE_REPOSITORY_REF=openshift \
-p CONTEXT_DIR=kitchensink \
-e AB_PROMETHEUS_ENABLE=true \
-e JAVA_OPTS_APPEND=-Dwildfly.statistics-enabled=true
Setup metrics related service
oc apply -f - << EOF
apiVersion: v1
kind: Service
metadata:
labels:
app: monitor_sample
name: eap-app-metrics
namespace: "$oc_project"
spec:
selector:
deploymentConfig: eap-app
ports:
- name: metrics
port: 9799
protocol: TCP
targetPort: 9799
EOF
Make sure enableUserWorkload: true
oc -n openshift-monitoring edit configmap cluster-monitoring-config
apiVersion: v1
data:
config.yaml: |
enableUserWorkload: true
Setup ServiceMonitor, as detailed on the solution EAP 8 and 7 container image jmx-exporter agent:
oc apply -f - << EOF
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: monitor
namespace: "$oc_project"
spec:
endpoints:
- port: metrics
selector:
matchLabels:
app: monitor_sample
EOF
Check in the web UI openshift -> Observe -> Metrics
Example: jboss_undertow_active_sessions How to monitor HTTP Sessions to count / view the number of active HTTP sessions in JBoss EAP
Updated on October 10, 2023
For JBoss EAP 7.3 and EAP 7, see the solution How to enable Prometheus and statistics in EAP for OpenShift? and for more details on the prometheus agent and test see solution EAP 7 image jmx-exporter agent.
As explained above, in JBoss EAP 7.3 and 7.4 for OpenShift, <pod-ip-address>:9990/metrics is exported by default via metrics subsystem. AB_PROMETHEUS_ENABLE=true is no longer needed to export metrics in Prometheus format. AB_PROMETHEUS_ENABLE=true is still available for backward compatibility in JBoss EAP 7.4 images.
It is recommended the metric subsystem instead of AB_PROMETHEUS_ENABLE=true because metrics exporting by Prometheus JMX exporter exposes only some of the subsystem metrics listed in /opt/jboss/container/prometheus/etc/jmx-exporter-config.yaml on JBoss EAP container images as below. It does not contain jboss_io_busy_task_thread_count one of the key metrics of JBoss EAP (for more details about BusyWorkerThreadCount):
whitelistObjectNames:
- "jboss.as:deployment=*,subsystem=ejb3,*"
- "jboss.as:deployment=*,subsystem=undertow"
- "jboss.as:deployment=*,subsystem=undertow,servlet=*"
- "jboss.as:deployment=*,subdeployment=*,subsystem=ejb3,*"
- "jboss.as:deployment=*,subdeployment=*,subsystem=undertow"
- "jboss.as:deployment=*,subdeployment=*,subsystem=undertow,servlet=*"
- "jboss.as:subsystem=datasources,data-source=*,statistics=jdbc"
- "jboss.as:subsystem=datasources,data-source=*,statistics=pool"
- "jboss.as:subsystem=datasources,xa-data-source=*,statistics=jdbc"
- "jboss.as:subsystem=datasources,xa-data-source=*,statistics=pool"
- "jboss.as:subsystem=messaging-activemq,server=*,jms-queue=*"
- "jboss.as:subsystem=messaging-activemq,server=*,jms-topic=*"
- "jboss.as:subsystem=transactions"
- "jboss.as:subsystem=undertow,server=*,http-listener=*"
In order to collect metrics exported by the metrics subsystem, the port needs to be changed from 9797 to 9990 in Service. The rest of the steps are the same as above.
oc apply -f - << EOF
apiVersion: v1
kind: Service
metadata:
labels:
app: monitor_sample
name: eap-app-metrics
namespace: "$oc_project"
spec:
selector:
deploymentConfig: eap-app
ports:
- name: metrics
port: 9990
protocol: TCP
targetPort: 9990
EOF
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments