Tuesday, 10 October 2017

Further stories of a tinkerer - this time it's IBM BPM, Apache Kibana and Elasticsearch

As per my previous post: -


I'm using this: -


as inspiration.

Start the Deployment Environment

/opt/ibm/WebSphere/AppServer/bin/BPMConfig.sh -start -profile Dmgr01 -de De1

Enable BPM Analytics

/opt/ibm/WebSphereProfiles/Dmgr01/bin/wsadmin.sh -lang jython -f /opt/ibm/WebSphere/AppServer/BPM/Lombardi/tools/def/EnableBPMAnalytics.py

Realm/Cell Name: <default>
Username: wasadmin
Password:         
 WASX7209I: Connected to process "dmgr" on node Dmgr using SOAP connector;  The type of process is: DeploymentManager
JMS Queue Connection Factory "monitorCF" in cell scope is created.
Queue destination "monitorDestination" on bus "BPM.De1.Bus" is created.
JMS Queue "monitorQueue" in cell scope is created.
JMS Activation specification "defAS" in cell scope is created.
Native JSON DEF event is configured. defListenerId is "jmsListenerForJSON".
DEF is reloaded.
WASX7327I: Contents of was.policy file:
 //
// Template policy file for enterprise application.
// Extra permissions can be added if required by the enterprise application.
//
// NOTE: Syntax errors in the policy files will cause the enterprise application FAIL to start.
//       Extreme care should be taken when editing these policy files. It is advised to use
//       the policytool provided by the JDK for editing the policy files
//       (WAS_HOME/java/jre/bin/policytool). 
//

grant codeBase "file:${application}" {
};

grant codeBase "file:${jars}" {
};

grant codeBase "file:${connectorComponent}" {
};

grant codeBase "file:${webComponent}" {
};

grant codeBase "file:${ejbComponent}" {
};


ADMA5016I: Installation of BPMEventEmitter_war_De1 started.
ADMA5058I: Application and module versions are validated with versions of deployment targets.
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
ADMA5081I: The bootstrap address for client module is configured in the WebSphere Application Server repository.
ADMA5053I: The library references for the installed optional package are created.
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
ADMA5001I: The application binaries are saved in /opt/ibm/WebSphereProfiles/Dmgr01/wstemp/Script15f0620c96e/workspace/cells/PCCell1/applications/BPMEventEmitter_war_De1.ear/BPMEventEmitter_war_De1.ear
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
SECJ0400I: Successfully updated the application BPMEventEmitter_war_De1 with the appContextIDForSecurity information.
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
ADMA5005I: The application BPMEventEmitter_war_De1 is configured in the WebSphere Application Server repository.
ADMA5113I: Activation plan created successfully.
ADMA5011I: The cleanup of the temp directory for application BPMEventEmitter_war_De1 is complete.
ADMA5013I: Application BPMEventEmitter_war_De1 installed successfully.
Saving Configuration


Stop the Deployment Environment

/opt/ibm/WebSphere/AppServer/bin/BPMConfig.sh -stop -profile Dmgr01 -de De1

Start the Deployment Environment

/opt/ibm/WebSphere/AppServer/bin/BPMConfig.sh -start -profile Dmgr01 -de De1

Navigate to the Process Portal


Launch a BPD

I chose Standard HR Open New Position - other processes are available, though :-)

Navigate to the Integrated Solutions Console



Edit the BPM Event Emitter YAML file

- I'm using a standard 3-cluster Deployment Environment, so this file is for the Support Cluster

vi /opt/ibm/WebSphereProfiles/Dmgr01/config/cells/PCCell1/clusters/SupCluster/analytics/config/BPMEventEmitter.yml

I only needed to make one change: -

# Configuration properties for the Elasticsearch server
# Elasticsearch is the default event consumer.
# The monitor event is transformed into the Kibana query-optimized format
# before it is written to the Elasticsearch index as a document.
esConfiguration:
    hosts: macbook:9200
    enabled: true
    # The Elasticsearch index name
    index: bpm-events
    # Enable the following properties when Elasticsearch security is on.
    username: elastic
    password: <xor>d3hrdXJEeXU=
    httpsTrustType:
    trustFileLocation:
    hostnameVerifier:
    esTaskIndex: restore_task_index

# The identifier for this BPM environment
# It can be the cell name or any other appropriate identifier.     
bpmCellName: bpmCell01


as I'm NOT using security within Elasticsearch, which is running in a Docker container on my MacBook.

For the record, I validated that the VM hosting BPM could access Elasticsearch: -


{
  "name" : "i1VZYw9",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Dc8j18ioSpWV1Qm16F0pcA",
  "version" : {
    "number" : "5.6.2",
    "build_hash" : "57e20f3",
    "build_date" : "2017-09-23T13:16:45.703Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

Fully Synchronise the Nodes

/opt/ibm/WebSphereProfiles/Dmgr01/bin/wsadmin.sh -lang jython -f fullSync.jy

Start the Application

/opt/ibm/WebSphereProfiles/Dmgr01/bin/wsadmin.sh -lang jython

AdminControl.invoke('WebSphere:name=ApplicationManager,process=SupClusterMember1,platform=proxy,node=Node1,version=8.5.5.12,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=PCCell1,spec=1.0', 'startApplication', '[BPMEventEmitter_war_De1]')

Check the logs

tail -f /opt/ibm/WebSphereProfiles/AppSrv01/logs/SupClusterMember1/SystemOut.log

...
[10/10/17 18:09:46:094 BST] 00000077 ConfigConnect I   CWMCD1002I: The Kafka connection is disabled.
[10/10/17 18:09:46:103 BST] 00000077 RestClientMan W   CWMCD0030W: The current Elasticsearch channel for localhost:9200 is not secured. IBM highly recommends that you secure the channel to prevent network attacks. Refer to the user's documentation to enable security.
[10/10/17 18:09:46:198 BST] 00000077 ConfigConnect I   CWMCD1005I: The ElasticSearch connection is created.
[10/10/17 18:09:46:230 BST] 00000077 LifeCycleMana E class com.ibm.bpm.mon.oi.LifeCycleManageBean startMethod CWMCD1016E: The creation of the Elasticsearch index mapping failed on an exception.
                                 java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:731)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:192)
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
        at java.lang.Thread.run(Thread.java:785)

[10/10/17 18:09:46:234 BST] 00000077 BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "startMethod" on bean "BeanId(BPMEventEmitter_war_De1#BPMEventEmitter.war#LifeCycleManageBean, null)". Exception data: java.lang.RuntimeException: CWMCD1016E: The creation of the Elasticsearch index mapping failed on an exception.
        at com.ibm.bpm.mon.oi.LifeCycleManageBean.startMethod(LifeCycleManageBean.java:68)


Stop, have a nice cup of tea and regroup

There WAS a clue in the logs above, but it took me several hours to find it …

Yeah, you've spotted it … why do the logs refer to localhost when I've configured BPM to connect to Elasticsearch via the socket macbook:9200 ?

I'd obviously misread the documentation, specifically this PDF IBM Business Process Manager Analytics which said, in part: -




I had ONLY edited the cluster-level file and not the server-level file.

Once I did this: -

vi /opt/ibm/WebSphereProfiles/Dmgr01/config/cells/PCCell1/nodes/Node1/servers/SupClusterMember1/analytics/config/BPMEventEmitter.yml

# Configuration properties for the Elasticsearch server
# Elasticsearch is the default event consumer.
# The monitor event is transformed into the Kibana query-optimized format
# before it is written to the Elasticsearch index as a document.
esConfiguration:
    hosts: macbook:9200
    enabled: true
    # The Elasticsearch index name
    index: bpm-events
    # Enable the following properties when Elasticsearch security is on.
    username: elastic
    password: <xor>d3hrdXJEeXU=
    httpsTrustType:
    trustFileLocation:
    hostnameVerifier:
    esTaskIndex: restore_task_index

# The identifier for this BPM environment
# It can be the cell name or any other appropriate identifier.     
bpmCellName: bpmCell01


re-synchronised the node: -

/opt/ibm/WebSphereProfiles/Dmgr01/bin/wsadmin.sh -lang jython -f fullSync.jy

started the Application

/opt/ibm/WebSphereProfiles/Dmgr01/bin/wsadmin.sh -lang jython

AdminControl.invoke('WebSphere:name=ApplicationManager,process=SupClusterMember1,platform=proxy,node=Node1,version=8.5.5.12,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=PCCell1,spec=1.0', 'startApplication', '[BPMEventEmitter_war_De1]')


and checked the logs

tail -f /opt/ibm/WebSphereProfiles/AppSrv01/logs/SupClusterMember1/SystemOut.log

[10/10/17 18:22:30:751 BST] 000000a7 AdminHelper   A   ADMN1008I: An attempt is made to start the BPMEventEmitter_war_De1 application. (User ID = defaultWIMFileBasedRealm/wasadmin)
[10/10/17 18:22:30:760 BST] 000000a7 CompositionUn A   WSVR0190I: Starting composition unit WebSphere:cuname=BPMEventEmitter_war_De1 in BLA WebSphere:blaname=BPMEventEmitter_war_De1.
[10/10/17 18:22:30:822 BST] 000000a7 ApplicationMg A   WSVR0200I: Starting application: BPMEventEmitter_war_De1
[10/10/17 18:22:30:823 BST] 000000a7 ApplicationMg A   WSVR0204I: Application: BPMEventEmitter_war_De1  Application build level: Unknown
[10/10/17 18:22:32:036 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.QueryParam annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:037 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.MatrixParam annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:038 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.core.Context annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:039 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.CookieParam annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:039 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.PathParam annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:040 BST] 000000a7 AbstractInjec W   CWNEN0070W: The javax.ws.rs.HeaderParam annotation class will not be recognized because it was loaded from the file:/opt/ibm/WebSphereProfiles/AppSrv01/installedApps/PCCell1/BPMEventEmitter_war_De1.ear/BPMEventEmitter.war/WEB-INF/lib/jsr311-api-1.1.1.jar location rather than from a product class loader.
[10/10/17 18:22:32:045 BST] 000000a7 SharedEJBRunt I   WSVR0037I: Starting EJB jar: BPMEventEmitter.war
[10/10/17 18:22:32:104 BST] 000000a7 WASNameSpaceB I   CNTR0167I: The server is binding the com.ibm.bpm.mon.oi.LifeCycleManageBean interface of the LifeCycleManageBean enterprise bean in the BPMEventEmitter.war module of the BPMEventEmitter_war_De1 application.  The binding location is: ejblocal:BPMEventEmitter_war_De1/BPMEventEmitter.war/LifeCycleManageBean#com.ibm.bpm.mon.oi.LifeCycleManageBean
[10/10/17 18:22:32:107 BST] 000000a7 WASNameSpaceB I   CNTR0167I: The server is binding the com.ibm.bpm.mon.oi.LifeCycleManageBean interface of the LifeCycleManageBean enterprise bean in the BPMEventEmitter.war module of the BPMEventEmitter_war_De1 application.  The binding location is: ejblocal:com.ibm.bpm.mon.oi.LifeCycleManageBean
[10/10/17 18:22:32:108 BST] 000000a7 AbstractEJBRu I   CNTR0167I: The server is binding the com.ibm.bpm.mon.oi.LifeCycleManageBean interface of the LifeCycleManageBean enterprise bean in the BPMEventEmitter.war module of the BPMEventEmitter_war_De1 application.  The binding location is: java:global/BPMEventEmitter/LifeCycleManageBean!com.ibm.bpm.mon.oi.LifeCycleManageBean
[10/10/17 18:22:32:110 BST] 000000a7 AbstractEJBRu I   CNTR0180I: The BPMEventEmitterMDB message-driven bean in the BPMEventEmitter.war module of the BPMEventEmitter_war_De1 application is bound to the jms/defAS activation specification.
[10/10/17 18:22:32:117 BST] 000000a7 ActivationSpe I   J2CA0291I: Application BPMEventEmitter_war_De1#BPMEventEmitter.war#BPMEventEmitterMDB has an <activation-config-property>, destinationJndiName, for which there is no corresponding property on the ActivationSpec class jms/defAS(com.ibm.ws.sib.api.jmsra.impl.JmsJcaActivationSpecImpl) of ResourceAdapter cells/PCCell1/resources.xml#J2CResourceAdapter_1507551590072. This property will be ignored. This may have undesirable effects.
[10/10/17 18:22:32:154 BST] 000000a7 SibMessage    I   [:] CWSIV0777I: A connection to messaging engine MECluster.000-BPM.De1.Bus for destination monitorDestination on bus BPM.De1.Bus has been successfully created.
[10/10/17 18:22:32:156 BST] 000000a7 ActivationSpe I   J2CA0523I: The Message Endpoint for ActivationSpec jms/defAS (com.ibm.ws.sib.api.jmsra.impl.JmsJcaActivationSpecImpl) and MDB Application BPMEventEmitter_war_De1#BPMEventEmitter.war#BPMEventEmitterMDB is activated.
[10/10/17 18:22:32:183 BST] 000000a7 SharedEJBRunt I   WSVR0057I: EJB jar started: BPMEventEmitter.war
[10/10/17 18:22:32:184 BST] 000000a7 webapp        I com.ibm.ws.webcontainer.webapp.WebGroupImpl WebGroup SRVE0169I: Loading Web Module: BPMEventEmitter.
[10/10/17 18:22:32:191 BST] 000000a7 WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key default_hostBPMEventEmitter
[10/10/17 18:22:34:113 BST] 000000a7 webcontainer  I com.ibm.ws.webcontainer.VirtualHostImpl addWebApplication SRVE0250I: Web Module BPMEventEmitter has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443,*:9061,*:9044,*:9062,*:9081,*:9444,*:9045,*:9063,*:9082,*:9445,*:9046].
[10/10/17 18:22:34:136 BST] 000000a7 LifeCycleMana I   Application Name:IBM BPM Analytics
[10/10/17 18:22:34:137 BST] 000000a7 LifeCycleMana I   Application Version:8.6.0.0
[10/10/17 18:22:34:137 BST] 000000a7 LifeCycleMana I   Build Level:20170918_46
[10/10/17 18:22:34:248 BST] 000000a7 ConfigConnect I   CWMCD1002I: The Kafka connection is disabled.
[10/10/17 18:22:34:254 BST] 000000a7 RestClientMan W   CWMCD0030W: The current Elasticsearch channel for macbook:9200 is not secured. IBM highly recommends that you secure the channel to prevent network attacks. Refer to the user's documentation to enable security.
[10/10/17 18:22:34:327 BST] 000000a7 ConfigConnect I   CWMCD1005I: The ElasticSearch connection is created.
[10/10/17 18:22:36:780 BST] 000000a7 LifeCycleMana I   CWMCD1014I: The BPMEventEmitter message-driven bean (MDB) is started.
[10/10/17 18:22:36:792 BST] 000000a7 ApplicationMg A   WSVR0221I: Application started: BPMEventEmitter_war_De1
[10/10/17 18:22:36:793 BST] 000000a7 CompositionUn A   WSVR0191I: Composition unit WebSphere:cuname=BPMEventEmitter_war_De1 in BLA WebSphere:blaname=BPMEventEmitter_war_De1 started.

I then checked Kibana, which is running within the same Docker container as Elasticsearch: -


clicked the Play buttton

and, c'est voila, there are my events: -



etc.

I went one stage further and clicked the spanner ( wrench ) icon: -


to get a cURL test client: -

curl -XGET "http://localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match_all": {}
  }
}'

amended it to replace localhost with macbook, and ran it: -

curl -XGET "http://macbook:9200/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match_all": {}
  }
}'


which returned: -

{"took":2,"timed_out":false,"_shards":{"total":11,"successful":11,"skipped":0,"failed":0},"hits":{"total":13,"max_score":1.0,"hits":[{"_index":".kibana","_type":"config","_id":"5.6.2","_score":1.0,"_source":{"buildNum":15543}},{"_index":"bpm-events","_type":"ActivityEvent","_id":"f07332cb-a777-4215-bc49-b97c7c4af9fc_T7169e00460f51792162189","_score":1.0,"_source":{"mon:id":"T7169e00460f51792162189","mon:eventPointData":{"mon:kind":{"mon:version":"2010-11-11","content":"bpmnx:ACTIVITY_ACTIVE"},"mon:time":{"mon:of":"occurrence","content":"2017-10-10T13:26:22.228+01:00"},"ibm:sequenceId":"0000000008","mon:model":[{"mon:id":"bpdid:431b0753c33842e2:3d5457c0:141a2fd3448:-75fb","mon:type":"bpmn:userTask","mon:version":"2064.cca1f786-0c79-4e4e-8539-5767b38c3a48","mon:name":"Submit position request","mon:instance":{"mon:id":"5","mon:role":{"mon:id":"PERFORMER","mon:resource":{"mon:id":"wasadmin","mon:name":"wasadmin"}}},"wle:snapshot-name":"Responsive Hiring Sample v8600_02"},{"mon:id":"c904b3b1-afc1-4698-bf5a-a20892c20275","mon:type":"bpmn:process","mon:version":"2064.cca1f786-0c79-4e4e-8539-5767b38c3a48","mon:name":"Standard HR Open New Position","mon:documentation":"This process covers a manager requesting to create a new position or fill an existing position. The process routes the position request to the Human Resources (HR) department to search for candidates.","mon:instance":{"mon:id":"53","mon:state":"Active"},"wle:snapshot-name":"Responsive Hiring Sample v8600_02"},{"mon:id":"9ab0d0c6-d92c-4355-9ed5-d8a05acdc4b0","mon:type":"wle:processApplication","mon:version":"2064.cca1f786-0c79-4e4e-8539-5767b38c3a48","mon:name":"Hiring Sample","mon:documentation":"Hiring Sample","wle:snapshot-name":"Responsive Hiring Sample v8600_02"}],"mon:correlation":{"mon:ancestor":{"mon:id":"c904b3b1-afc1-4698-bf5a-a20892c20275.2064.cca1f786-0c79-4e4e-8539-5767b38c3a48.53.5"

So that was easy :-)

I've also got the EventSummaryAgent with which to play, but that's another job for another day … :-)

For the record, my IBM colleague, Allen Chan, presented upon this a few months back: -



No comments: