Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Monitor business metrics with Red Hat Process Automation Manager, Elasticsearch, and Kibana

May 4, 2020
Sadhana Nandakumar
Related topics:
JavaDevOpsMicroservicesEvent-Driven

Share:

    Red Hat Process Automation Manager is a platform for developing containerized microservices and applications that automate business decisions and processes. Combining process- and task-level SLA metrics plus case-related breakdowns can be beneficial for identifying trends and reorganizing the workforce as necessary. So, a critical piece of a business process system is having real-time insights into what is happening, and both monitoring KPI metrics and responding to problem trends is an integral part of operations.

    Integration with Elasticsearch improves our search capabilities and provides a unified reporting environment for the business. Maciej Swiderski blogged about how we can potentially use Elasticsearch to capture KPI metrics and provide for full-text search capabilities. This article extends the idea and walks through how to enable integration with Elasticsearch on a Red Hat OpenShift environment, and how to represent the KPIs in a graphical business-friendly dashboard using Kibana.

    Preparing the demo environment

    Let’s install the necessary components for this demonstration on Red Hat OpenShift, which enables efficient container orchestration and allows rapid container provisioning, deployment, scaling, and management.

    Setting up Elastic and Kibana

    Let's make use of the Elastic cluster Operator to set up Elastic/Kibana on OpenShift:

    $ oc apply -f https://download.elastic.co/downloads/eck/1.0.1/all-in-one.yaml 
    $ oc new-project elastic

    Now, we can deploy an Elastic instance:

    $ cat <<EOF | oc apply -n elastic -f -
    # This sample sets up an Elasticsearch cluster with an OpenShift route
    apiVersion: elasticsearch.k8s.elastic.co/v1
    kind: Elasticsearch
    metadata:
      name: elasticsearch-sample
    spec:
      version: 7.6.2
      nodeSets:
      - name: default
        count: 1
        config:
          node.master: true
          node.data: true
          node.ingest: true
          node.store.allow_mmap: false
    ---
    
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      name: elasticsearch-sample
    spec:
      #host: elasticsearch.example.com # override if you don't want to use the host that is automatically generated by OpenShift (<route-name>[-<namespace>].<suffix>)
      tls:
        termination: passthrough # Elasticsearch is the TLS endpoint
        insecureEdgeTerminationPolicy: Redirect
      to:
        kind: Service
        name: elasticsearch-sample-es-http
    EOF

    Next, let us deploy a Kibana instance:

    $ cat <<EOF | oc apply -n elastic -f -
    apiVersion: kibana.k8s.elastic.co/v1
    kind: Kibana
    metadata:
      name: kibana-sample
    spec:
      version: 7.6.2
      count: 1
      elasticsearchRef:
        name: "elasticsearch-sample"
      podTemplate:
        spec:
          containers:
          - name: kibana
            resources:
              limits:
                memory: 1Gi
                cpu: 1
    ---
    apiVersion: v1
    kind: Route
    metadata:
      name: kibana-sample
    spec:
      #host: kibana.example.com # override if you don't want to use the host that is automatically generated by OpenShift (<route-name>[-<namespace>].<suffix>)
      tls:
        termination: passthrough # Kibana is the TLS endpoint
        insecureEdgeTerminationPolicy: Redirect
      to:
        kind: Service
        name: kibana-sample-kb-http
    EOF

    We can now access the Kibana dashboard from the route exposed:

    $ oc get route -n elastic
    

    The credentials for logging into Kibana can be found under Secrets for the Elastic project, as shown in Figure 1.

    The login credentials for Kibana are available in Secrets
    Figure 1: The login credentials for Kibana are available in Secrets.

    Setting up the Elasticsearch event emitter 

    The event emitter integration code is a single Java class that implements the EventEmitter interface. A basic implementation of the emitter can be found here. By default process, task, and case metrics are pushed on to the corresponding indexes on Elastic:

    if (view instanceof ProcessInstanceView) {
        index = "processes";
        type = "process";
        id = ((ProcessInstanceView) view).getCompositeId();
    } else if (view instanceof TaskInstanceView) {
        index = "tasks";
        type = "task";
        id = ((TaskInstanceView) view).getCompositeId();
    } else if (view instanceof CaseInstanceView) {
        index = "cases";
        type = "case";
        id = ((CaseInstanceView) view).getCompositeId();
    }
    content.append("{ \"index\" : { \"_index\" : \"" + index + "\", \"_type\" : \"" + type + "\", \"_id\" : \"" + id + "\" } }\n");
    content.append(json);
    

    We can now extend this basic implementation and allow for HTTPS authentication because the Elastic instance on OpenShift is exposed over HTTPS:

    protected CloseableHttpClient buildClient() throws Exception{
       HttpClientBuilder builder = HttpClients.custom();
       if (elasticSearchUser != null && elasticSearchPassword != null) {
           SSLContextBuilder builder1 = new SSLContextBuilder();
           builder1.loadTrustMaterial(null, new TrustStrategy() {
               @Override
               public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                   return true;
               }
           });
           CredentialsProvider provider = new BasicCredentialsProvider();
           UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(elasticSearchUser, elasticSearchPassword);
           provider.setCredentials(AuthScope.ANY, credentials);
           SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(builder1.build(), new NoopHostnameVerifier());
           builder.setDefaultCredentialsProvider(provider);
           builder.setSSLSocketFactory(sslConnectionSocketFactory).build();
       }
       return builder.build();
    }

    Please note that for the purpose of this demonstration, we bypassed the certificate check and used the basic authentication mechanism. For a production use case, it is necessary to authenticate with a valid certificate.

    We can now build a custom Docker image with the event emitter JAR on the KIE server war’s classpath:

    FROM docker-registry.default.svc:5000/openshift/rhpam-kieserver-rhel8:7.5.0
    COPY contrib/jbpm-event-emitters-elasticsearch-7.36.0-SNAPSHOT.jar /opt/eap/standalone/deployments/ROOT.war/WEB-INF/lib/jbpm-event-emitters-elasticsearch-7.36.0-SNAPSHOT.jar
    USER root
    RUN chownjboss:root /opt/eap/standalone/deployments/ROOT.war/WEB-INF/lib/jbpm-event-emitters-elasticsearch-7.36.0-SNAPSHOT.jar && \
    chmod 664 /opt/eap/standalone/deployments/ROOT.war/WEB-INF/lib/jbpm-event-emitters-elasticsearch-7.36.0-SNAPSHOT.jar
    USER jboss

    We also need to pass the corresponding metadata for the Elastic cluster using the JAVA_OPTS Kie Server property:

    $ oc set env dc/{{ pam_app_name }}-kieserver JAVA_OPTS_APPEND=>\"-Dorg.jbpm.event.emitters.elasticsearch.url=https://{{routeelastic.stdout}} -Dorg.jbpm.event.emitters.elasticsearch.user=elastic -Dorg.jbpm.event.emitters.elasticsearch.password={{elasticpwd.stdout}}\" -n {{ OCP_PROJECT }}

    Business activity monitoring

    Now that we are done with the setup, let us quickly look at to visualize the process, task, and case metrics using Kibana. Let us begin by logging into Business Central and pulling a project from the Try Samples section, as shown in Figures 2 and 3.

    Business Central -&gt; Space -&gt; MySpace -&gt; Projects -&gt; dropdown list box -&gt; Try Sample
    Figure 2: Pulling up the Try Samples section.
    The Try Samples project as it appears in MySpace
    Figure 3: The Try Samples section contains a variety of options.

    For this example, we will build and deploy the Mortgage_Process project. We will use this project for metrics visualization. Let us now kickstart a process using the process start form:

    Enter the details into the process start form
    Figure 4: Enter the details into the process start form.

    The process is created, as shown in Figure 5.

    The MortgageApprovalProcess in the Process Instance perspective
    Figure 5: The MortgageApprovalProcess in the Process Instance perspective.

    Now, log into the Kibana dashboard. We will start with a basic visualization for both processes and tasks. Kibana templates provide an exportable JSON format for sharing graphical reports across instances of Kibana. A sample template can be found here. Import the template from the Kibana dashboard's Saved Objects section, under the Management option.

    We now have a sample dashboard available for processes (Figure 6) and tasks (Figure 7).

    Dashboard showing the sample project's processes.
    Figure 6: The new sample Processes dashboard.
    Dashboard showing the sample project's tasks
    Figure 7: The new sample Tasks dashboard.

    As these tasks are worked on and the processes head to completion, their status and updates are pushed to Elastic, as shown in Figure 8.

    dashboard showing tasks broken down in 4 ways
    Figure 8: Track the progress of your tasks and processes through their dashboards.

    Now let us create custom metrics from the process data. We can assume that we need to filter out the cases where property price is over 2 million and property age is less than 25 years. Kibana provides a convenient way to create full-text searches and then lets us convert the result to a visualization.

    Open the raw data section of Kibana and create a custom query to filter out the data, as shown in Figure 9.

    Kibana's raw section with two fields chosen and used in a custom query
    Figure 9: Create your custom filter.

    We can easily convert this data into a visualization by saving this search and creating a bar chart out of it, as shown in Figures 10 and 11.

    Kibana's New Vertical Bar / Choose a source dialog box.
    Figure 10: Create a bar chart.
    Kibana showing your new bar chart.
    Figure 11: Your new bar chart.

    Similar visualizations can be created for cases, too. A sample case visualization using KPI metrics for the case can be set up as shown in Figure 12.

    Dashboard showing cases broken down in 4 ways
    Figure 12: The sample case visualization.

    A complete example of the setup can be found here.

    Summary

    By setting up an integration with Elasticsearch, we can visualize data from the business automation engine side-by-side with the metrics from other disparate systems. Doing this also provides for faster, more scalable, business-friendly visualizations fit for operations management.

    References

    Elasticsearch empowers jBPM

    Deploying Elastic and Kibana on Openshift

    Last updated: June 26, 2020

    Recent Posts

    • Integrate Red Hat AI Inference Server & LangChain in agentic workflows

    • Streamline multi-cloud operations with Ansible and ServiceNow

    • Automate dynamic application security testing with RapiDAST

    • Assessing AI for OpenShift operations: Advanced configurations

    • OpenShift Lightspeed: Assessing AI for OpenShift operations

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue