Questo contenuto non è disponibile nella lingua selezionata.
Chapter 15. Prometheus metrics monitoring in Red Hat Process Automation Manager
Prometheus is an open-source systems monitoring toolkit that you can use with Red Hat Process Automation Manager to collect and store metrics related to the execution of business rules, processes, Decision Model and Notation (DMN) models, and other Red Hat Process Automation Manager assets. You can access the stored metrics through a REST API call to the KIE Server, through the Prometheus expression browser, or using a data-graphing tool such as Grafana.
You can configure Prometheus metrics monitoring for an on-premise KIE Server instance, for KIE Server on Spring Boot, or for a KIE Server deployment on Red Hat OpenShift Container Platform.
For the list of available metrics that KIE Server exposes with Prometheus, download the Red Hat Process Automation Manager 7.13.5 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhpam-7.13.5-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-services/kie-server-services-prometheus/src/main/java/org/kie/server/services/prometheus.
Red Hat support for Prometheus is limited to the setup and configuration recommendations provided in Red Hat product documentation.
15.1. Configuring Prometheus metrics monitoring for KIE Server Copia collegamentoCollegamento copiato negli appunti!
You can configure your KIE Server instances to use Prometheus to collect and store metrics related to your business asset activity in Red Hat Process Automation Manager. For the list of available metrics that KIE Server exposes with Prometheus, download the Red Hat Process Automation Manager 7.13.5 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhpam-7.13.5-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-services/kie-server-services-prometheus/src/main/java/org/kie/server/services/prometheus.
Prerequisites
- KIE Server is installed.
-
You have
kie-serveruser role access to KIE Server. - Prometheus is installed. For information about downloading and using Prometheus, see the Prometheus documentation page.
Procedure
-
In your KIE Server instance, set the
org.kie.prometheus.server.ext.disabledsystem property tofalseto enable the Prometheus extension. You can define this property when you start KIE Server or in thestandalone.xmlorstandalone-full.xmlfile of Red Hat Process Automation Manager distribution. If you are running Red Hat Process Automation Manager on Spring Boot, configure the required key in the
application.propertiessystem property:Spring Boot application.properties key for Red Hat Process Automation Manager and Prometheus
kieserver.jbpm.enabled=true kieserver.drools.enabled=true kieserver.dmn.enabled=true kieserver.prometheus.enabled=true
kieserver.jbpm.enabled=true kieserver.drools.enabled=true kieserver.dmn.enabled=true kieserver.prometheus.enabled=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the
prometheus.yamlfile of your Prometheus distribution, add the following settings in thescrape_configssection to configure Prometheus to scrape metrics from KIE Server:Scrape configurations in prometheus.yaml file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Scrape configurations in prometheus.yaml file for Spring Boot (if applicable)
scrape_configs: - job_name: 'kie' metrics_path: /rest/metrics static_configs: - targets: ["HOST:PORT"]scrape_configs: - job_name: 'kie' metrics_path: /rest/metrics static_configs: - targets: ["HOST:PORT"]Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the values according to your KIE Server location and settings.
Start the KIE Server instance.
Example start command for Red Hat Process Automation Manager on Red Hat JBoss EAP
cd ~/EAP_HOME/bin ./standalone.sh --c standalone-full.xml
$ cd ~/EAP_HOME/bin $ ./standalone.sh --c standalone-full.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow After you start the configured KIE Server instance, Prometheus begins collecting metrics and KIE Server publishes the metrics to the REST API endpoint
http://HOST:PORT/SERVER/services/rest/metrics(or on Spring Boot, tohttp://HOST:PORT/rest/metrics).In a REST client or curl utility, send a REST API request with the following components to verify that KIE Server is publishing the metrics:
For REST client:
-
Authentication: Enter the user name and password of the KIE Server user with the
kie-serverrole. HTTP Headers: Set the following header:
-
Accept:application/json
-
-
HTTP method: Set to
GET. -
URL: Enter the KIE Server REST API base URL and metrics endpoint, such as
http://localhost:8080/kie-server/services/rest/metrics(or on Spring Boot,http://localhost:8080/rest/metrics).
For curl utility:
-
-u: Enter the user name and password of the KIE Server user with thekie-serverrole. -H: Set the following header:-
accept:application/json
-
-
-X: Set toGET. -
URL: Enter the KIE Server REST API base URL and metrics endpoint, such as
http://localhost:8080/kie-server/services/rest/metrics(or on Spring Boot,http://localhost:8080/rest/metrics).
Example curl command for Red Hat Process Automation Manager on Red Hat JBoss EAP
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/kie-server/services/rest/metrics"
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/kie-server/services/rest/metrics"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example curl command for Red Hat Process Automation Manager on Spring Boot
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/rest/metrics"
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/rest/metrics"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the metrics are not available in KIE Server, review and verify the KIE Server and Prometheus configurations described in this section.
You can also interact with your collected metrics in the Prometheus expression browser at
http://HOST:PORT/graph, or integrate your Prometheus data source with a data-graphing tool such as Grafana:Figure 15.1. Prometheus expression browser with KIE Server metrics
Figure 15.2. Prometheus expression browser with KIE Server target
Figure 15.3. Grafana dashboard with KIE Server metrics for DMN models
Figure 15.4. Grafana dashboard with KIE Server metrics for solvers
Figure 15.5. Grafana dashboard with KIE Server metrics for processes, cases, and tasks
-
Authentication: Enter the user name and password of the KIE Server user with the
Additional resources
15.2. Configuring Prometheus metrics monitoring for KIE Server on Red Hat OpenShift Container Platform Copia collegamentoCollegamento copiato negli appunti!
You can configure your KIE Server deployment on Red Hat OpenShift Container Platform to use Prometheus to collect and store metrics related to your business asset activity in Red Hat Process Automation Manager. For the list of available metrics that KIE Server exposes with Prometheus, download the Red Hat Process Automation Manager 7.13.5 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhpam-7.13.5-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-services/kie-server-services-prometheus/src/main/java/org/kie/server/services/prometheus.
Prerequisites
- KIE Server is installed and deployed on Red Hat OpenShift Container Platform. For more information about KIE Server on OpenShift, see the relevant OpenShift deployment option in the Product documentation for Red Hat Process Automation Manager 7.13.
-
You have
kie-serveruser role access to KIE Server. - Prometheus Operator is installed. For information about downloading and using Prometheus Operator, see the Prometheus Operator project in GitHub.
Procedure
In the
DeploymentConfigobject of your KIE Server deployment on OpenShift, set thePROMETHEUS_SERVER_EXT_DISABLEDenvironment variable tofalseto enable the Prometheus extension. You can set this variable in the OpenShift web console or use theoccommand in a command terminal:oc set env dc/<dc_name> PROMETHEUS_SERVER_EXT_DISABLED=false -n <namespace>
oc set env dc/<dc_name> PROMETHEUS_SERVER_EXT_DISABLED=false -n <namespace>Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you have not yet deployed your KIE Server on OpenShift, then in the OpenShift template that you plan to use for your OpenShift deployment (for example,
rhpam713-prod-immutable-kieserver.yaml), you can set thePROMETHEUS_SERVER_EXT_DISABLEDtemplate parameter tofalseto enable the Prometheus extension.If you are using the OpenShift Operator to deploy KIE Server on OpenShift, then in your KIE Server configuration, set the
PROMETHEUS_SERVER_EXT_DISABLEDenvironment variable tofalseto enable the Prometheus extension:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
service-metrics.yamlfile to add a service that exposes the metrics from KIE Server to Prometheus:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a command terminal, use the
occommand to apply theservice-metrics.yamlfile to your OpenShift deployment:oc apply -f service-metrics.yaml
oc apply -f service-metrics.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create an OpenShift secret, such as
metrics-secret, to access the Prometheus metrics on KIE Server. The secret must contain the "username" and "password" elements with KIE Server user credentials. For information about OpenShift secrets, see the Secrets chapter in the OpenShift Developer Guide. Create a
service-monitor.yamlfile that defines theServiceMonitorobject. A service monitor enables Prometheus to connect to the KIE Server metrics service.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a command terminal, use the
occommand to apply theservice-monitor.yamlfile to your OpenShift deployment:oc apply -f service-monitor.yaml
oc apply -f service-monitor.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow After you complete these configurations, Prometheus begins collecting metrics and KIE Server publishes the metrics to the REST API endpoint
http://HOST:PORT/kie-server/services/rest/metrics.You can interact with your collected metrics in the Prometheus expression browser at
http://HOST:PORT/graph, or integrate your Prometheus data source with a data-graphing tool such as Grafana.The host and port for the Prometheus expression browser location
http://HOST:PORT/graphwas defined in the route where you exposed the Prometheus web console when you installed the Prometheus Operator. For information about OpenShift routes, see the Routes chapter in the OpenShift Architecture documentation.Figure 15.6. Prometheus expression browser with KIE Server metrics
Figure 15.7. Prometheus expression browser with KIE Server target
Figure 15.8. Grafana dashboard with KIE Server metrics for DMN models
Figure 15.9. Grafana dashboard with KIE Server metrics for solvers
Figure 15.10. Grafana dashboard with KIE Server metrics for processes, cases, and tasks
Additional resources
15.3. Extending Prometheus metrics monitoring in KIE Server with custom metrics Copia collegamentoCollegamento copiato negli appunti!
After you configure your KIE Server instance to use Prometheus metrics monitoring, you can extend the Prometheus functionality in KIE Server to use custom metrics according to your business needs. Prometheus then collects and stores your custom metrics along with the default metrics that KIE Server exposes with Prometheus.
As an example, this procedure defines custom Decision Model and Notation (DMN) metrics to be collected and stored by Prometheus.
Prerequisites
- Prometheus metrics monitoring is configured for your KIE Server instance. For information about Prometheus configuration with KIE Server on-premise, see Section 15.1, “Configuring Prometheus metrics monitoring for KIE Server”. For information about Prometheus configuration with KIE Server on Red Hat OpenShift Container Platform, see Section 15.2, “Configuring Prometheus metrics monitoring for KIE Server on Red Hat OpenShift Container Platform”.
Procedure
Create an empty Maven project and define the following packaging type and dependencies in the
pom.xmlfile for the project:Example pom.xml file in the sample project
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Implement the relevant listener from the
org.kie.server.services.prometheus.PrometheusMetricsProviderinterface as part of the custom listener class that defines your custom Prometheus metrics, as shown in the following example:Sample implementation of the
DMNRuntimeEventListenerlistener in a custom listener classCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
PrometheusMetricsProviderinterface contains the required listeners for collecting Prometheus metrics. The interface is incorporated by thekie-server-services-prometheusdependency that you declared in your projectpom.xmlfile.In this example, the
ExampleCustomPrometheusMetricListenerclass implements theDMNRuntimeEventListenerlistener (from thePrometheusMetricsProviderinterface) and defines the custom DMN metrics to be collected and stored by Prometheus.Implement the
PrometheusMetricsProviderinterface as part of a custom metrics provider class that associates your custom listener with thePrometheusMetricsProviderinterface, as shown in the following example:Sample implementation of the
PrometheusMetricsProviderinterface in a custom metrics provider classCopy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the
MyPrometheusMetricsProviderclass implements thePrometheusMetricsProviderinterface and includes your customExampleCustomPrometheusMetricListenerlistener class.-
To make the new metrics provider discoverable for KIE Server, create a
META-INF/services/org.kie.server.services.prometheus.PrometheusMetricsProviderfile in your Maven project and add the fully qualified class name of thePrometheusMetricsProviderimplementation class within the file. For this example, the file contains the single lineorg.kie.server.ext.prometheus.MyPrometheusMetricsProvider. Build your project and copy the resulting JAR file into the
~/kie-server.war/WEB-INF/libdirectory of your project. For example, on Red Hat JBoss EAP, the path to this directory isEAP_HOME/standalone/deployments/kie-server.war/WEB-INF/lib.If you are deploying Red Hat Process Automation Manager on Red Hat OpenShift Container Platform, create a custom KIE Server image and add this JAR file to the image. For more information about creating a custom KIE Server image with an additional JAR file, see Deploying an Red Hat Process Automation Manager environment on Red Hat OpenShift Container Platform 4 using Operators.
Start the KIE Server and deploy the built project to the running KIE Server. You can deploy the project using the Business Central interface or the KIE Server REST API (a
PUTrequest tohttp://SERVER:PORT/kie-server/services/rest/server/containers/{containerId}).After your project is deployed on a running KIE Server, Prometheus begins collecting metrics and KIE Server publishes the metrics to the REST API endpoint
http://HOST:PORT/SERVER/services/rest/metrics(or on Spring Boot, tohttp://HOST:PORT/rest/metrics).